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_PayMent_QCAdd : Form { public Pay_PayMent_QCAdd() { InitializeComponent(); } public int HYear; public int HPeriod; long HMaterID; long HDeptID; long HGroupID; long HEmpID; long HProcID; long HUnitID; double HMoney; long HICMOInterID; string HICMOBillNo; string HRemark; private void cmdHMaterID_Click(object sender, EventArgs e) { DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View(); if (oMater.RefreshView()) { txtHMaterID.Tag = oMater.omodel.HItemID; txtHMaterID.Text = oMater.omodel.HNumber; txtHMaterName.Text = oMater.omodel.HName; txtHUnitID.Tag = oMater.omodel.HUnitID; txtHUnitID.Text = oMater.omodel.HUnitName; } else { txtHMaterID.Tag = 0; txtHMaterID.Text = ""; txtHMaterName.Text = ""; txtHUnitID.Tag = 0; txtHUnitID.Text = ""; } } private void txtHMaterID_TextChanged(object sender, EventArgs e) { if (txtHMaterID.Text.Trim() == "") { txtHMaterID.Tag = "0"; txtHMaterName.Text = ""; } } private void cmdHCostItemID_Click(object sender, EventArgs e) { DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View(); if (oDept.RefreshView()) { txtHDeptID.Text = oDept.oModel.HName; txtHDeptID.Tag = oDept.oModel.HItemID; } else { txtHDeptID.Text = ""; txtHDeptID.Tag = 0; } } private void txtHCostItemID_TextChanged(object sender, EventArgs e) { if (txtHDeptID.Text.Trim() == "") txtHDeptID.Tag = "0"; } private void Pay_PayMent_QCAdd_Load(object sender, EventArgs e) { //获取本期成本会计期间 if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false) { MessageBox.Show("获取成本会计期间失败!"); return; } cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear); cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 1); cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 2); cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 3); //cmbHYear.SelectedIndex = 0; //cmdHPeriod.Text = DBUtility.ClsPub.CBCurPeriod.ToString(); cmbHYear.Text = DBUtility.ClsPub.isStrNull(HYear); cmbHPeriod.Text = DBUtility.ClsPub.isStrNull(HPeriod); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; HYear = DBUtility.ClsPub.isInt( cmbHYear.Text); HPeriod = DBUtility.ClsPub.isInt(cmbHPeriod.Text); HDeptID = DBUtility.ClsPub.isLong(txtHDeptID.Tag); HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag); HEmpID = DBUtility.ClsPub.isLong(txtHEmpID.Tag); HMaterID = DBUtility.ClsPub.isLong(txtHMaterID.Tag); HProcID = DBUtility.ClsPub.isLong(txtHProcID.Tag); HUnitID = DBUtility.ClsPub.isLong(txtHUnitID.Tag); HMoney = DBUtility.ClsPub.isDoule(txtHMoney.Text); HICMOInterID = DBUtility.ClsPub.isLong(txtHICMOBillNo.Tag); HICMOBillNo = DBUtility.ClsPub.isStrNull(txtHICMOBillNo.Text); HRemark=DBUtility.ClsPub.isStrNull(txtHRemark.Text); Ds = oCn.RunProcReturn("select * from Pay_InitReportBalBill where HYear=" + HYear + " and HPeriod=" + HPeriod + " and HDeptID=" + HDeptID + " and HGroupID=" + HGroupID + " and HEmpID=" + HEmpID + " and HMaterID=" + HMaterID + " and HProcID=" + HProcID + " and HICMOBillNo='" + HICMOBillNo +"'"+ " and HICMOInterID=" + HICMOInterID + " and HUnitID=" + HUnitID, "Pay_InitReportBalBill"); if (Ds.Tables[0].Rows.Count > 0) { if (MessageBox.Show("该员工对应工序已存在期初,是否覆盖?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { oCn.RunProc("delete Pay_InitReportBalBill where HYear=" + HYear + " and HPeriod=" + HPeriod + " and HDeptID=" + HDeptID + " and HGroupID=" + HGroupID + " and HEmpID=" + HEmpID + " and HMaterID=" + HMaterID + " and HProcID=" + HProcID + " and HICMOBillNo='" + HICMOBillNo + "'" + " and HICMOInterID=" + HICMOInterID + " and HUnitID=" + HUnitID); } else { return; } } oCn.RunProc("insert into Pay_InitReportBalBill (HYear,HPeriod,HBillType,HDate " + " ,HDeptID,HGroupID,HEmpID,HMaterID,HProcID,HUnitID,HBeginQty" + " ,HReceiveQty,HSendQty,HEndQty,HBeginBal,HReceiveBal,HSendBal,HEndBal" + " ,HICMOInterID,HICMOBillNo,HRemark,HMaker,HMakeDate" + ") values (" + HYear + "," + HPeriod + ",2213,getdate()"+ "," + HDeptID + "," + HGroupID + "," + HEmpID + "," + HMaterID + "," + HProcID + "," + HUnitID + "," + HMoney + ",0,0,0,0,0,0,0"+ ","+HICMOInterID+",'"+HICMOBillNo+"','"+HRemark+"','"+DBUtility.ClsPub.CurUserName+"',getdate()"+ ")"); MessageBox.Show("保存完毕!"); } private void cmdHGroupID_Click(object sender, EventArgs e) { DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); if (oGroup.RefreshView()) { txtHGroupID.Text = oGroup.oModel.HName; txtHGroupID.Tag = oGroup.oModel.HItemID; } else { txtHGroupID.Text = ""; txtHGroupID.Tag = 0; } } private void cmdHProcID_Click(object sender, EventArgs e) { //DAL.ClsK3_Process_View oProc = new DAL.ClsK3_Process_View(); //if (oProc.RefreshView()) //{ // txtHProcID.Text = oProc.oModel.HName; // txtHProcID.Tag = oProc.oModel.HItemID; //} //else //{ // txtHProcID.Text = ""; // txtHProcID.Tag = 0; //} if (DBUtility.ClsPub.isLong(txtHICMOBillNo.Tag) == 0) { BLL.ClsBaseSelect_InterFace.SetTextByProc(txtHProcID); } else { BLL.ClsBaseSelect_InterFace.SetTextByProc_ICMO(txtHProcID, DBUtility.ClsPub.isLong(txtHICMOBillNo.Tag)); } } private void cmdHEmpID_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHEmpID.Text = oEmp.oModel.HName; txtHEmpID.Tag = oEmp.oModel.HItemID; } else { txtHEmpID.Text = ""; txtHEmpID.Tag = 0; } } private void txtHGroupID_TextChanged(object sender, EventArgs e) { if (txtHGroupID.Text.Trim() == "") txtHGroupID.Tag = "0"; } private void txtHProcID_TextChanged(object sender, EventArgs e) { if (txtHProcID.Text.Trim() == "") txtHProcID.Tag = "0"; } private void txtHEmpID_TextChanged(object sender, EventArgs e) { if (txtHEmpID.Text.Trim() == "") txtHEmpID.Tag = "0"; } private void cmdHUnitID_Click(object sender, EventArgs e) { DAL.ClsGy_Unit_View oUnit = new DAL.ClsGy_Unit_View(); if (oUnit.RefreshView()) { txtHUnitID.Text = oUnit.oModel.HName; txtHUnitID.Tag = oUnit.oModel.HItemID; } else { txtHUnitID.Text = ""; txtHUnitID.Tag = 0; } } private void txtHUnitID_TextChanged(object sender, EventArgs e) { if (txtHUnitID.Text.Trim() == "") txtHUnitID.Tag = "0"; } private void cmdHICMOBillNo_Click(object sender, EventArgs e) { DAL.Cls_S_K3_ICMOForProdInList oK3_ICMOForProdInList = new DAL.Cls_S_K3_ICMOForProdInList(); if (oK3_ICMOForProdInList.Refresh("")) //选择原单 { FillSelectData(oK3_ICMOForProdInList.oBillSelectColl); } } private void FillSelectData(List oList) { DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); int i = -1; foreach (DBUtility.BillSelect oSelectRow in oList) { i = i + 1; //生产任务单 if (oSelectRow.BillType == "85") { //grdMain.Rows.Add(); Application.DoEvents(); //得到信息 Ds = oCn.RunProcReturn("select * from h_v_K3_ICMOBillList where hmainid=" + oSelectRow.BillMainID + " and hsubid=0", "h_v_K3_ICMOBillList"); //写入信息 //Sub_WriteInForm(Ds.Tables[0], i); txtHDeptID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]); txtHDeptID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["部门"]); txtHMaterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]); txtHMaterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["物料代码"]); txtHMaterName.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["物料名称"]); txtHUnitID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]); txtHUnitID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["计量单位"]); txtHICMOBillNo.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainID"]); txtHICMOBillNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["单据号"]); Application.DoEvents(); } // } } } }