using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using gregn6Lib;
|
using SQLHelper;
|
using DBUtility;
|
using System.Threading;
|
using System.IO;
|
|
namespace WarM
|
{
|
public partial class Sc_ICMOToBarCode : Form
|
{
|
public Sc_ICMOToBarCode()
|
{
|
InitializeComponent();
|
}
|
public frmBillQueryCondition_New frmCondition;
|
public string ViewName = "Sc_ICMOBillStatus_Tmp";
|
public string ModCaption = "快速生成条码";
|
public const string ModName = "3722";
|
public const string ModRightName = "Sc_ICMOToBarCode";
|
public const string ModRightNameEdit = ModRightName + "_Edit";
|
public const string ModRightNameCheck = ModRightName + "_Check";
|
public const string ModRightNameClose = ModRightName + "_Close";
|
public const string ModRightNameDelete = ModRightName + "_Delete";
|
public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//DAL.ClsGy_ICBomBill oBill = new DAL.ClsGy_ICBomBill();
|
//public Gy_ICBomBill oFrm;
|
public int selectRow = 0;
|
public int selectRow2 = 0;
|
public string sDlgWhere = ""; //外窗体递入
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public Int64 HInterID = 0;
|
//
|
private void initGrid()
|
{
|
DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name);
|
}
|
//
|
|
private void Display()
|
{
|
ClsCN SubCn = new ClsCN();
|
DataSet DSet;
|
string sSql = "";
|
string sFastSQL = "";
|
//生产订单号
|
//if (txtHICMOBillNo.Text.Trim() != "")
|
//{
|
// sFastSQL = sFastSQL + " and HICMOBillNo like '%" + txtHICMOBillNo.Text + "%'";
|
//}
|
string HICMOBillNo = "";
|
HICMOBillNo = txtHICMOBillNo.Text.Trim().ToString();
|
//销售订单号
|
string HSeOrderBillNo = "";
|
HICMOBillNo = txtHSeOrderBillNo.Text.Trim().ToString();
|
//物料
|
//if (txtHMaterID.Text.Trim() != "")
|
//{
|
// sFastSQL = sFastSQL + " and HMaterName like '%" + txtHMaterID.Text + "%'";
|
//}
|
string HMaterName = "";
|
HMaterName = txtHMaterID.Text.Trim().ToString();
|
//机台
|
//if (txtHSourceID.Text.Trim() != "")
|
//{
|
// sFastSQL = sFastSQL + " and HSourceName like '%" + txtHSourceID.Text + "%'";
|
//}
|
string HSourceName = "";
|
HSourceName = txtHSourceID.Text.Trim().ToString();
|
//职员
|
string HEmpName = "";
|
HEmpName = txtHEmpID.Text.Trim().ToString();
|
//判断开始日期
|
//if (dtpHBeginDate.Checked)
|
//{
|
// sFastSQL = sFastSQL + " and 日期>='" + dtpHBeginDate.Value.ToShortDateString() + "'";
|
//}
|
string HBeginDate = "";
|
HBeginDate = dtpHBeginDate.Value.ToShortDateString();
|
|
//判断结束日期
|
//if (dtpHEndDate.Checked)
|
//{
|
// sFastSQL = sFastSQL + " and 日期<='" + dtpHEndDate.Value.ToShortDateString() + "'";
|
//}
|
string HEndDate = "";
|
HEndDate = dtpHEndDate.Value.ToShortDateString();
|
//if (sFastSQL.Trim() == "")
|
//{
|
// MessageBox.Show("没有输入条件!");
|
// return;
|
//}
|
|
//过滤条件
|
|
//
|
DSet = SubCn.RunProcReturn("exec h_p_KSTMSC '" + HSeOrderBillNo + "' ,'" + HICMOBillNo + "' , '" + HMaterName + "' , '" + HSourceName + "' ,'" + HEmpName + "' ,'" + HBeginDate + "', '" + HEndDate + "'", "h_p_KSTMSC", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
|
//标准装箱
|
//for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
//{
|
// txtHMiniQty.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("HMiniQty")].Value);
|
// if (txtHMiniQty.Text.Trim() != "")
|
// {
|
// txtHMiniQty.Enabled = false;
|
// }
|
//}
|
//冻结
|
//int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
|
//string s = frmCondition.cmbHComplete.Text;
|
//DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s,FrCol);
|
//画线
|
GraphLine();
|
|
|
//
|
}
|
|
//
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled=false;
|
initGrid();
|
Display();
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void sx_Click(object sender, EventArgs e)
|
{
|
timer1.Enabled = true;
|
}
|
|
private void dj_Click(object sender, EventArgs e)
|
{
|
Sub_ShowBill();
|
}
|
//显示单据
|
private void Sub_ShowBill()
|
{
|
//Int64 lngBillKey = 0;
|
//if (grdMain.CurrentRow == null)
|
// return;
|
//lngBillKey =DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
//if (lngBillKey == 0)
|
// return;
|
//DAL.ClsGy_ICBomBill oBill = new DAL.ClsGy_ICBomBill();
|
//if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
|
//{
|
// oFrm = new Gy_ICBomBill();
|
// oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
|
// oFrm.BillOld = oBill;
|
// oFrm.ShowDialog();
|
// if (oFrm.BillChange)
|
// {
|
// if (MessageBox.Show("单据列表已经发生变化,是否刷新", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
// {
|
// timer1.Enabled = true;
|
// }
|
// }
|
//}
|
//else
|
//{
|
// MessageBox.Show("单据未找到", "提示");
|
//}
|
//oBill = null;
|
}
|
//
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
private Int32 Fun_GetColList(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
|
}
|
//
|
private void Sc_ICMOToBarCode_Load(object sender, EventArgs e)
|
{
|
//
|
//frmCondition = new frmBillQueryCondition_New();
|
this.Text = ModCaption;
|
//lblCaption.Text = ModCaption;
|
initGrid();
|
}
|
|
private void grdMain_DblClick(object sender, EventArgs e)
|
{
|
Sub_ShowBill();
|
}
|
|
private void cx_Click(object sender, EventArgs e)
|
{
|
//frmCondition = new frmBillQueryCondition_New();
|
//SetCondition(frmCondition, ViewName, this.Name);
|
//frmCondition.ShowDialog();
|
//if (frmCondition.Tag.ToString() == "OK")
|
//{
|
// Display();
|
//}
|
}
|
|
//public void SetCondition(frmBillQueryCondition_New frmCondition, string ViewName, string Name)
|
//{
|
// frmCondition.Tag = "";
|
// frmCondition.ViewName = ViewName;
|
// frmCondition.ModName = Name;
|
//}
|
|
private void xz_Click(object sender, EventArgs e)
|
{
|
//
|
//oFrm = new Gy_ICBomBill();
|
//oFrm.ShowDialog();
|
}
|
|
private void sc_Click(object sender, EventArgs e)
|
{
|
Sub_DeleteBill();
|
}
|
//删除
|
private void Sub_DeleteBill()
|
{
|
// //编辑权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
//
|
//Int64 lngBillKey = 0;
|
//if (grdMain.CurrentRow == null)
|
// return;
|
//lngBillKey = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
//if (lngBillKey == 0)
|
// return;
|
//DAL.ClsGy_BarCodeBill_View oBill = new DAL.ClsGy_BarCodeBill_View();
|
//DAL.ClsGy_BarCodeBill_Ctl oBillC = new DAL.ClsGy_BarCodeBill_Ctl();
|
//if (oBill.GetInfoByID(lngBillKey))
|
//{
|
// if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
// {
|
// if (!oBillC.DeleteByID(lngBillKey))
|
// {
|
// MessageBox.Show(DBUtility.ClsPub.sExeReturnInfo, "提示");
|
// return;
|
// }
|
// else
|
// {
|
// Display();
|
// }
|
|
// }
|
//}
|
//else
|
//{
|
// MessageBox.Show("单据未找到", "提示");
|
//}
|
|
Int64 lngBillKey = 0;
|
if (grdMain.CurrentRow == null)
|
return;
|
if (MessageBox.Show("确定要删除所选单据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value);
|
if (lngBillKey == 0)
|
return;
|
DAL.ClsGy_BarCodeBill_View oBill = new DAL.ClsGy_BarCodeBill_View();
|
DAL.ClsGy_BarCodeBill_Ctl oBillC = new DAL.ClsGy_BarCodeBill_Ctl();
|
if (oBill.GetInfoByID(lngBillKey))
|
{
|
try
|
{
|
oBillC.DeleteByID(lngBillKey);
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show("删除失败,条码" + grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value + "已被使用", "提示");
|
Display();
|
return;
|
}
|
if (oBillC.DeleteByID(lngBillKey) != true)
|
{
|
MessageBox.Show("删除失败,原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("单据未找到!", "提示");
|
return;
|
}
|
}
|
}
|
MessageBox.Show("删除成功!", "提示");
|
Display();
|
}
|
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
//timer2.Enabled = false;
|
//frmCondition = new frmBillQueryCondition_New();
|
//SetCondition(frmCondition, ViewName, this.Name);
|
//frmCondition.ShowDialog();
|
//if (frmCondition.Tag.ToString() == "OK")
|
//{
|
// timer1.Enabled = true;
|
//}
|
}
|
|
|
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
//保存列宽
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
}
|
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
|
}
|
//
|
private void GraphLine()
|
{
|
//int MainIDCol = Fun_GetCol("hmainid");
|
//int SubIDCol = Fun_GetCol("hsubid");
|
//string s = frmCondition.cmbHComplete.Text;
|
//long n=0;
|
//DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s,ref n);
|
//显示
|
//lbldj.Text = "查询出 " + n.ToString() + " 张单据";
|
//lbljl.Text = "共有 " + grdMain.RowCount.ToString() + " 条记录";
|
}
|
//审核
|
private void sh_Click(object sender, EventArgs e)
|
{
|
this.Sub_CheckBill();
|
}
|
|
//审核单据
|
private void Sub_CheckBill()
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true,DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
//
|
Int64 lngBillKey = 0;
|
if (grdMain.CurrentRow == null)
|
return;
|
lngBillKey = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
if (lngBillKey == 0)
|
return;
|
DAL.ClsGy_ICBomBill oBill = new DAL.ClsGy_ICBomBill();
|
//查看是否已审核,关闭,作废
|
if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HChecker.Trim() != "")
|
{
|
MessageBox.Show("单据已审核!不能再次审核", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
//审核
|
if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
|
{
|
MessageBox.Show("审核成功!", "提示");
|
return;
|
}
|
else
|
{
|
MessageBox.Show("审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
}
|
//反审单据
|
private void Sub_AbandonCheck()
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true,DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
//
|
Int64 lngBillKey = 0;
|
if (grdMain.CurrentRow == null)
|
return;
|
lngBillKey = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
if (lngBillKey == 0)
|
return;
|
DAL.ClsGy_ICBomBill oBill = new DAL.ClsGy_ICBomBill();
|
//查看是否已审核,关闭,作废
|
if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HChecker.Trim() == "")
|
{
|
MessageBox.Show("单据未审核!不需要反审核!", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
//反审核
|
if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
|
{
|
MessageBox.Show("反审核成功!", "提示");
|
return;
|
}
|
else
|
{
|
MessageBox.Show("反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
}
|
//反审核
|
private void qsh_Click(object sender, EventArgs e)
|
{
|
Sub_AbandonCheck();
|
}
|
|
private void GraphicsGrid()
|
{
|
DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
|
}
|
|
#region //打印设置
|
|
GridppReport Report;
|
|
//预览
|
int CurRows = 0;
|
private void yl_Click(object sender, EventArgs e)
|
{
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.PrintPreview(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
private void Sub_SetReport(string sOpenTmp)
|
{
|
//判断行数
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
grdMain.Rows[i].Cells[0].Value = "";
|
}
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
|
}
|
//
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
|
}
|
|
//填入单据表头信息
|
private void ReportBeforePostRecord()//your report?kao
|
{
|
try
|
{
|
//Report.FieldByName("物料代码").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("物料代码")].Value.ToString();
|
//Report.FieldByName("物料名称").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("物料名称")].Value.ToString();
|
//Report.FieldByName("规格型号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("规格型号")].Value.ToString();
|
////Report.FieldByName("自定义规格").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("自定义规格")].Value.ToString();
|
//Report.FieldByName("条码编号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("条码编号")].Value.ToString();
|
//Report.FieldByName("数量").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("数量")].Value.ToString();
|
//Report.FieldByName("批次").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("批号")].Value.ToString();
|
//Report.FieldByName("源单单号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("源单单号")].Value.ToString();
|
//Report.FieldByName("销售订单号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("销售订单号")].Value.ToString();
|
//Report.FieldByName("采购订单号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("采购订单号")].Value.ToString();
|
//Report.FieldByName("供应商").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("往来单位")].Value.ToString();
|
//Report.FieldByName("生产车间").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("生产车间")].Value.ToString();
|
//Report.FieldByName("备注").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("备注")].Value.ToString();
|
//Report.FieldByName("总托数").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("总托数")].Value.ToString();
|
//Report.FieldByName("托号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("托号")].Value.ToString();
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表头:" + e.Message);
|
}
|
//CurRows = CurRows + 1;
|
}
|
private void ReportFetchRecordByDataTable()
|
{
|
try
|
{
|
DataTable ds = new DataTable();
|
BLL.Utility.FillRecordToReport_Sel(Report, grdMain, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
#endregion
|
//
|
private void grdMain_Paint(object sender, PaintEventArgs e)
|
{
|
GraphicsGrid();
|
}
|
|
private void dy_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
//打印前判断条码是否已打印过
|
string sBarCode = "";
|
string sRelQty = "";
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
sBarCode = sBarCode + "," + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
//if (oBar.Set_BPrintQty(sBarCode.Substring(1), ref sRelQty))
|
//{
|
// MessageBox.Show(sRelQty);
|
// return;
|
//}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
//DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(false);
|
//oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdMain.Rows[CurRows].Cells[Fun_GetCol("条码编号")].Value));
|
Thread.Sleep(1000);
|
}
|
|
//批量更新条码打印次数
|
oBar.Set_EPrintQty(sBarCode.Substring(1));
|
}
|
|
private void dy2_Click(object sender, EventArgs e)
|
{
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
//
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
selectRow = i;
|
selectRow2 = i + 1;
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(false);
|
oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value));
|
//
|
if (selectRow2 > grdMain.SelectedRows.Count - 1)
|
{
|
}
|
else
|
{
|
oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i + 1].Cells[Fun_GetCol("条码编号")].Value));
|
}
|
Thread.Sleep(1000);
|
i++;
|
}
|
}
|
}
|
|
private void yc_Click(object sender, EventArgs e)
|
{
|
DataGridViewToExcel2(grdMain, this.Text, this.Text);
|
}
|
|
/// <summary>
|
/// 网格 导出EXCEL 网格,文件名,标题名
|
/// </summary>
|
public static void DataGridViewToExcel2(DataGridView grdMain, string sText, string sBTText)
|
{
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
saveFileDialog.Filter = "Execl文件(*.xls)|*.xls";
|
saveFileDialog.FilterIndex = 0;
|
saveFileDialog.RestoreDirectory = true;
|
saveFileDialog.CreatePrompt = true;
|
saveFileDialog.Title = "数据视图导出EXCEL文件";
|
saveFileDialog.FileName = sText;
|
//saveFileDialog.ShowDialog();
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
{
|
Stream myStream;
|
myStream = saveFileDialog.OpenFile();
|
StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312"));
|
string str = "";
|
DateTime start = DateTime.Now;
|
try
|
{
|
if (sBTText != "")
|
{
|
sw.WriteLine(sBTText);
|
}
|
//写标题
|
bool sFirstCol = true;
|
for (int i = 0; i < grdMain.ColumnCount; i++)
|
{
|
if (i > 0 && grdMain.Columns[i].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[i].HeaderText.Substring(0, 1) != "H" && sFirstCol != true)
|
{
|
str += "\t";
|
}
|
if (grdMain.Columns[i].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[i].HeaderText.Substring(0, 1) != "H")
|
{
|
sFirstCol = false;
|
str += grdMain.Columns[i].HeaderText;
|
}
|
}
|
str = str.Replace("\n", "");
|
sw.WriteLine(str);
|
|
//写内容
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
string tempStr = "";
|
sFirstCol = true;
|
for (int k = 0; k < grdMain.Columns.Count; k++)
|
{
|
if (k > 0 && grdMain.Columns[k].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[k].HeaderText.Substring(0, 1) != "H" && sFirstCol != true)
|
{
|
tempStr += "\t";
|
}
|
if (grdMain.Columns[k].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[k].HeaderText.Substring(0, 1) != "H")
|
{
|
sFirstCol = false;
|
if (grdMain.Rows[j].Cells[k].Value == null)
|
{
|
tempStr += string.Empty;
|
}
|
else
|
{
|
tempStr += grdMain.Rows[j].Cells[k].Value.ToString();
|
}
|
}
|
}
|
tempStr = tempStr.Replace("\n", "");
|
sw.WriteLine(tempStr);
|
}
|
sw.Close();
|
myStream.Close();
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message);
|
}
|
finally
|
{
|
sw.Close();
|
myStream.Close();
|
}
|
MessageBox.Show("将此工作表导出为excel共耗时:" + DateTime.Now.Subtract(start).TotalMilliseconds.ToString() + "毫秒");
|
}
|
}
|
|
private void zf_Click(object sender, EventArgs e)
|
{
|
//Sub_AbandonCheck();
|
if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
if (grdMain.CurrentRow == null)
|
return;
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
if (MessageBox.Show("确定要作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
{
|
return;
|
}
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
if (DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HMaterID")].Value) != 0)
|
{
|
if (!oBar.Cancelltion(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value)))
|
{
|
MessageBox.Show("作废失败!", "提示");
|
return;
|
}
|
}
|
}
|
MessageBox.Show("作废成功!", "提示");
|
}
|
|
private void fzf_Click(object sender, EventArgs e)
|
{
|
//this.Sub_CheckBill();
|
if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
if (grdMain.CurrentRow == null)
|
return;
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
if (MessageBox.Show("确定要反作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
{
|
return;
|
}
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
if (DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HMaterID")].Value) != 0)
|
{
|
if (!oBar.UnCancelltion(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value)))
|
{
|
MessageBox.Show("反作废失败!", "提示");
|
return;
|
}
|
}
|
}
|
MessageBox.Show("反作废成功!", "提示");
|
}
|
|
private void cmdHSaveBill_Click(object sender, EventArgs e)
|
{
|
|
Display();
|
}
|
|
private void button4_Click(object sender, EventArgs e)
|
{
|
//1.获取界面上面整箱数量框输入的数量 赋值给变量 并刷新网格
|
double HBarCodeQty = 0;
|
double HZXQty = 0;
|
HZXQty = ClsPub.isDoule(txtHZXQty.Text);
|
if (HZXQty ==0)
|
{
|
MessageBox.Show("请输入整箱数量!");
|
return;
|
}
|
Display();
|
//2.获取网格选中行物料ID
|
int a = grdMain.CurrentRow.Index;
|
long HMaterID = 0;
|
HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[a].Cells[Fun_GetCol("HMaterID")].Value);
|
if (HMaterID == 0)
|
{
|
MessageBox.Show("没有选中任何记录!");
|
return;
|
}
|
//3.定义是否组托的变量
|
int Mul = 0;
|
//4.根据单据类型获取本次条码主内码HInterID
|
HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
|
//5.从网格第一行循环至最后一行 判断I行的物料内码与M是否一致;如果不一致则循环下一行;
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
long HGrdMaterID = 0;
|
HGrdMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("HMaterID")].Value);
|
if (HMaterID == HGrdMaterID)
|
{
|
double HDDQty = 0;
|
HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
|
if (HDDQty >= HZXQty)
|
{
|
HBarCodeQty = HZXQty;
|
this.Sub_SaveBill();
|
Display();
|
Mul = Mul + 1;
|
break;
|
}
|
else if(HDDQty < HZXQty)
|
{
|
HBarCodeQty = HDDQty;
|
HZXQty = HZXQty - HDDQty;
|
this.Sub_SaveBill();
|
Mul = Mul + 1;
|
continue;
|
}
|
}
|
}
|
|
|
//3.先判断物料是否一致 如果一致开始循环网格
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
//long HGrdMaterID = 0;
|
//HGrdMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("HMaterID")].Value);
|
//if (HGrdMaterID == HMaterID)
|
//{
|
// double HDDQty = 0;
|
// HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
|
// //如果循环的该行记录的订单数量已经大于等于本次装箱数量 则直接生成唯一码 并且刷新网格 刷新条码信息页
|
// if (HDDQty >= HZXQty)
|
// {
|
// double HBarCodeQty = 0;
|
// HBarCodeQty = HZXQty;
|
// this.Sub_SaveBill();
|
// Display();
|
// }
|
// //如果改行记录订单数量小于本次装箱数量 则继续循环 走生成托条码方法
|
// else
|
// {
|
// //查出符合条件的选中这条数量跟装箱数量的差异值
|
// double HCYQty = 0;
|
// HCYQty = HZXQty - DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
|
|
// }
|
|
//}
|
//else
|
//{
|
|
//}
|
}
|
|
|
|
|
}
|
|
private void Sub_SaveBill()
|
{
|
HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
|
string HMaterNumber = "";
|
string HBatchNo = "";
|
string HDate = "";
|
string HYear = "";
|
string HPeriod = "";
|
string HDay = "";
|
string HTMNumber = "";
|
string HOrgNumber = "";
|
DataSet Ds;
|
int LSH = 0; //流水号
|
string LSH2 = ""; //流水号转换成字符
|
double HZXQty = 0; //装箱数量
|
double HDDQty = 0; //订单数量
|
double HBQty = 0; //箱数
|
int k = 0;
|
int n = 0; //同一批生成条码中的第几条
|
string WeiShu = ""; //尾数
|
int LSHlen = 6; //流水号长度
|
string TM = ""; //条码
|
for (int j = 0; j < grdMain.SelectedRows.Count; j++)
|
{
|
HMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[j].Index].Cells[Fun_GetCol("物料代码")].Value);
|
HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[j].Index].Cells[Fun_GetCol("批次")].Value);
|
HDate = DateTime.Now.ToShortDateString();
|
HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
|
HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
|
HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
|
HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
|
HDay = HDay.Substring(HDay.Length - 2, 2);
|
HOrgNumber = ClsPub.HOrgNumber;
|
|
|
//HBQty = HBQty + ClsPub.isInt(txtHBQty.Text);
|
HZXQty = ClsPub.isDoule(txtHZXQty.Text);
|
HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.SelectedRows[j].Index].Cells[Fun_GetCol("订单数量")].Value);
|
|
|
if (cmbHBarCodeType.Text == "唯一条码")
|
{
|
HTMNumber = HOrgNumber + HMaterNumber + HYear + HPeriod + HDay;
|
Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
|
}
|
else if (cmbHBarCodeType.Text == "批次条码")
|
{
|
TM = HOrgNumber + HMaterNumber + HBatchNo;
|
}
|
n = 0;
|
|
LSH2 = LSH.ToString();
|
while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
if (cmbHBarCodeType.Text == "唯一条码")
|
{
|
//条码编号 = 条码前缀 + 流水号
|
TM = HTMNumber + LSH2;
|
}
|
if (TM.Trim() == "")
|
{
|
MessageBox.Show("条形码不能为空,不能生成条码!");
|
return;
|
}
|
string HWei = ""; //尾数
|
string HBarCode = "";
|
string HBarCodeType = "";
|
Int64 HMaterID1 = 0;
|
Int64 HAuxPropID = 0;
|
Int64 HUnitID = 0;
|
double HQty2 = 0;
|
string HBatchNo2 = "";
|
Int64 HSupID = 0;
|
Int64 HGroupID = 0;
|
int HPrintQty = 0;
|
Int64 HSourceInterID = 0;
|
Int64 HSourceEntryID = 0;
|
string HSourceBillNo = "";
|
string HSourceBillType = "";
|
Int64 HBarcodeNo = 0; //托号
|
Int64 HBarcodeQtys = 0; //总托数
|
Int64 HDeptID = 0;
|
Int64 HWhID = 0;
|
Int64 HSPID = 0;
|
string HRemark = "";
|
string HMaterName = "";
|
string HMaterModel = "";
|
string HPinfan = "";
|
string HMTONo = "";
|
Int64 HCusID = 0;
|
string HCusType = "";
|
DateTime HEndDate;
|
string HWorkLineName = "";
|
string HSeOrderBillNo = "";
|
string HInnerBillNo = "";
|
try
|
{
|
oCn.BeginTran();
|
HWei = WeiShu;
|
HBarCode = TM;
|
HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text);
|
HMaterID1 = ClsPub.isLong(grdMain.SelectedRows[j].Cells[Fun_GetCol("HMaterID")].Value);
|
HAuxPropID = 0;
|
HUnitID = 0;
|
HQty2 = HZXQty;
|
HBatchNo2 = ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("批次")].Value);
|
HSourceInterID = 0;
|
HSourceEntryID = 0;
|
HSourceBillNo = ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("生产订单号")].Value);
|
HSourceBillType = "3710";
|
HBarcodeQtys = 0;
|
HBarcodeNo = 0;
|
HSupID = 0;
|
HDeptID = 0;
|
HWhID = 0;
|
HSPID = 0;
|
HRemark = "";
|
HMaterName = ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("物料名称")].Value);
|
HMaterModel = ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("规格型号")].Value);
|
HPinfan = "";
|
HMTONo = "";
|
HCusID = 0;
|
HCusType = "";
|
HEndDate = ClsPub.isDate(grdMain.SelectedRows[j].Cells[Fun_GetCol("日期")].Value);
|
HWorkLineName = "";
|
HSeOrderBillNo = "";
|
HInnerBillNo = "";
|
oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
|
",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
|
",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
|
",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
|
",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
|
",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
|
") values ("
|
+ "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID1.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
|
+ ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
|
+ ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
|
+ ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
|
+ ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + HDate + "'"
|
+ ", " + ClsPub.HOrgID.ToString() + "," + ClsPub.HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString()
|
+ ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')");
|
oCn.Commit();
|
MessageBox.Show("条码生成完毕!");
|
//grdSub.RowCount = 0;
|
DisplayTM();
|
}
|
|
catch (Exception e1)
|
{
|
oCn.RollBack();
|
MessageBox.Show("条码生成失败!" + e1.Message);
|
}
|
}
|
}
|
|
|
|
private void DisplayTM()
|
{
|
DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,条码不存在!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdList.DataSource = DSet.Tables[0].DefaultView;
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdList, this.Name + "grdList", s, FrCol);
|
//画线
|
//GraphLine();
|
//
|
}
|
|
//private void button5_Click(object sender, EventArgs e)
|
//{
|
// //判断是否已经生成条码
|
// for (int j = 0; j < grdMain.SelectedRows.Count; j++)
|
// {
|
// if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("HBarCode")].Value) == "")
|
// {
|
// MessageBox.Show("条码未生成,请先生成条码后再预览!");
|
// return;
|
// }
|
|
// //打印前判断条码是否已打印过
|
// if (ReportPrintBegin())
|
// {
|
// return;
|
// }
|
|
// //选择打印模板
|
// BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
// oFrm.sBillName = ModName;
|
// oFrm.sBillModel = ModCaption;
|
// oFrm.ShowDialog();
|
// if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
// {
|
// Sub_SetReport(oFrm.sOpenTmp);
|
// Report.PrintPreview(false);
|
// Thread.Sleep(1000);
|
// }
|
// }
|
//}
|
|
|
//打印前判断条码是否已打印过
|
//private bool ReportPrintBegin()
|
//{
|
// string sRelQty = "";
|
|
// if (oBar.Set_BPrintQty(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("HBarCode")].Value), ref sRelQty))
|
// {
|
// MessageBox.Show("条码已经打印过,不可重复打印!");
|
// return true;
|
// }
|
// else
|
// {
|
// return false;
|
// }
|
//}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
//打印前判断条码是否已打印过
|
string sBarCode = "";
|
string sRelQty = "";
|
for (int i = 0; i < grdSub.SelectedRows.Count; i++)
|
{
|
sBarCode = sBarCode + "," + DBUtility.ClsPub.isStrNull(grdSub.Rows[grdSub.SelectedRows[i].Index].Cells[Fun_GetCol("HBarcode")].Value);
|
}
|
//if (oBar.Set_BPrintQty(sBarCode.Substring(1), ref sRelQty))
|
//{
|
// MessageBox.Show(sRelQty);
|
// return;
|
//}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
//DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(false);
|
//oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdMain.Rows[CurRows].Cells[Fun_GetCol("条码编号")].Value));
|
Thread.Sleep(1000);
|
}
|
|
//批量更新条码打印次数
|
oBar.Set_EPrintQty(sBarCode.Substring(1));
|
}
|
|
private void cmdHSaveBill1_Click(object sender, EventArgs e)
|
{
|
Display1();
|
}
|
|
private void Display1()
|
{
|
ClsCN SubCn = new ClsCN();
|
DataSet DSet;
|
string sSql = "";
|
string sFastSQL = "";
|
//生产订单号
|
//if (txtHICMOBillNo.Text.Trim() != "")
|
//{
|
// sFastSQL = sFastSQL + " and HICMOBillNo like '%" + txtHICMOBillNo.Text + "%'";
|
//}
|
string HICMOBillNo = "";
|
HICMOBillNo = txtHICMOBillNo1.Text.Trim().ToString();
|
//物料
|
//if (txtHMaterID.Text.Trim() != "")
|
//{
|
// sFastSQL = sFastSQL + " and HMaterName like '%" + txtHMaterID.Text + "%'";
|
//}
|
string HMaterName = "";
|
HMaterName = txtHMaterID1.Text.Trim().ToString();
|
//判断开始日期
|
//if (dtpHBeginDate.Checked)
|
//{
|
// sFastSQL = sFastSQL + " and 日期>='" + dtpHBeginDate.Value.ToShortDateString() + "'";
|
//}
|
string HBeginDate = "";
|
HBeginDate = dtpHBeginDate1.Value.ToShortDateString();
|
|
//判断结束日期
|
//if (dtpHEndDate.Checked)
|
//{
|
// sFastSQL = sFastSQL + " and 日期<='" + dtpHEndDate.Value.ToShortDateString() + "'";
|
//}
|
string HEndDate = "";
|
HEndDate = dtpHEndDate1.Value.ToShortDateString();
|
//if (sFastSQL.Trim() == "")
|
//{
|
// MessageBox.Show("没有输入条件!");
|
// return;
|
//}
|
|
//过滤条件
|
|
//
|
DSet = SubCn.RunProcReturn("exec h_p_KSTMCX '" + HICMOBillNo + "' , '" + HMaterName + "' ,'" + HBeginDate + "', '" + HEndDate + "'", "h_p_KSTMCX", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdSub.DataSource = DSet.Tables[0].DefaultView;
|
//冻结
|
//int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
|
//string s = frmCondition.cmbHComplete.Text;
|
//DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name, s, FrCol);
|
//画线
|
GraphLine();
|
|
|
//
|
}
|
|
private void cmdHSourceID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_WorkCenter_View oWork = new DAL.ClsGy_WorkCenter_View();
|
if (oWork.RefreshView())
|
{
|
this.txtHSourceID.Text = oWork.oModel.HName;
|
this.txtHSourceID.Tag = oWork.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHSourceID.Text = "";
|
}
|
}
|
|
private void cmdHEmpID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
|
if (oEmp.RefreshView())
|
{
|
this.txtHEmpID.Text = oEmp.oModel.HName;
|
this.txtHEmpID.Tag = oEmp.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHEmpID.Text = "";
|
}
|
}
|
|
private void cmdHMaterID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View();
|
if (oMater.RefreshView())
|
{
|
this.txtHMaterID.Text = oMater.oModel.HName;
|
this.txtHMaterID.Tag = oMater.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHMaterID.Text = "";
|
}
|
}
|
|
private void cmdHMaterID1_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View();
|
if (oMater.RefreshView())
|
{
|
this.txtHMaterID1.Text = oMater.oModel.HName;
|
this.txtHMaterID1.Tag = oMater.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHMaterID1.Text = "";
|
}
|
}
|
|
private void txtHMiniQty_TextChanged(object sender, EventArgs e)
|
{
|
//double HMiniQty = 0;
|
//double HBQty = 0;
|
//HMiniQty = DBUtility.ClsPub.isDoule(txtHMiniQty.Text.Trim());
|
//HBQty =
|
|
|
}
|
|
private void txtHBQty_TextChanged(object sender, EventArgs e)
|
{
|
double HICMOQty = 0;
|
double HMiniQty = 0;
|
double HBQty = 0;
|
|
|
|
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
txtHZXQty.Text = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("订单数量")].Value);
|
}
|
HICMOQty = DBUtility.ClsPub.isDoule(txtHZXQty.Text.Trim());
|
HMiniQty = DBUtility.ClsPub.isDoule(txtHMiniQty.Text.Trim());
|
if (HMiniQty == 0)
|
{
|
HBQty = 0;
|
}
|
else
|
{
|
HBQty = HICMOQty / HMiniQty;
|
}
|
HBQty = Math.Ceiling(HBQty);
|
txtHBQty.Text = DBUtility.ClsPub.isStrNull(HBQty);
|
}
|
|
private void button5_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
for (int i = 0; i < grdList.SelectedRows.Count; i++)
|
{
|
if (DBUtility.ClsPub.isStrNull(grdList.SelectedRows[i].Cells[Fun_GetColList("条码编号")].Value) == "")
|
{
|
MessageBox.Show("条码未生成,请先生成条码后再预览!");
|
return;
|
}
|
}
|
|
//打印前判断条码是否已打印过
|
if (ReportPrintBegin())
|
{
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.PrintPreview(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
private bool ReportPrintBegin()
|
{
|
string sRelQty = "";
|
|
if (oBar.Set_BPrintQty(DBUtility.ClsPub.isStrNull(grdList.Rows[0].Cells[Fun_GetColList("条码编号")].Value), ref sRelQty))
|
{
|
MessageBox.Show("条码已经打印过,不可重复打印!");
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
private void button6_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (DBUtility.ClsPub.isStrNull(grdList.Rows[0].Cells[Fun_GetColList("条码编号")].Value) == "")
|
{
|
MessageBox.Show("条码未生成,请先生成条码后再预览!");
|
return;
|
}
|
|
//打印前判断条码是否已打印过
|
if (ReportPrintBegin())
|
{
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.PrintPreview(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
private void cz_Click(object sender, EventArgs e)
|
{
|
txtHBQty.Text = "";
|
txtHEmpID.Text = "";
|
txtHICMOBillNo.Text = "";
|
txtHICMOBillNo1.Text = "";
|
txtHZXQty.Text = "";
|
txtHMaterID.Text = "";
|
txtHMaterID1.Text = "";
|
txtHMiniQty.Text = "";
|
txtHSourceID.Text = "";
|
cmbHBarCodeType.Items.Clear();
|
grdList.DataSource = null;
|
grdSub.DataSource = null;
|
grdMain.DataSource = null;
|
}
|
}
|
}
|