using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace PayM { public partial class Pay_SumBalBill_JS : Form { public Pay_SumBalBill_JS() { InitializeComponent(); } public DAL.ClsPay_SumBalBill BillNew = new DAL.ClsPay_SumBalBill(); //¶ÔÓ¦µ¥¾ÝÀà private void Pay_SumBalBill_JS_Load(object sender, EventArgs e) { cmbHYear.Items.Clear(); //»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä int CurYear = 0; int CurPeriod = 0; if (DBUtility.ClsPub.Sub_GetCurPeriod(ref CurYear, ref CurPeriod) == false) { MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!"); return; } cmbHYear.Items.Add(CurYear); cmbHYear.Items.Add(CurYear - 1); cmbHYear.Items.Add(CurYear - 2); cmbHYear.Items.Add(CurYear - 3); cmbHYear.Items.Add(""); cmbHYear.SelectedIndex = 0; cmbHPeriod.Text = CurPeriod.ToString(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { bool bResult; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; //-------------ÅжÏÊÇ·ñÒѾ­½áÕË // string a = ""; int sYear = 0; int sPeriod = 0; if (!DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DBUtility.ClsPub.isDate(cmbHYear.Text + "-" + cmbHPeriod.Text+"-01"), ref sYear, ref sPeriod, ref a)) { MessageBox.Show(a + "£¬²»ÔÊÐí¼ÆË㣡", "Ìáʾ"); return; } // //-----------ÅжÏËùÓе¥¾ÝÊÇ·ñÒѾ­ÉóºË Ds = oCn.RunProcReturn("exec h_p_Pay_SumBalBill_JSCheck " + cmbHYear.Text + "," + cmbHPeriod.Text, "h_p_Pay_SumBalBill_JSCheck", ref DBUtility.ClsPub.sErrInfo); if (Ds == null) { MessageBox.Show("ÅжÏËùÓе¥¾ÝÊÇ·ñÒѾ­ÉóºË³ö´í£º" + DBUtility.ClsPub.sErrInfo); return; } if (Ds.Tables[0].Rows.Count != 0) { string s = ""; for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { s = s + Ds.Tables[0].Rows[i][0].ToString()+"\r\n"; } s = s + "´æÔÚ´íÎóÐÅÏ¢£¬²»ÔÊÐí¼ÆË㣡"; MessageBox.Show(s); return; } //---------Åжϱ¾ÆÚ¼äÊÇ·ñÒѾ­¼ÆËã Ds = oCn.RunProcReturn("select * from Pay_SumBalBillMain where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text, "Pay_SumBalBillMain", ref DBUtility.ClsPub.sErrInfo); if (Ds == null) { MessageBox.Show("ÅжÏÊÇ·ñÒÑÉú³É³ö´í£º" + DBUtility.ClsPub.sErrInfo); return; } if (Ds.Tables[0].Rows.Count != 0) { if (MessageBox.Show("±¾»á¼ÆÆÚ¼äÒÑÉú³É£¬ÊÇ·ñ¸²¸Ç£¿", "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { oCn.RunProc("delete Pay_SumBalBillMain where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text); } else { return; } } //---------------------¼ÆËã Ds = oCn.RunProcReturn("exec h_p_Pay_SumBalBill_JS " + cmbHYear.Text + "," + cmbHPeriod.Text, "h_p_Pay_SumBalBill_JS", ref DBUtility.ClsPub.sErrInfo); if (Ds == null) { MessageBox.Show("¼ÆËã³ö´í£º" + DBUtility.ClsPub.sErrInfo); return; } if (Ds.Tables[0].Rows.Count == 0) { return; } //------------------------------------------- long HGroupID = -1; for (int i = 0; i <= Ds.Tables[0].Rows.Count - 1; i++) { if (HGroupID != DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"])) { if (HGroupID != -1) { BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } BillNew.omodel.HYear = DBUtility.ClsPub.isLong(cmbHYear.Text); BillNew.omodel.HPeriod = DBUtility.ClsPub.isLong(cmbHPeriod.Text); //¹Ì¶¨¸³Öµ================================= BillNew.omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//µÃµ½Ðµ¥ºÅ BillNew.omodel.HDate = DBUtility.ClsPub.isDate(cmbHYear.Text + "-" + cmbHPeriod.Text+"-01"); BillNew.omodel.HRemark = ""; //==================================================== BillNew.omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]); BillNew.omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HDeptID"]); BillNew.omodel.HEmpID = 0; BillNew.omodel.HPayType = 0; BillNew.omodel.HExplanation = ""; BillNew.omodel.HInnerBillNo = ""; BillNew.omodel.HSaveFlag = true; //Ã÷ϸÀำֵ BillNew.DetailColl = new List(); HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]); } Model.ClsPay_SumBalBillSub oSub = new Model.ClsPay_SumBalBillSub(); //¹Ì¶¨¸³Öµ======================================== oSub.HEntryID = i + 1; oSub.HRemark =""; oSub.HSourceInterID = 0; oSub.HSourceEntryID = 0; oSub.HSourceBillType = ""; oSub.HSourceBillNo = ""; oSub.HRelationQty = 0; oSub.HRelationMoney = 0; oSub.HCloseMan = ""; oSub.HEntryCloseDate = DBUtility.ClsPub.isDate("1900-01-01"); oSub.HCloseType = false; //============================= oSub.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]); oSub.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]); oSub.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEmpID"]); oSub.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HQty"]); oSub.HTimes = 0; oSub.HPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPrice"]); oSub.HMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HMoney"]); oSub.HReportQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReportQty"]); oSub.HSumReportQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSumReportQty"]); oSub.HSumStockQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSumStockQty"]); oSub.HEmpRate = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["HEmpRate"]); oSub.HICMOInterID = 0; oSub.HProcReportInterID = 0; oSub.HProcReportEntryID = 0; oSub.HProcPlanEntryID = 0; oSub.HProcPlanInterID = 0; oSub.HICMOBillNo = ""; oSub.HProcReportBillNo = ""; oSub.HProcPlanBillNo = ""; BillNew.DetailColl.Add(oSub); if (i == Ds.Tables[0].Rows.Count-1) { BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } } //bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); //if (bResult == false) //{ // MessageBox.Show("±£´æÊ§°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); // return; //} MessageBox.Show("¼ÆËãÍê±Ï£¡"); this.Close(); } } }