private void SyncGoods(Entity.Inventory inv, SqlTransaction trans) { //string strsql = "SELECT * FROM tbProductClass where cnvcproductclasscode='"+inv.cnvcInvCCode+"'"; //DataTable dtpc = SqlHelper.ExecuteDataTable(trans,CommandType.Text,strsql); // if(dtpc.Rows.Count>0) // { //Entity.ProductClass pc = new ProductClass(dtpc); // if(pc.cnvcProductType == "FINALPRODUCT") // { string strsql = "select * from tbGoods where vcGoodsID='" + inv.cnvcInvCode + "'"; DataTable dtGoods = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql); if (inv.cnbSale) { if (dtGoods.Rows.Count == 0) { Entity.Goods gs = new Goods(); gs.vcGoodsID = inv.cnvcInvCode; gs.vcGoodsName = inv.cnvcInvName; gs.vcSpell = Helper.GetChineseSpell(inv.cnvcInvName); gs.nPrice = Convert.ToDecimal(inv.cnfRetailPrice); gs.nRate = 0; gs.iIgValue = -1; gs.cNewFlag = "0"; gs.vcComments = "存货档案添加同步"; EntityMapping.Create(gs, trans); } else { Entity.Goods gs = new Goods(dtGoods); if (gs.vcGoodsName != inv.cnvcInvName) { gs.vcGoodsName = inv.cnvcInvName; gs.vcSpell = Helper.GetChineseSpell(inv.cnvcInvName); } if (inv.cnfRetailPrice > 0) { gs.nPrice = Convert.ToDecimal(inv.cnfRetailPrice); } gs.vcComments = "存货档案修改同步"; EntityMapping.Update(gs, trans); } } else { if (dtGoods.Rows.Count > 0) { Entity.Goods gs = new Goods(dtGoods); EntityMapping.Delete(gs, trans); } } //} //} }
private void BindPart() { if (Session["part"] != null) { Entity.Inventory inv = Session["part"] as Entity.Inventory; this.SetDDL(this.ddlProductClass, inv.cnvcInvCCode); this.SetDDL(this.ddlUnit, inv.cnvcProduceUnitCode); this.SetDDL(this.ddlGroupCode, inv.cnvcGroupCode); this.txtProductCode.Text = inv.cnvcInvCode; this.txtProductName.Text = inv.cnvcInvName; } }
public int DeleteInventory(OperLog operLog, Entity.Inventory inv) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Entity.Inventory oldinv = new Entity.Inventory(); oldinv.cnvcInvCode = inv.cnvcInvCode; oldinv = EntityMapping.Get(oldinv, trans) as Entity.Inventory; EntityMapping.Delete(oldinv, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "存货编码:" + inv.cnvcInvCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); return(-1); } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); return(-1); } finally { ConnectionPool.ReturnConnection(conn); } return(1); } }
private void BindInv(Entity.Inventory inv) { this.txtInvCode.Text = inv.cnvcInvCode; this.txtInvName.Text = inv.cnvcInvName; this.SetDDL(this.ddlInvCCode, inv.cnvcInvCCode); this.chkProductBill.Checked = inv.cnbProductBill; this.chkSale.Checked = inv.cnbSale; this.chkPurchase.Checked = inv.cnbPurchase; this.chkSelf.Checked = inv.cnbSelf; this.chkComsume.Checked = inv.cnbComsume; this.txtInvCCost.Text = inv.cniInvCCost.ToString(); this.txtInvNCost.Text = inv.cniInvNCost.ToString(); this.txtSafeNum.Text = inv.cniSafeNum.ToString(); this.txtLowSum.Text = inv.cniLowSum.ToString(); if (inv.cndSDate > DateTime.MinValue) { this.txtSDate.Text = inv.cndSDate.ToString("yyyy-MM-dd"); } if (inv.cndEDate > DateTime.MinValue) { this.txtEDate.Text = inv.cndEDate.ToString("yyyy-MM-dd"); } this.SetDDL(this.ddlValueType, inv.cnvcValueType); this.txtInvStd.Text = inv.cnvcInvStd; this.SetDDL(this.ddlGroupCode, inv.cnvcGroupCode); BindUnit(); this.SetDDL(this.ddlComUnitCode, inv.cnvcComUnitCode); this.SetDDL(this.ddlPUComUnitCode, inv.cnvcPUComUnitCode); this.SetDDL(this.ddlSAComUnitCode, inv.cnvcSAComUnitCode); this.SetDDL(this.ddlSTComUnitCode, inv.cnvcSTComUnitCode); this.SetDDL(this.ddlShopUnitCode, inv.cnvcShopUnitCode); this.SetDDL(this.ddlProduceUnitCode, inv.cnvcProduceUnitCode); this.txtRetailPrice.Text = inv.cnfRetailPrice.ToString(); this.txtFeel.Text = inv.cnvcFeel; this.txtOrganise.Text = inv.cnvcOrganise; this.txtColor.Text = inv.cnvcColor; this.txtTaste.Text = inv.cnvcTaste; //添加字段 zhh this.txtExpire.Text = inv.cnnExpire.ToString(); this.txtDue.Text = inv.cnnDue.ToString(); }
private void BindChild() { if (Session["child"] != null) { DataTable dtchild = Session["child"] as DataTable; if (!dtchild.Columns.Contains("cnnBaseQtyN")) { dtchild.Columns.Add("cnnBaseQtyN"); } if (Session["bom"] != null) { DataTable dtbom = Session["bom"] as DataTable; foreach (DataRow dr in dtchild.Rows) { Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(dr); DataRow[] drs = dtbom.Select("cnvcComponentInvCode='" + inv.cnvcInvCode + "'"); if (drs.Length > 0) { Entity.BillOfMaterials bom = new BillOfMaterials(drs[0]); dr["cnnBaseQtyN"] = bom.cnnBaseQtyN; } } } this.DataTableConvert(dtchild, "cnvcProduceUnitCode", "cnvcProduceUnitCodeName", "tbComputationUnit", "cnvcComUnitCode", "cnvcComUnitName", ""); this.dgBOM.DataSource = dtchild; this.dgBOM.DataBind(); } else { Entity.Inventory inv = new Entity.Inventory(); DataTable dtchild = inv.ToTable().Clone(); dtchild.Columns.Add("cnnBaseQtyN"); this.dgBOM.DataSource = dtchild; this.dgBOM.DataBind(); } }
private void Button1_Click(object sender, System.EventArgs e) { //确定 Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); //ol.cnvcOperType = "添加存货档案"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; Entity.Inventory inv = GetInv(); Business.InventoryFacade binv = new InventoryFacade(); if (this.JudgeIsNull(this.txtInvCode.Text)) { this.Popup("存货编码获取错误,请重新打开此页面"); return; } if (this.JudgeIsNull(this.txtInvName.Text)) { this.Popup("请输入存货名称"); return; } // if(this.JudgeIsNull(this.txtInvCCost.Text)) // { // this.Popup("请输入参考成本"); // return; // } if (!this.JudgeIsNum(this.txtInvCCost.Text)) { this.Popup("参考成本请输入数字"); return; } if (!this.JudgeIsNum(this.txtSafeNum.Text)) { this.Popup("安全库存量请输入数字"); return; } if (!this.JudgeIsNum(this.txtLowSum.Text)) { this.Popup("最低库存量请输入数字"); return; } if (!this.JudgeIsNum(this.txtExpire.Text)) { this.Popup("过期限制请输入数字"); return; } if (!this.JudgeIsNum(this.txtRetailPrice.Text)) { this.Popup("零售价请输入数字"); return; } if (this.lblTitle.Text == "添加存货档案") { //Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "添加存货档案"; // ol.cnvcOperID = this.oper.strLoginID; // ol.cnvcDeptID = this.oper.strDeptID; // // // Entity.Inventory inv = GetInv(); // // Business.InventoryFacade binv = new InventoryFacade(); int ret = binv.AddInventory(ol, inv); if (ret > 0) { this.Popup("添加存货档案成功!"); } else { this.Popup("添加存货档案失败!"); } this.Response.Write("<script type=\"text/javascript\">window.returnValue=true;window.close()</script>"); } if (this.lblTitle.Text == "修改存货档案") { //Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改存货档案"; // ol.cnvcOperID = this.oper.strLoginID; // ol.cnvcDeptID = this.oper.strDeptID; // // // Entity.Inventory inv = GetInv(); // // Business.InventoryFacade binv = new InventoryFacade(); int ret = binv.UpdateInventory(ol, inv); if (ret > 0) { this.Popup("修改存货档案成功!"); } else { this.Popup("修改存货档案失败!"); } this.Response.Write("<script type=\"text/javascript\">window.returnValue=true;window.close()</script>"); } }
private void Button1_Click(object sender, System.EventArgs e) { //选择 if (this.DataGrid2.SelectedIndex >= 0) { string strinvcode = this.DataGrid2.SelectedItem.Cells[1].Text; if (strinvcode == "nbsp;") { return; } string strinvname = this.DataGrid2.SelectedItem.Cells[2].Text; string strinvccode = this.DataGrid2.SelectedItem.Cells[3].Text; string strgroupcode = this.DataGrid2.SelectedItem.Cells[20].Text; string stProduceUnitCode = this.DataGrid2.SelectedItem.Cells[25].Text; Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(); inv.cnvcInvCode = strinvcode; inv.cnvcInvName = strinvname; inv.cnvcInvCCode = strinvccode; inv.cnvcGroupCode = strgroupcode; inv.cnvcProduceUnitCode = stProduceUnitCode; if (hidflag.Value == "part") { Session["part"] = inv; string strsql = "select * from tbinventory where cnvcinvcode in (select cnvcComponentInvCode from tbBillOfMaterials where cnvcPartInvcode='" + strinvcode + "')"; DataTable dtchild = Helper.Query(strsql); Session["child"] = dtchild; strsql = "select * from tbBillOfMaterials where cnvcPartInvcode='" + strinvcode + "'"; DataTable dtBOM = Helper.Query(strsql); Entity.BillOfMaterials bom = new BillOfMaterials(dtBOM); Session["BaseQtyD"] = bom.cnnBaseQtyD; Session["bom"] = dtBOM; } if (hidflag.Value == "child") { //子件 if (Session["child"] == null) { Session["child"] = inv.ToTable(); } else { if (Session["part"] != null) { Entity.Inventory invpart = Session["part"] as Entity.Inventory; if (invpart.cnvcInvCode == inv.cnvcInvCode) { this.Popup("母件已选!"); return; } } DataTable dt = Session["child"] as DataTable; DataRow[] drs = dt.Select("cnvcinvcode='" + inv.cnvcInvCode + "'"); if (drs.Length > 0) { this.Popup("子件已选!"); return; } int iColloms = dt.Columns.Count; object[] oArray = new object[iColloms]; inv.ToRow().ItemArray.CopyTo(oArray, 0); dt.Rows.Add(oArray); //dt.Rows.Add(inv.ToRow()); Entity.BillOfMaterials bom = new BillOfMaterials(); bom.cnvcComponentInvCode = inv.cnvcInvCode; if (Session["bom"] == null) { Session["bom"] = bom.ToTable(); } DataTable dtbom = Session["bom"] as DataTable; object[] bomarray = new object[dtbom.Columns.Count]; bom.ToRow().ItemArray.CopyTo(bomarray, 0); dtbom.Rows.Add(bomarray); Session["bom"] = dtbom; Session["child"] = dt; } } } this.Response.Write("<script type=\"text/javascript\">window.close()</script>"); }
private void btnAdd_Click(object sender, System.EventArgs e) { //添加 try { string strCount = this.txtBaseQtyD.Text; if (strCount == "") { Popup("请输入基础用量"); return; } if (!Regex.IsMatch(strCount, @"^[+|-]{0,1}(\d*)\.{0,1}\d{0,}$")) { Popup("基础用量请输入数字"); return; } string strProductCode = txtProductCode.Text; if (strProductCode == "") { Popup("请选择存货"); return; } if (Session["part"] == null || Session["bom"] == null) { this.Popup("数据异常!"); return; } Entity.Inventory inv = Session["part"] as Entity.Inventory; DataTable dtbom = Session["bom"] as DataTable; if (dtbom.Rows.Count == 0) { this.Popup("请选择子件!"); return; } foreach (DataRow drbom in dtbom.Rows) { Entity.BillOfMaterials bom = new BillOfMaterials(drbom); if (bom.cnnBaseQtyN <= 0) { this.Popup("请输入用量"); return; } drbom["cnvcpartinvcode"] = inv.cnvcInvCode; drbom["cnnbaseqtyd"] = strCount; } OperLog operLog = new OperLog(); operLog.cnvcOperID = oper.strLoginID; operLog.cnvcDeptID = oper.strDeptID; operLog.cnvcOperType = "编辑配方"; Business.InventoryFacade inf = new InventoryFacade(); int ret = inf.UpdateBOM(operLog, inv.cnvcInvCode, dtbom); if (ret > 0) { this.Popup("编辑配方成功!"); } else { this.Popup("编辑配方失败!"); } } catch (Exception ex) { Popup(ex.Message); } }
public int UpdateInventory(OperLog operLog, Entity.Inventory inv) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); //IFormatProvider ip = new System.ifor //strSysTime = DateTime.Parse(strSysTime).ToString("yyyy-MM-dd hh:mm:ss"); DateTime dtSysTime = DateTime.Parse(strSysTime); //dtSysTime = dtSysTime.ToString Entity.Inventory oldinv = new Entity.Inventory(); oldinv.cnvcInvCode = inv.cnvcInvCode; oldinv = EntityMapping.Get(oldinv, trans) as Entity.Inventory; oldinv.cnbComsume = inv.cnbComsume; oldinv.cnbProductBill = inv.cnbProductBill; oldinv.cnbPurchase = inv.cnbPurchase; oldinv.cnbSale = inv.cnbSale; oldinv.cnbSelf = inv.cnbSelf; oldinv.cndEDate = inv.cndEDate; oldinv.cndSDate = inv.cndSDate; oldinv.cndModifyDate = dtSysTime; oldinv.cnfRetailPrice = inv.cnfRetailPrice; oldinv.cniInvCCost = inv.cniInvCCost; oldinv.cniInvNCost = inv.cniInvNCost; oldinv.cniLowSum = inv.cniLowSum; oldinv.cniSafeNum = inv.cniSafeNum; oldinv.cnvcColor = inv.cnvcColor; oldinv.cnvcComUnitCode = inv.cnvcComUnitCode; oldinv.cnvcFeel = inv.cnvcFeel; oldinv.cnvcGroupCode = inv.cnvcGroupCode; oldinv.cnvcInvCCode = inv.cnvcInvCCode; oldinv.cnvcInvCode = inv.cnvcInvCode; oldinv.cnvcInvName = inv.cnvcInvName; oldinv.cnvcInvStd = inv.cnvcInvStd; oldinv.cnvcModifyPerson = operLog.cnvcOperID; oldinv.cnvcOrganise = inv.cnvcOrganise; oldinv.cnvcProduceUnitCode = inv.cnvcProduceUnitCode; oldinv.cnvcPUComUnitCode = inv.cnvcPUComUnitCode; oldinv.cnvcSAComUnitCode = inv.cnvcSAComUnitCode; oldinv.cnvcShopUnitCode = inv.cnvcShopUnitCode; oldinv.cnvcSTComUnitCode = inv.cnvcSTComUnitCode; oldinv.cnvcTaste = inv.cnvcTaste; oldinv.cnvcValueType = inv.cnvcValueType; EntityMapping.Update(oldinv, trans); SyncGoods(inv, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "存货编码:" + inv.cnvcInvCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); return(-1); } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); return(-1); } finally { ConnectionPool.ReturnConnection(conn); } return(1); } }