using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Pub_Class; using SQLHelper; namespace WorkM { public partial class Sc_ICMOBillList_CLDDlgOrder : Form { public Sc_ICMOBillList_CLDDlgOrder() { InitializeComponent(); } public long HICMOInterID = 0; public string HICMOBillNo = ""; public long HMaterID = 0; public long HDeptID = 0; public double HPlanQty = 0; public string HOrderBillNo = ""; public string HOrderProcNo = ""; // public int HQtyCol = 0; public int HCountCol = 0; public int IsOk; private void cmdCancel_Click(object sender, EventArgs e) { IsOk = 2; this.Visible = false; } private bool AllowOK() { for (int i = 0; i <= grdMain.Rows.Count - 1; i++) { if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("Ñ¡Ôñ")].Value) == "¡Ì") { if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("¹¤ÒÕ·Ïß")].Value) == "") { MessageBox.Show("Ñ¡ÔñµÄµÚ"+ Convert.ToString(i+1) +"ÐУ¬Ã»ÓÐÉèÖù¤ÒÕ·Ïߣ¬²»ÔÊÐíÏÂÍÆ£¡"); return false; } if (DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("Á÷ת¿¨ÊýÁ¿")].Value) <= 0) { MessageBox.Show("Ñ¡ÔñµÄµÚ" + Convert.ToString(i + 1) + "ÐУ¬Ã»ÓпÉÏÂÍÆÊýÁ¿£¬²»ÔÊÐíÏÂÍÆ£¡"); return false; } if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("״̬")].Value) != "¿ª¹¤") { MessageBox.Show("Ñ¡ÔñµÄµÚ" + Convert.ToString(i + 1) + "ÐУ¬²»ÊÇ¡¾¿ª¹¤¡¿×´Ì¬£¬²»ÔÊÐíÏÂÍÆ£¡"); return false; } } } return true; } private void cmdOK_Click(object sender, EventArgs e) { label4.Focus(); int sCount = 0; if (!AllowOK()) { return; } // int t = 0; for (int i = 0; i <= grdMain.Rows.Count - 1; i++) { if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("Ñ¡Ôñ")].Value) == "¡Ì") { // sCount = DBUtility.ClsPub.isInt(grdMain.Rows[i].Cells[Fun_GetCol("Éú³ÉÕÅÊý")].Value); // for (int c = 0; c <= sCount - 1; c++) // { WriteClass(i); //} t++; } } if (t == 0) { MessageBox.Show("ÇëÑ¡ÔñÐèÒªÏÂÍÆµÄÁ÷ת¿¨"); return; } else { MessageBox.Show("Éú³ÉÁ÷ת¿¨Íê±Ï£¡"); } // IsOk = 1; this.Visible = false; } private void WriteClass(int irow) { ClsCN oCn = new ClsCN(); DataSet Ds; DataSet oDsNo; DAL.ClsSc_ProcessExchangeBill BillNew = new DAL.ClsSc_ProcessExchangeBill(); Int64 HKeyMaterID = 0; Int64 HMainMaterID = 0; Int64 HMaterID = 0; Int64 HUnitID = 0; Int64 HBomID = 0; DateTime HPlanCommitDate = DateTime.Now; DateTime HPlanFinishDate = DateTime.Now; Int64 HRoutingID = 0; double HQty = 0; Int64 HICMOEntryID = 0; HMainMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[irow].Cells[Fun_GetCol("hmaterid")].Value); HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[irow].Cells[Fun_GetCol("hmaterid")].Value); HUnitID = DBUtility.ClsPub.isLong(grdMain.Rows[irow].Cells[Fun_GetCol("HUnitID")].Value); HICMOBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[irow].Cells[Fun_GetCol("Éú²ú¶©µ¥ºÅ")].Value); HICMOEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[irow].Cells[Fun_GetCol("HSubID")].Value); HICMOInterID = DBUtility.ClsPub.isLong(grdMain.Rows[irow].Cells[Fun_GetCol("HMainID")].Value); HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[irow].Cells[Fun_GetCol("Á÷ת¿¨ÊýÁ¿")].Value); HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[irow].Cells[Fun_GetCol("HDeptID")].Value); //HNum Á¬½ÓµÄÊÇ ¹¤ÒÕ×éµÄ´úÂë Ds = oCn.RunProcReturn("select * from h_v_Gy_RoutingBillList where HMaterID=" + HMaterID , "h_v_Gy_RoutingBillList"); if (Ds.Tables[0].Rows.Count > 0) { 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=" + HICMOInterID + " 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); } sNo = sNo.Substring(sNo.Length - 3, 3); string sBillNo = HICMOBillNo; 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.HOrderProcNO = HOrderProcNo; BillNew.omodel.HICMOInterID = HICMOInterID; BillNew.omodel.HICMOEntryID = HICMOEntryID; BillNew.omodel.HICMOBillNo = HICMOBillNo; BillNew.omodel.HWWOrderBillNo = HICMOBillNo; //} BillNew.omodel.HMaterID = HMaterID; BillNew.omodel.HMaterID2 = HMaterID; BillNew.omodel.HMaterNumber = ""; BillNew.omodel.HBatchNo = ""; BillNew.omodel.HUnitID = HUnitID; BillNew.omodel.HUnitNumber = ""; BillNew.omodel.HPlanQty = HQty; BillNew.omodel.HQty = HQty; 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 = "lX1"; //Á÷ת¿¨ÀàÐÍ BillNew.omodel.HRoutingInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainID"]); BillNew.omodel.HMainMaterID = HMainMaterID; BillNew.omodel.HKeyMaterID = HKeyMaterID; //¹Ø¼üÎïÁÏ ¸ù¾Ýϼ¶BOM »ñÈ¡¹Ø¼ü¼þ //Ã÷ϸÀำֵ 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.HRelationQty = 0; oSub.HRelationMoney = 0; oSub.HCloseMan = ""; oSub.HEntryCloseDate = DBUtility.ClsPub.isDate("1990-01-01"); oSub.HCloseType = false; // oSub.HSourceInterID = HICMOInterID; oSub.HSourceEntryID = HICMOEntryID; oSub.HSourceBillType = "85"; oSub.HSourceBillNo = HICMOBillNo; oSub.HICMOBillNo = HICMOBillNo; oSub.HICMOInterID = HICMOInterID; oSub.HICMOEntryID = HICMOEntryID; //============================= oSub.HQty = HQty; 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]["HCenterID"]); oSub.HDeptID = 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.HSupFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[r]["ίÍâ±ê¼Ç"]); oSub.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[r]["HSupID"]); 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 = HPlanCommitDate; oSub.HPlanEndDate = HPlanFinishDate; 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 = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[r]["ϵÀÁ÷ת¹¤Ðò"]); ; //ϸö×ÔÖÆ¼þÊ×¹¤Ðò 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; } } } private void Sc_ICMOBillList_CLDDlgOrder_Activated(object sender, EventArgs e) { IsOk = 0; } private void timer1_Tick(object sender, EventArgs e) { } private void initGrid() { DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name); grdMain.ReadOnly = false; } /// /// °´¶©µ¥¸ú×ٺŷֽâ /// private void Display() { ClsCN SubCn = new ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; //¹ýÂËÌõ¼þ ¸ù¾Ý¶©µ¥¸ú×ٺŠ·µ»ØÈ«²¿Éú²ú¶©µ¥¡£ sSql = "exec h_p_Sc_GetAllICMOByOrderProcNoQueryToLZK_CLD '" + HOrderProcNo.ToString() + "'"; // DSet = SubCn.RunProcReturn(sSql, "Gy_czygl", ref DBUtility.ClsPub.sExeReturnInfo); //Éú³ÉÊ×ÐбêÌâ if (DSet == null) { MessageBox.Show("ûÓвéѯµ½BOMÐÅÏ¢£¡" + 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 = 4; string s = "ÊÇ"; DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol); //for (int i = 0; i < grdMain.ColumnCount; i++) //{ // grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; //ÁÐ ÅÅÐòģʽ //} // HQtyCol = Fun_GetCol("Á÷ת¿¨ÊýÁ¿"); HCountCol = Fun_GetCol("Éú³ÉÕÅÊý"); } private Int32 Fun_GetCol(string sCol) { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); } private void GraphicsGrid() { DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain); } private void Sc_ICMOBillList_CLDDlgOrder_Load(object sender, EventArgs e) { DAL.ClsCLD_Material_View oMater = new DAL.ClsCLD_Material_View(); if (oMater.GetInfoByID(HMaterID)) { txtHMater.Tag = HMaterID; txtHMater.Text = oMater.omodel.HName; txtHModel.Text = oMater.omodel.HModel; } else { txtHMater.Tag = 0; txtHMater.Text = ""; txtHModel.Text = ""; } txtHOrderProcNo.Text = HOrderProcNo; initGrid(); Display(); } private void grdMain_Paint(object sender, PaintEventArgs e) { GraphicsGrid(); } private void grdMain_DoubleClick(object sender, EventArgs e) { if (DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Ñ¡Ôñ")].Value) == "") { grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Ñ¡Ôñ")].Value = "¡Ì"; } else { grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Ñ¡Ôñ")].Value = ""; } } private void txtHPlanQty_TextChanged(object sender, EventArgs e) { //if (DBUtility.ClsPub.isDoule(txtHPlanQty.Text) <= 0) //{ // return; //} //double HConsultAuxQty = 0; //double HQty = DBUtility.ClsPub.isDoule(txtHPlanQty.Text); //for (int i = 0; i <= grdMain.RowCount - 1; i++) //{ // HConsultAuxQty = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("HConsultAuxQty")].Value); // grdMain.Rows[i].Cells[Fun_GetCol("²ÎÕÕÊýÁ¿")].Value = DBUtility.ClsPub.isDoule(HQty * HConsultAuxQty, 0); // grdMain.Rows[i].Cells[Fun_GetCol("Á÷ת¿¨ÊýÁ¿")].Value = DBUtility.ClsPub.isDoule(HQty * HConsultAuxQty, 0); //} } private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { int i = grdMain.CurrentCell.ColumnIndex; if (i != HQtyCol && i != HCountCol) { e.Cancel = true; } } private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } private void cmdcheck_Click(object sender, EventArgs e) { label4.Focus(); int sCount = 0; int t = 0; for (int i = 0; i <= grdMain.Rows.Count - 1; i++) { if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("״̬")].Value) != "¿ª¹¤" || DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("¹¤ÒÕ·Ïß")].Value) == "" || DBUtility.ClsPub.isSingle(grdMain.Rows[i].Cells[Fun_GetCol("Á÷ת¿¨ÊýÁ¿")].Value) <=0) { grdMain.Rows[i].Cells[Fun_GetCol("Ñ¡Ôñ")].Value = ""; } } } } }