using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace CostM { public partial class Pay_AccPayMentDayBill4 : Form { public int HCode; public string HPathBakServer; public string HHardDisk; public int HDelDays; public string HBMaterNumber; public string HEMaterNumber; public int HMaterType; //ÎïÁ϶Πpublic int HSetType; //ºËË㷽ʽ public int HYear; //»á¼ÆÄê public int HPeriod; //»á¼ÆÔ public DateTime HBDate; //¿ªÊ¼ÈÕÆÚ public DateTime HEDate; //½áÊøÈÕÆÚ public DateTime HDate; //µ±Ç°ºËËãÈÕÆÚ public long HGroupID; //µ±Ç°ºËËã°à×é public long HEmpID; //µ±Ç°ºËËãÈËÔ± public double HMoney; //µ±Ç°ºËËãÈËÔ±¹¤×Ê public DAL.ClsPay_PayMentDayBill BillNew = new DAL.ClsPay_PayMentDayBill(); //¶ÔÓ¦µ¥¾ÝÀà public Pay_AccPayMentDayBill4() { InitializeComponent(); } private void Pay_AccPayMentDayBill4_Load(object sender, EventArgs e) { timer1.Enabled = true; } private void button1_Click(object sender, EventArgs e) { HCode=1; this.Hide(); } private void button2_Click(object sender, EventArgs e) { HCode = 2; this.Hide(); } private void button3_Click(object sender, EventArgs e) { HCode = 3; this.Hide(); } private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; SetMateStdPrice(); } //ÅжϺËËãÐÅÏ¢ private bool AllowBegin() { return true; } //ºËËã private void SetMateStdPrice() { if (!AllowBegin()) { MessageBox.Show("ÄúÉèÖúËËãÐÅÏ¢ÓдíÎ󣬲»ÄܽøÐкËË㣡ÇëÓë¹ÜÀíÔ±ÁªÏµ"); return; } //ºËËãÀàÐÍ switch (HSetType) { case 0://¼ÓȨ SetMateStdPrice_JQ(); break; case 1://ÒÆ¶¯¼ÓȨ break; case 2://×îРSetMateStdPrice_ZuiXin(); break; case 3://×îµÍ break; case 4://×î¸ß break; default: break; } } //¼ÓȨƽ¾ù private void SetMateStdPrice_JQ() { //µÃµ½ºËËãµÄ ÎïÁ϶ΠSQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet oDs; oDs = oCn.RunProcReturn("exec h_p_CB_getMaterialAToB '" + DBUtility.ClsPub.CBCurBDate.ToShortDateString() + "','" + DBUtility.ClsPub.CBCurEDate.ToShortDateString() + "','" + this.HBMaterNumber.Trim() + "','" + this.HEMaterNumber.Trim() + "'," + this.HMaterType.ToString(), "gy_czygl"); if (oDs == null || oDs.Tables[0].Rows.Count == 0) { MessageBox.Show("´íÎóµÄÎïÁ϶Σ¡"); return; } pb1.Maximum = oDs.Tables[0].Rows.Count; pb1.Value = 0; for (int i = 0; i < oDs.Tables[0].Rows.Count; i++) { System.Windows.Forms.Application.DoEvents(); //ºËËã±¾ÎïÁÏ oCn.RunProc("exec h_p_K3_AccMateOutPrice " + DBUtility.ClsPub.CBCurYear.ToString() + "," + DBUtility.ClsPub.CBCurPeriod.ToString() + ",'" + DBUtility.ClsPub.CBCurBDate.ToShortDateString() + "','" + DBUtility.ClsPub.CBCurEDate.ToShortDateString() + "'," + DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[i]["HMaterID"])); System.Windows.Forms.Application.DoEvents(); pb1.Value = i + 1; lblHCount.Text = pb1.Value.ToString() + "/" + pb1.Maximum.ToString(); System.Windows.Forms.Application.DoEvents(); } } //×îе¥¼Û private void SetMateStdPrice_ZuiXin() { HBDate = DBUtility.ClsPub.isDate(HYear + "-" + HPeriod + "-01"); HEDate = HBDate.AddMonths(1); //µÃµ½ºËËãµÄ ¹¤×÷×é SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet oDs; DataSet oDsDate; DataSet oDsOld; DataSet oDsJT; DataSet oDsDR; oDs = oCn.RunProcReturn("select * from Gy_ClassTimePrjGroup where hstopflag=0", "Gy_ClassTimePrjGroup"); if (oDs == null || oDs.Tables[0].Rows.Count == 0) { MessageBox.Show("´íÎóµÄ¹¤×÷×飡"); return; } oDsDate = oCn.RunProcReturn("select dateadd(dd,number,'" + HBDate + "') AS hdate from master..spt_values where type='p' and dateadd(dd,number,'" + HBDate + "')<'"+ HEDate+"'","gy_czygl"); pb1.Maximum = oDsDate.Tables[0].Rows.Count; pb1.Value = 0; for (int j = 0; j < oDsDate.Tables[0].Rows.Count; j++) { HDate = DBUtility.ClsPub.isDate(oDsDate.Tables[0].Rows[j][0]); System.Windows.Forms.Application.DoEvents(); for (int i = 0; i < oDs.Tables[0].Rows.Count; i++) { System.Windows.Forms.Application.DoEvents(); //ºËËã¸Ã¹¤×÷×éÿÈÕ¹¤×Ê oDsJT=oCn.RunProcReturn("exec h_p_Pay_AccPayMentDayBillJT '" + HDate + "'," + DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[i]["HItemID"]),"Pay_PayMentDayBillMain"); if (oDsJT.Tables[0].Rows.Count > 0) { for (int k = 0; k < oDsJT.Tables[0].Rows.Count; k++) { System.Windows.Forms.Application.DoEvents(); HEmpID = DBUtility.ClsPub.isLong(oDsJT.Tables[0].Rows[k]["HEmpID"]); HGroupID = DBUtility.ClsPub.isLong(oDsJT.Tables[0].Rows[k]["HGroupID"]); HMoney = DBUtility.ClsPub.isDoule(oDsJT.Tables[0].Rows[k]["HMoney"]); oDsOld = oCn.RunProcReturn("select a.HInterID from Pay_PayMentDayBillMain a inner join Pay_PayMentDayBillSub b on a.hinterid=b.hinterid where HDate='" + HDate + "' and b.HEmpID=" + HEmpID, "Pay_PayMentDayBillMain"); if (oDsOld.Tables[0].Rows.Count > 0) { oCn.RunProc("delete Pay_PayMentDayBillMain where HInterID=" + DBUtility.ClsPub.isLong(oDsOld.Tables[0].Rows[0][0])); oCn.RunProc("delete Pay_PayMentDayBillSub where HInterID=" + DBUtility.ClsPub.isLong(oDsOld.Tables[0].Rows[0][0])); } DAL.ClsPay_PayMentDayBill oMain = new DAL.ClsPay_PayMentDayBill(); oMain.omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); oMain.omodel.HDate = HDate; oMain.omodel.HDeptID = 0; oMain.omodel.HDeptName = ""; oMain.omodel.HExplanation = ""; oMain.omodel.HGroupID = HGroupID; oMain.omodel.HGroupName = ""; oMain.omodel.HInnerBillNo = ""; oMain.omodel.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now); oMain.omodel.HMaker = "admin"; oMain.omodel.HPeriod = HPeriod; oMain.omodel.HRemark = ""; oMain.omodel.HYear = HYear; oMain.DetailColl = new List(); Model.ClsPay_PayMentDayBillSub oSub = new Model.ClsPay_PayMentDayBillSub(); oSub.HEmpID = HEmpID; oSub.HEntryID = 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(""); oSub.HCloseType = false; oSub.HPostID = DBUtility.ClsPub.isLong(oDsJT.Tables[0].Rows[k]["HPostID"]); oSub.HEmpName = ""; oSub.HEmpType = DBUtility.ClsPub.isStrNull(oDsJT.Tables[0].Rows[k]["HEmpType"]); // oSub.HPiecePay = DBUtility.ClsPub.isSingle(HMoney); oSub.HTimesPay = 0; oSub.HWorkTimes = DBUtility.ClsPub.isSingle(oDsJT.Tables[0].Rows[k]["HTimes"]); oSub.HPayTotal = DBUtility.ClsPub.isSingle(HMoney); if (DBUtility.ClsPub.isSingle(oDsJT.Tables[0].Rows[k]["HTimes"]) == 0) { oSub.HAvghourPay = 0; } else { oSub.HAvghourPay = DBUtility.ClsPub.isSingle(HMoney) / DBUtility.ClsPub.isSingle(oDsJT.Tables[0].Rows[k]["HTimes"]); } oMain.DetailColl.Add(oSub); if (!oMain.AddBill(ref DBUtility.ClsPub.sExeReturnInfo)) { MessageBox.Show("±£´æÊ§°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); return; } } } } oDsDR = oCn.RunProcReturn("exec h_p_Pay_AccPayMentDayBillDR '" + HDate + "'", "Pay_PayMentDayBillMain"); if (oDsDR.Tables[0].Rows.Count > 0) { for (int p = 0; p < oDsDR.Tables[0].Rows.Count; p++) { System.Windows.Forms.Application.DoEvents(); HEmpID = DBUtility.ClsPub.isLong(oDsDR.Tables[0].Rows[p]["HEmpID"]); HGroupID = DBUtility.ClsPub.isLong(oDsDR.Tables[0].Rows[p]["HGroupID"]); HMoney = DBUtility.ClsPub.isDoule(oDsDR.Tables[0].Rows[p]["HMoney"]); oDsOld = oCn.RunProcReturn("select a.HInterID from Pay_PayMentDayBillMain a inner join Pay_PayMentDayBillSub b on a.hinterid=b.hinterid where HDate='" + HDate + "' and b.HEmpID=" + HEmpID, "Pay_PayMentDayBillMain"); if (oDsOld.Tables[0].Rows.Count > 0) { oCn.RunProc("delete Pay_PayMentDayBillMain where HInterID=" + DBUtility.ClsPub.isLong(oDsOld.Tables[0].Rows[0][0])); oCn.RunProc("delete Pay_PayMentDayBillSub where HInterID=" + DBUtility.ClsPub.isLong(oDsOld.Tables[0].Rows[0][0])); } DAL.ClsPay_PayMentDayBill oMain = new DAL.ClsPay_PayMentDayBill(); oMain.omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); oMain.omodel.HDate = HDate; oMain.omodel.HDeptID = 0; oMain.omodel.HDeptName = ""; oMain.omodel.HExplanation = ""; oMain.omodel.HGroupID = HGroupID; oMain.omodel.HGroupName = ""; oMain.omodel.HInnerBillNo = ""; oMain.omodel.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now); oMain.omodel.HMaker = "admin"; oMain.omodel.HPeriod = HPeriod; oMain.omodel.HRemark = ""; oMain.omodel.HYear = HYear; oMain.DetailColl = new List(); Model.ClsPay_PayMentDayBillSub oSub = new Model.ClsPay_PayMentDayBillSub(); oSub.HEmpID = HEmpID; oSub.HEntryID = 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(""); oSub.HCloseType = false; oSub.HPostID = DBUtility.ClsPub.isLong(oDsDR.Tables[0].Rows[p]["HPostID"]); oSub.HEmpName = ""; oSub.HEmpType = DBUtility.ClsPub.isStrNull(oDsDR.Tables[0].Rows[p]["HEmpType"]); // oSub.HPiecePay = DBUtility.ClsPub.isSingle(HMoney); oSub.HTimesPay = 0; oSub.HWorkTimes = DBUtility.ClsPub.isSingle(oDsDR.Tables[0].Rows[p]["HTimes"]); oSub.HPayTotal = DBUtility.ClsPub.isSingle(HMoney); if (DBUtility.ClsPub.isSingle(oDsDR.Tables[0].Rows[p]["HTimes"]) == 0) { oSub.HAvghourPay = 0; } else { oSub.HAvghourPay = DBUtility.ClsPub.isSingle(HMoney) / DBUtility.ClsPub.isSingle(oDsDR.Tables[0].Rows[p]["HTimes"]); } oMain.DetailColl.Add(oSub); if (!oMain.AddBill(ref DBUtility.ClsPub.sExeReturnInfo)) { MessageBox.Show("±£´æÊ§°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); return; } } } System.Windows.Forms.Application.DoEvents(); pb1.Value = j + 1; lblHCount.Text = pb1.Value.ToString() + "/" + pb1.Maximum.ToString(); lblHMaterName.Text = HDate.ToString(); System.Windows.Forms.Application.DoEvents(); } } } }