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; namespace WorkM { public partial class Sc_ICMOBillList_CLD : Form { public Sc_ICMOBillList_CLD() { InitializeComponent(); } public DBUtility.frmBillQueryCondition_New frmCondition; public string ViewName = "h_v_Sc_ICMOBillList_CLD"; public string ModCaption = "生产生产订单列表"; public const string ModName = "85"; public const string ModRightName = "Sc_ICMOBill_K3"; public const string ModRightNameEdit = ModRightName + "_Edit"; public const string ModRightNameCheck = ModRightName + "_Check"; public const string ModRightNameClose = ModRightName + "_Close"; public const string ModRightNameDelete = ModRightName + "_Delete"; DAL.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); public Sc_ICMOBill_K3 oFrm; public string sDlgWhere = ""; //外窗体递入 Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum(); // private void initGrid() { DBUtility.Xt_BaseBillFun.initGridList(grdMain,this.Name); } // private void Display() { ClsCN SubCn = new ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; //过滤条件 if (frmCondition.SqlStr.Trim().Length == 0) { sSql = "Select * from " + ViewName + " Where 1=1 " + sWhere + sDlgWhere + " order by 单据号 desc,hsubid "; } else { sSql = frmCondition.SqlStr + sWhere + sDlgWhere + " order by 单据号 desc,hsubid "; } // DSet = SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo); //生成首行标题 if (DSet == null) { MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo); return; } //释放冻结 DBUtility.Xt_BaseBillFun.CancelFrozenCol(grdMain); // grdMain.DataSource = DSet.Tables[0].DefaultView; //设置合计列 string sTotalCol = ""; sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet); string[] sT; sT = sTotalCol.Split(Convert.ToChar(",")); oSumGrid.BuildTotalCols(sT); // //冻结 int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text); string s = frmCondition.cmbHComplete.Text; DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol); //画线 GraphLine(); Total(); // } // private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled=false; initGrid(); Sub_FastQuery(); } 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.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { oFrm = new Sc_ICMOBill_K3(); 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 void Sc_ICMOBillList_CLD_Load(object sender, EventArgs e) { // frmCondition = new frmBillQueryCondition_New(); this.Text = ModCaption; lblCaption.Text = ModCaption; oSumGrid.ogrdMain = grdMain; //初始化 new oSumGrid.oGridsum = grdSum; 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") { Sub_FastQuery(); } } public void SetCondition(DBUtility.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 Sc_ICMOBill_K3(); oFrm.ShowDialog(); } private void sc_Click(object sender, EventArgs e) { Sub_DeleteBill(); } private void yc_Click(object sender, EventArgs e) { BLL.Gy_GridView_Hide oHide = new BLL.Gy_GridView_Hide(); oHide.KeyItem = this.Name; oHide.oGrd = grdMain; oHide.ShowDialog(); // DBUtility.ClsPub.HideGridView(grdMain, Name, DBUtility.ClsPub.AppPath);//设置隐藏列 } //删除 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.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel)==DialogResult.OK) { if (oBill.omodel.HChecker != "") { MessageBox.Show("单据已经审核,不能删除!", "提示"); return; } if (!oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) { MessageBox.Show(DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } else { Display(); } } } else { MessageBox.Show("单据未找到", "提示"); } } private void timer2_Tick(object sender, EventArgs e) { timer2.Enabled = false; if (sDlgWhere == "") { //frmCondition = new frmBillQueryCondition_New(); //SetCondition(frmCondition, ViewName, this.Name); //frmCondition.ShowDialog(); //if (frmCondition.Tag.ToString() == "OK") //{ // timer1.Enabled = true; //} Sub_FastQuery(); } else { 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.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); //查看是否已审核,关闭,作废 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.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); //查看是否已审核,关闭,作废 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; //预览 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(true); } } private void Sub_SetReport(string sOpenTmp) { //判断行数 // Report = new GridppReport(); Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); } private void ReportFetchRecordByDataTable() { BLL.Utility.FillRecordToReport(Report, grdMain, grdPrint, Fun_GetCol("HMaterID")); } #endregion // private void grdMain_Paint(object sender, PaintEventArgs e) { GraphicsGrid(); } //合计 new private void Total() { if (grdMain.Rows.Count > 0 && grdMain.ColumnCount>0) { oSumGrid.SetGridsum(); oSumGrid.Total(); } } //合计 new private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { Total(); } //合计 new private void grdMain_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { Total(); } //引出EXCEL private void dc_Click(object sender, EventArgs e) { //DBUtility.Gy_BaseFun.DataToExcel(this.Text, grdMain); //DBUtility.Gy_BaseFun.Data2Excel(this.Text, grdMain, this.Name); DBUtility.Gy_BaseFun.DataGridViewToExcel2(grdMain); } //下推生成 工序计划单 private void 工序计划单ToolStripMenuItem_Click(object sender, EventArgs e) { Int64 lngBillKey = 0; if (grdMain.CurrentRow == null) return; DAL.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++) { lngBillKey = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("hmainid")].Value); if (lngBillKey == 0) continue; if (!oBill.ProcessPlanBill_Add(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { MessageBox.Show("下推失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); continue; } } MessageBox.Show("下推工序计划单成功!", "提示"); timer1.Enabled = true; return; } private void shc_Click(object sender, EventArgs e) { BLL.ClsPub_BLL.UpBillShow(grdMain, true, this.MdiParent); } private void xc_Click(object sender, EventArgs e) { BLL.ClsPub_BLL.UpBillShow(grdMain, false, this.MdiParent); } Sc_ICMOBillList_K3Dlg oRoutingDlg = new Sc_ICMOBillList_K3Dlg(); private void 指定工艺工序计划单ToolStripMenuItem_Click(object sender, EventArgs e) { Int64 lngBillKey = 0; Int64 HMaterID = 0; Int64 HRoutingID = 0; if (grdMain.CurrentRow == null) return; HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); // oRoutingDlg.sWhere = " and hmaterid=" + HMaterID.ToString(); oRoutingDlg.ShowDialog(); if (oRoutingDlg.IsOk == 1) { DAL.ClsSc_ICMOBill_K3 oBill = new DAL.ClsSc_ICMOBill_K3(); lngBillKey = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); HRoutingID = DBUtility.ClsPub.isLong(oRoutingDlg.txtHRoutingID.Tag); if (lngBillKey == 0) return; if (!oBill.ProcessPlanBill_Add(lngBillKey, HRoutingID, ref DBUtility.ClsPub.sExeReturnInfo)) { MessageBox.Show("下推失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } else { MessageBox.Show("下推工序计划单成功!" + DBUtility.ClsPub.sExeReturnInfo, "提示"); timer1.Enabled = true; } } } private void gyd_Click(object sender, EventArgs e) { } private void 工序流转卡ToolStripMenuItem_Click(object sender, EventArgs e) { ClsCN oCn = new ClsCN(); DataSet Ds; Int64 HICMOID = 0; string HICMONo = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; Int64 HBomID = 0; DateTime HPlanCommitDate = DateTime.Now; DateTime HPlanFinishDate = DateTime.Now; Int64 HDeptID = 0; Int64 HRoutingID = 0; double HQty = 0; if (grdMain.CurrentRow == null) return; HICMOID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); HICMONo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("单据号")].Value); HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); HUnitID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HUnitID")].Value); HBomID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hbomid")].Value); HPlanCommitDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划开工日期")].Value); HPlanFinishDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划完工日期")].Value); HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hdeptid")].Value); HRoutingID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HRoutingID")].Value); HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划生产数量")].Value); //DAL.ClsSc_ProcessExchangeBill oBill = new DAL.ClsSc_ProcessExchangeBill(); //oBill.omodel.HICMOInterID = HICMOID; //oBill.omodel.HICMOBillNo = HICMONo; //oBill.omodel.HMaterID = HMaterID; //oBill.omodel.HUnitID = HUnitID; //oBill.omodel.HPlanQty = HQty; //oBill.omodel.HPlanBeginDate = HPlanCommitDate; //oBill.omodel.HPlanEndDate = HPlanFinishDate; //oBill.omodel.HWorkShopID = HDeptID; //oBill. Sc_ProcessExchangeBill oPEB = new Sc_ProcessExchangeBill(); Ds = oCn.RunProcReturn("select * from h_v_S_Sc_ICMOBillList_CLD where hmainid=" + HICMOID , "h_v_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { //oPEB.Sub_WriteInForm(Ds.Tables[0], 0); oPEB.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oPEB.oXT = Ds; oPEB.ShowDialog(); } } //快速过滤 private void Sub_FastQuery() { string sFastSQL = ""; //判断状态 //if (cmbHStatus.Text != "全部" && cmbHStatus.Text != "") //{ // if (cmbHStatus.Text == "未审核") // { // sFastSQL = sFastSQL + " and 审核人='' "; // } // if (cmbHStatus.Text == "已审核") // { // sFastSQL = sFastSQL + " and 审核人<>'' "; // } // if (cmbHStatus.Text == "未关闭") // { // sFastSQL = sFastSQL + " and 关闭人='' "; // } // if (cmbHStatus.Text == "已关闭") // { // sFastSQL = sFastSQL + " and 关闭人<>'' "; // } //} //判断开始日期 if (dtpHBDate.Checked) { sFastSQL = sFastSQL + " and 日期>='" + dtpHBDate.Value.ToShortDateString() + "'"; } //判断结束日期 if (dtpHEDate.Checked) { sFastSQL = sFastSQL + " and 日期<='" + dtpHEDate.Value.ToShortDateString() + "'"; } //生产订单号 if (txtHBillNo.Text.Trim() != "") { sFastSQL = sFastSQL + " and 单据号 like '%" + txtHBillNo.Text + "%'"; } //生产订单号 if (txtHDeptID.Text.Trim() != "") { sFastSQL = sFastSQL + " and 生产车间名称 like '%" + txtHDeptID.Text + "%'"; } //物料 if (txtHMaterID.Text.Trim() != "") { sFastSQL = sFastSQL + " and (物料代码 like '%" + txtHMaterID.Text.Trim() + "%' or 物料名称 like '%" + txtHMaterID.Text.Trim() + "%' or 规格型号 like '%" + txtHMaterID.Text.Trim() + "%') "; } //订单跟踪号 if (txtHOrderProcNO.Text.Trim() != "") { sFastSQL = sFastSQL + " and 订单跟踪号 like '%" + txtHOrderProcNO.Text + "%'"; } //if (sFastSQL.Trim() == "") //{ // MessageBox.Show("没有输入条件!"); // return; //} sDlgWhere = sFastSQL; Display(); sDlgWhere = ""; } private void btnOK_Click(object sender, EventArgs e) { Sub_FastQuery(); } private void txtHMaterID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Sub_FastQuery(); } } private void txtHBillNo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Sub_FastQuery(); } } private void txtHDeptID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Sub_FastQuery(); } } private void xtpl_Click(object sender, EventArgs e) { //ClsCN oCn = new ClsCN(); //DataSet Ds; //DataSet oDsNo; //DAL.ClsSc_ProcessExchangeBill BillNew = new DAL.ClsSc_ProcessExchangeBill(); //Int64 HICMOID = 0; //string HICMONo = ""; //Int64 HMaterID = 0; //Int64 HUnitID = 0; //Int64 HBomID = 0; //DateTime HPlanCommitDate = DateTime.Now; //DateTime HPlanFinishDate = DateTime.Now; //Int64 HDeptID = 0; //Int64 HRoutingID = 0; //double HQty = 0; //if (grdMain.CurrentRow == null) // return; //if (grdMain.SelectedRows.Count > 1) //{ // MessageBox.Show("只允许选择一张生产订单!"); // return; //} //HICMOID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); //HICMONo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("单据号")].Value); //HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); //HUnitID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HUnitID")].Value); //HPlanCommitDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划开工日期")].Value); //HPlanFinishDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划完工日期")].Value); //HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hdeptid")].Value); //HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划生产数量")].Value); //Sc_ICMOBillList_K3DlgQty oQty = new Sc_ICMOBillList_K3DlgQty(); //oQty.HICMOInterID = HICMOID; //oQty.HICMOBillNo = HICMONo; //oQty.HPlanQty = HQty; //oQty.ShowDialog(); //if (oQty.IsOk == 1) //{ // Ds = oCn.RunProcReturn("select * from h_v_S_Sc_ICMOBillList_CLD where hmainid=" + HICMOID, "h_v_S_Sc_ICMOBillList_CLD"); // if (Ds.Tables[0].Rows.Count > 0) // { // for (int i = 0; i < DBUtility.ClsPub.isInt(oQty.txtHCount.Text); i++) // { // BillNew.omodel.HYear = 0; // BillNew.omodel.HPeriod = 0; // string sNo = ""; // oDsNo = oCn.RunProcReturn("select hicmointerid,sum(1) HNo from Sc_ProcessExchangeBillmain where hicmointerid=" + HICMOID + " group by hicmointerid ", "Sc_ProcessExchangeBillmain"); // if (oDsNo == null || oDsNo.Tables[0].Rows.Count == 0) // { // sNo = "00001"; // } // else // { // sNo = "0000" + DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.isLong(oDsNo.Tables[0].Rows[0]["HNo"]) + 1); // } // sNo = sNo.Substring(sNo.Length - 2, 2); // //initGrid(); // //initGrid_Sub(); // string sBillNo = HICMONo; // sBillNo = sBillNo.Replace("WORKX", ""); // sBillNo = sBillNo.Replace("WORK", ""); // sBillNo = sBillNo.Replace("_", "-"); // sBillNo = sBillNo + "-" + sNo; // //固定赋值================================= // BillNew.omodel.HBillNo = sBillNo; // BillNew.omodel.HDate = DBUtility.ClsPub.isDate(ClsPub.GetServerDate(0)); // BillNew.omodel.HRemark = ""; // //==================================================== // BillNew.omodel.HWWOrderInterID = 0; // BillNew.omodel.HWWOrderEntryID = 0; // BillNew.omodel.HWWOrderBillNo = ""; // BillNew.omodel.HICMOInterID = HICMOID; // BillNew.omodel.HICMOBillNo = HICMONo; // BillNew.omodel.HMaterID = HMaterID; // BillNew.omodel.HMaterNumber = ""; // BillNew.omodel.HBatchNo = ""; // BillNew.omodel.HUnitID = HUnitID; // BillNew.omodel.HUnitNumber = ""; // BillNew.omodel.HPlanQty = HQty; // BillNew.omodel.HQty = DBUtility.ClsPub.isDoule(oQty.txtHQty.Text); // BillNew.omodel.HPlanBeginDate = HPlanCommitDate; // BillNew.omodel.HPlanEndDate =HPlanFinishDate; // BillNew.omodel.HExplanation = ""; // BillNew.omodel.HInnerBillNo = ""; // BillNew.omodel.HWorkShopID = HDeptID; // BillNew.omodel.HSupID = 0; // //明细类赋值 // BillNew.DetailColl = new List(); // for (int r = 0; r <= Ds.Tables[0].Rows.Count - 1; r++) // { // Model.ClsSc_ProcessExchangeBillSub oSub = new Model.ClsSc_ProcessExchangeBillSub(); // //固定赋值======================================== // oSub.HEntryID =r + 1; // oSub.HRemark = ""; // oSub.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hmainid"]); // oSub.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hsubid"]); // oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["HBillType"]); // oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["生产订单号"]); // oSub.HRelationQty = 0; // oSub.HRelationMoney = 0; // oSub.HCloseMan = ""; // oSub.HEntryCloseDate = DBUtility.ClsPub.isDate("1990-01-01"); // oSub.HCloseType = false; // //============================= // oSub.HQty = DBUtility.ClsPub.isDoule(oQty.txtHQty.Text); // oSub.HProcNo = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["工序号"]); // oSub.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hprocid"]); // oSub.HProcNumber = ""; // oSub.HWorkRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["加工说明"]); // oSub.HCenterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HWorkCenterID"]); // oSub.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hdeptid"]); // oSub.HDeptNumber = ""; // oSub.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HGroupID"]); // oSub.HGroupNumber = ""; // oSub.HWorkerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HWorkerID"]); // oSub.HWorkerNumber = ""; // oSub.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HSourceID"]); // oSub.HTimeUnit = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["时间单位"]); // oSub.HPlanWorkTimes = 0; // oSub.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[r]["计划开工日期"]); // oSub.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[r]["计划完工日期"]); // oSub.HRelBeginDate = DBUtility.ClsPub.isDate("1990-01-01"); // oSub.HRelEndDate = DBUtility.ClsPub.isDate("1990-01-01"); // oSub.HReadyTime = 0; // oSub.HQueueTime = 0; // oSub.HMoveTime = 0; // oSub.HBeginDayQty = 0; // oSub.HBeginFixQty = 0; // oSub.HFixWorkDays = 0; // oSub.HTrunWorkDays = 0; // oSub.HReadyTimes = 0; // oSub.HMyWorkDays = 0; // oSub.HOutPrice = 0; // oSub.HOutMoney = 0; // oSub.HLastProc = ""; // oSub.HFstProc = ""; // oSub.HICMOBillNo = HICMONo; // oSub.HICMOInterID = HICMOID; // oSub.HSeOrderInterID = 0; // oSub.HSeOrderEntryID = 0; // oSub.HSeOrderBillNo = ""; // oSub.HWWOrderInterID = 0; // oSub.HWWOrderEntryID = 0; // oSub.HWWOrderBillNo = ""; // BillNew.DetailColl.Add(oSub); // } // //新增 // if (!BillNew.AddBill(ref ClsPub.sExeReturnInfo)) // { // MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示"); // return; // } // } // } // else // { // MessageBox.Show("未查询到生产订单信息!"); // return; // } // MessageBox.Show("批量生成流转卡成功!"); //} } private void xtsingle_Click(object sender, EventArgs e) { ClsCN oCn = new ClsCN(); DataSet Ds; Int64 HICMOID = 0; string HICMONo = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; Int64 HBomID = 0; DateTime HPlanCommitDate = DateTime.Now; DateTime HPlanFinishDate = DateTime.Now; Int64 HDeptID = 0; Int64 HRoutingID = 0; double HQty = 0; if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count > 1) { MessageBox.Show("只允许选择一张生产订单!"); return; } HICMOID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); HICMONo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("单据号")].Value); HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); HUnitID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HUnitID")].Value); HBomID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hbomid")].Value); HPlanCommitDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划开工日期")].Value); HPlanFinishDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划完工日期")].Value); HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hdeptid")].Value); HRoutingID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HRoutingID")].Value); HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划生产数量")].Value); //DAL.ClsSc_ProcessExchangeBill oBill = new DAL.ClsSc_ProcessExchangeBill(); //oBill.omodel.HICMOInterID = HICMOID; //oBill.omodel.HICMOBillNo = HICMONo; //oBill.omodel.HMaterID = HMaterID; //oBill.omodel.HUnitID = HUnitID; //oBill.omodel.HPlanQty = HQty; //oBill.omodel.HPlanBeginDate = HPlanCommitDate; //oBill.omodel.HPlanEndDate = HPlanFinishDate; //oBill.omodel.HWorkShopID = HDeptID; //oBill. Sc_ProcessExchangeBill oPEB = new Sc_ProcessExchangeBill(); Ds = oCn.RunProcReturn("select * from h_v_S_Sc_ICMOBillList_CLD where hmainid=" + HICMOID, "h_v_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { //oPEB.Sub_WriteInForm(Ds.Tables[0], 0); oPEB.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oPEB.oXT = Ds; oPEB.ShowDialog(); } } private void xthb_Click(object sender, EventArgs e) { ClsCN oCn = new ClsCN(); DataSet Ds; Int64 HICMOID1 = 0; Int64 HMaterID1= 0; Int64 HICMOID2 = 0; Int64 HMaterID2 = 0; if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count != 2) { MessageBox.Show("请选择两张生产订单!"); return; } string sICMONo1 = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[0].Cells[Fun_GetCol("单据号")].Value); sICMONo1 = sICMONo1.Substring(0, sICMONo1.IndexOf("_")); string sICMONo2 = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[1].Cells[Fun_GetCol("单据号")].Value); sICMONo2 = sICMONo2.Substring(0, sICMONo2.IndexOf("_")); if (sICMONo1 != sICMONo2) { MessageBox.Show("请选择相同的销售订单生产订单!"); return; } HICMOID1 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[0].Cells[Fun_GetCol("hmainid")].Value); HMaterID1 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[0].Cells[Fun_GetCol("hmaterid")].Value); HICMOID2 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[1].Cells[Fun_GetCol("hmainid")].Value); HMaterID2 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[1].Cells[Fun_GetCol("hmaterid")].Value); // Sc_ProcessExchangeBill oPEB = new Sc_ProcessExchangeBill(); Ds = oCn.RunProcReturn("exec h_p_S_Sc_ICMOBillList_CLD " + HICMOID1 + "," + HMaterID1 + "," + HICMOID2 + "," + HMaterID2, "h_p_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { //oPEB.Sub_WriteInForm(Ds.Tables[0], 0); oPEB.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oPEB.oXT = Ds; oPEB.ShowDialog(); } } private void 单生产订单下推ToolStripMenuItem_Click(object sender, EventArgs e) { ClsCN oCn = new ClsCN(); DataSet Ds; Int64 HICMOID = 0; Int64 HICMOEntryID = 0; string HICMONo = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; Int64 HBomID = 0; DateTime HPlanCommitDate = DateTime.Now; DateTime HPlanFinishDate = DateTime.Now; Int64 HDeptID = 0; Int64 HRoutingID = 0; double HQty = 0; if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count > 1) { MessageBox.Show("只允许选择一张生产订单!"); return; } if (DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("状态")].Value)!= "开工") { MessageBox.Show("只允许下推开工状态的生产订单!"); return; } HICMOID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); HICMOEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HEntryID")].Value); HICMONo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("单据号")].Value); HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); HUnitID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HUnitID")].Value); HBomID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hbomid")].Value); HPlanCommitDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划开工日期")].Value); HPlanFinishDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划完工日期")].Value); HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hdeptid")].Value); HRoutingID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HRoutingID")].Value); HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("可下推数量")].Value); if (HRoutingID<= 0) { MessageBox.Show("本单未设置工艺路线,不允许下推!"); return; } //if (HQty <= 0) //{ // MessageBox.Show("本单已经下推完毕,不允许下推!"); // return; //} //DAL.ClsSc_ProcessExchangeBill oBill = new DAL.ClsSc_ProcessExchangeBill(); //oBill.omodel.HICMOInterID = HICMOID; //oBill.omodel.HICMOBillNo = HICMONo; //oBill.omodel.HMaterID = HMaterID; //oBill.omodel.HUnitID = HUnitID; //oBill.omodel.HPlanQty = HQty; //oBill.omodel.HPlanBeginDate = HPlanCommitDate; //oBill.omodel.HPlanEndDate = HPlanFinishDate; //oBill.omodel.HWorkShopID = HDeptID; //oBill. Sc_ProcessExchangeBill oPEB = new Sc_ProcessExchangeBill(); Ds = oCn.RunProcReturn("select * from h_v_S_Sc_ICMOBillList_CLD where hmainid=" + HICMOID + " and hentryID=" + HICMOEntryID.ToString() , "h_v_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { //oPEB.Sub_WriteInForm(Ds.Tables[0], 0); oPEB.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oPEB.oXT = Ds; oPEB.ShowDialog(); } } private void 批量下推ToolStripMenuItem_Click(object sender, EventArgs e) { ClsCN oCn = new ClsCN(); DataSet Ds; DataSet oDsNo; DAL.ClsSc_ProcessExchangeBill BillNew = new DAL.ClsSc_ProcessExchangeBill(); Int64 HICMOID = 0; string HICMONo = ""; Int64 HMaterID = 0; string HMaterNumber = ""; Int64 HUnitID = 0; string HUnitNumber = ""; Int64 HBomID = 0; DateTime HPlanCommitDate = DateTime.Now; DateTime HPlanFinishDate = DateTime.Now; Int64 HDeptID = 0; Int64 HRoutingID = 0; double HQty = 0; double LZQty = 0; double sumQty = 0; string FNumber = ""; if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count > 1) { MessageBox.Show("只允许选择一张生产订单!"); return; } HICMOID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); HICMONo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("单据号")].Value); HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); HMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("物料代码")].Value); HUnitID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HUnitID")].Value); HUnitNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计量单位代码")].Value); HPlanCommitDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划开工日期")].Value); HPlanFinishDate = DBUtility.ClsPub.isDate(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("计划完工日期")].Value); HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hdeptid")].Value); HRoutingID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HRoutingID")].Value); HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("可下推数量")].Value); FNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("FNumber")].Value); if (FNumber == "LX2") { Sc_ProcessExchangeBillback oPEBB = new Sc_ProcessExchangeBillback(); Ds = oCn.RunProcReturn("select * from h_v_S_Sc_ICMOBillList_CLD where hmainid=" + HICMOID, "h_v_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { //oPEB.Sub_WriteInForm(Ds.Tables[0], 0); oPEBB.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oPEBB.oXT = Ds; oPEBB.ShowDialog(); } return; } if (HRoutingID <= 0) { MessageBox.Show("本单未设置工艺路线,不允许下推!"); return; } if (HQty <= 0) { MessageBox.Show("本单已经下推完毕,不允许下推!"); return; } sumQty = HQty; Sc_ICMOBillList_K3DlgQty oQty = new Sc_ICMOBillList_K3DlgQty(); oQty.HICMOInterID = HICMOID; oQty.HICMOBillNo = HICMONo; oQty.HPlanQty = HQty; oQty.ShowDialog(); if (oQty.IsOk == 1) { Ds = oCn.RunProcReturn("select * from h_v_S_Sc_ICMOBillList_CLD where hmainid=" + HICMOID, "h_v_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < DBUtility.ClsPub.isInt(oQty.txtHCount.Text); i++) { if (sumQty - DBUtility.ClsPub.isDoule(oQty.txtHQty.Text) < 0) { LZQty = sumQty; } else { sumQty = sumQty - DBUtility.ClsPub.isDoule(oQty.txtHQty.Text); LZQty = DBUtility.ClsPub.isDoule(oQty.txtHQty.Text); } BillNew.omodel.HYear = 0; BillNew.omodel.HPeriod = 0; string sNo = ""; //获取当前改生产订单 最大流转卡号,并累计增加1。 string sOldNo = ""; oDsNo = oCn.RunProcReturn("select top 1 HBillNo from Sc_ProcessExchangeBillmain where hicmointerid=" + HICMOID + " order by LEN(HBillno) desc, HbillNo desc ", "Sc_ProcessExchangeBillmain"); if (oDsNo == null || oDsNo.Tables[0].Rows.Count == 0) { sNo = "00001"; } else { sOldNo = DBUtility.ClsPub.isStrNull(oDsNo.Tables[0].Rows[0]["HBillNo"]); sOldNo = sOldNo.Substring(sOldNo.Length - 3, 3); if (sOldNo.Substring(0, 1) == "0" || sOldNo.Substring(0, 1) == "-" ) { sOldNo = sOldNo.Substring(sOldNo.Length - 2, 2); if (sOldNo.Substring(0, 1) == "0") { sOldNo = sOldNo.Substring(sOldNo.Length - 1, 1); } } sNo = "0000" + DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.isLong(sOldNo) + 1); } //oDsNo = oCn.RunProcReturn("select hicmointerid,sum(1) HNo from Sc_ProcessExchangeBillmain where hicmointerid=" + HICMOID + " group by hicmointerid ", "Sc_ProcessExchangeBillmain"); //if (oDsNo == null || oDsNo.Tables[0].Rows.Count == 0) //{ // sNo = "00001"; //} //else //{ // sNo = "0000" + DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.isLong(oDsNo.Tables[0].Rows[0]["HNo"]) + 1); //} sNo = sNo.Substring(sNo.Length - 3, 3); //initGrid(); //initGrid_Sub(); string sBillNo = HICMONo; sBillNo = sBillNo.Replace("WORKX", ""); sBillNo = sBillNo.Replace("WORK", ""); sBillNo = sBillNo.Replace("_", "-"); sBillNo = sBillNo + "-" + sNo; //固定赋值================================= BillNew.omodel.HBillNo = sBillNo; BillNew.omodel.HDate = DBUtility.ClsPub.isDate(ClsPub.GetServerDate(0)); BillNew.omodel.HRemark = ""; //==================================================== BillNew.omodel.HWWOrderInterID = 0; BillNew.omodel.HWWOrderEntryID = 0; BillNew.omodel.HWWOrderBillNo = ""; BillNew.omodel.HICMOInterID = HICMOID; BillNew.omodel.HICMOBillNo = HICMONo; BillNew.omodel.HMaterID = HMaterID; BillNew.omodel.HMaterID2 = HMaterID; BillNew.omodel.HMaterNumber = HMaterNumber; BillNew.omodel.HBatchNo = ""; BillNew.omodel.HUnitID = HUnitID; BillNew.omodel.HUnitNumber = HUnitNumber; BillNew.omodel.HPlanQty = HQty; BillNew.omodel.HQty = LZQty; BillNew.omodel.HPlanBeginDate = HPlanCommitDate; BillNew.omodel.HPlanEndDate = HPlanFinishDate; BillNew.omodel.HExplanation = ""; BillNew.omodel.HInnerBillNo = ""; BillNew.omodel.HWorkShopID = HDeptID; BillNew.omodel.HSupID = 0; BillNew.omodel.HWorkTypeNum = FNumber; BillNew.omodel.HMainMaterID = HMaterID; BillNew.omodel.HKeyMaterID = HMaterID; //明细类赋值 BillNew.DetailColl = new List(); for (int r = 0; r <= Ds.Tables[0].Rows.Count - 1; r++) { Model.ClsSc_ProcessExchangeBillSub oSub = new Model.ClsSc_ProcessExchangeBillSub(); //固定赋值======================================== oSub.HEntryID = r + 1; oSub.HRemark = ""; oSub.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hmainid"]); oSub.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hsubid"]); oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["HBillType"]); oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["生产订单号"]); oSub.HRelationQty = 0; oSub.HRelationMoney = 0; oSub.HCloseMan = ""; oSub.HEntryCloseDate = DBUtility.ClsPub.isDate("1990-01-01"); oSub.HCloseType = false; //============================= oSub.HQty = LZQty; oSub.HProcNo = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["工序号"]); oSub.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hprocid"]); oSub.HProcNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["工序代码"]); ; oSub.HWorkRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["加工说明"]); oSub.HCenterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HWorkCenterID"]); oSub.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["hdeptid"]); oSub.HDeptNumber = ""; oSub.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HGroupID"]); oSub.HGroupNumber = ""; oSub.HWorkerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HWorkerID"]); oSub.HWorkerNumber = ""; oSub.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HSourceID"]); oSub.HTimeUnit = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["时间单位"]); oSub.HPlanWorkTimes = 0; oSub.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[r]["计划开工日期"]); oSub.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[r]["计划完工日期"]); oSub.HRelBeginDate = DBUtility.ClsPub.isDate("1990-01-01"); oSub.HRelEndDate = DBUtility.ClsPub.isDate("1990-01-01"); oSub.HReadyTime = 0; oSub.HQueueTime = 0; oSub.HMoveTime = 0; oSub.HBeginDayQty = 0; oSub.HBeginFixQty = 0; oSub.HFixWorkDays = 0; oSub.HTrunWorkDays = 0; oSub.HReadyTimes = 0; oSub.HMyWorkDays = 0; oSub.HOutPrice = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[r]["加工单价"]); oSub.HOutMoney = 0; oSub.HLastProc = "否"; oSub.HFstProc = "否"; oSub.HKeyProc = "否"; oSub.HICMOBillNo = HICMONo; oSub.HICMOInterID = HICMOID; oSub.HSeOrderInterID = 0; oSub.HSeOrderEntryID = 0; oSub.HSeOrderBillNo = ""; oSub.HWWOrderInterID = 0; oSub.HWWOrderEntryID = 0; oSub.HWWOrderBillNo = ""; BillNew.DetailColl.Add(oSub); } //新增 if (!BillNew.AddBill(ref ClsPub.sExeReturnInfo)) { MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示"); return; } } } else { MessageBox.Show("未查询到生产订单信息!"); return; } MessageBox.Show("批量生成流转卡成功!"); } } private void 合并下推ToolStripMenuItem_Click(object sender, EventArgs e) { ClsCN oCn = new ClsCN(); DataSet Ds; Int64 HICMOID1 = 0; Int64 HMaterID1 = 0; Int64 HICMOID2 = 0; Int64 HMaterID2 = 0; string FNumber = ""; FNumber = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[0].Cells[Fun_GetCol("FNumber")].Value); if (FNumber == "LX2") { MessageBox.Show("本单为返工单,不允许合并下推"); return; } if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count != 2) { MessageBox.Show("请选择两张生产订单!"); return; } string sICMONo1 = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[0].Cells[Fun_GetCol("单据号")].Value); sICMONo1=sICMONo1+ "_"; //防止手工单,出现异常 sICMONo1 = sICMONo1.Substring(0, sICMONo1.IndexOf("_")); string sICMONo2 = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[1].Cells[Fun_GetCol("单据号")].Value); sICMONo2 = sICMONo2 + "_"; //防止手工单,出现异常 sICMONo2 = sICMONo2.Substring(0, sICMONo2.IndexOf("_")); if (sICMONo1 != sICMONo2) { MessageBox.Show("请选择相同的销售订单生产订单!"); return; } HICMOID1 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[0].Cells[Fun_GetCol("hmainid")].Value); HMaterID1 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[0].Cells[Fun_GetCol("hmaterid")].Value); HICMOID2 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[1].Cells[Fun_GetCol("hmainid")].Value); HMaterID2 = DBUtility.ClsPub.isLong(grdMain.SelectedRows[1].Cells[Fun_GetCol("hmaterid")].Value); // Sc_ProcessExchangeBill oPEB = new Sc_ProcessExchangeBill(); Ds = oCn.RunProcReturn("exec h_p_S_Sc_ICMOBillList_CLD " + HICMOID1 + "," + HMaterID1 + "," + HICMOID2 + "," + HMaterID2, "h_p_S_Sc_ICMOBillList_CLD"); if (Ds.Tables[0].Rows.Count > 0) { //oPEB.Sub_WriteInForm(Ds.Tables[0], 0); oPEB.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oPEB.oXT = Ds; oPEB.ShowDialog(); } } private void 选择下推ToolStripMenuItem_Click(object sender, EventArgs e) { Int64 HDeptID = 0; Int64 HICMOID = 0; string HICMONo = ""; string FNumber = ""; Int64 HMaterID = 0; Int64 HRoutingID = 0; double HQty = 0; if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count > 1) { MessageBox.Show("只允许选择一张生产订单!"); return; } HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hdeptid")].Value); HICMOID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmainid")].Value); HICMONo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("单据号")].Value); HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); HRoutingID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HRoutingID")].Value); HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("可下推数量")].Value); FNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("FNumber")].Value); if (FNumber == "LX2") { MessageBox.Show("本单为返工单,不允许根据BOM下推"); return; } if (HRoutingID <= 0) { MessageBox.Show("本单未设置工艺路线,不允许下推!"); return; } if (HQty <= 0) { MessageBox.Show("本单已经下推完毕,不允许下推!"); return; } Sc_ICMOBillList_CLDDlgBOM oBom = new Sc_ICMOBillList_CLDDlgBOM(); oBom.HICMOInterID = HICMOID; oBom.HICMOBillNo = HICMONo; oBom.HDeptID = HDeptID; oBom.HMaterID = HMaterID; oBom.HPlanQty = HQty; oBom.ShowDialog(); //Display(); Sub_FastQuery(); } private void 订单跟踪号下推ToolStripMenuItem_Click(object sender, EventArgs e) { string FNumber = ""; Int64 HMaterID = 0; if (grdMain.CurrentRow == null) return; if (grdMain.SelectedRows.Count > 1) { MessageBox.Show("只允许选择一张生产订单!"); return; } HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("hmaterid")].Value); FNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("订单跟踪号")].Value); Sc_ICMOBillList_CLDDlgOrder oSc_ICMOBillList_CLDDlgOrder = new Sc_ICMOBillList_CLDDlgOrder(); oSc_ICMOBillList_CLDDlgOrder.HMaterID = HMaterID; oSc_ICMOBillList_CLDDlgOrder.HOrderProcNo = FNumber; oSc_ICMOBillList_CLDDlgOrder.ShowDialog(); //Display(); Sub_FastQuery(); } } }