/// <summary> /// 提交编辑 /// </summary> private bool SubmintEdit() { if (StockIn != null) { ModifiedGrid(); StockIn.FCate = "内部"; StockIn.FCode = CurrentUser.AccountComId.ToString(CultureInfo.InvariantCulture); StockIn.FName = ""; StockIn.FMemo = txtFMemo.Text.Trim(); var parms = new Dictionary <string, object>(); parms.Clear(); parms.Add("@keyID", StockIn.KeyId); parms.Add("@companyId", CurrentUser.AccountComId); var amt = Convert.ToDecimal(SqlService.ExecuteProcedureCommand("proc_PurchaseAmt", parms).Tables[0].Rows[0][0]); StockIn.FAmount = amt; StockIn.FBatchNumber = txtFBatchNumber.Text.Trim(); StockIn.FSurveyor = !ddlFSurveyor.SelectedValue.Equals("-1") ? ddlFSurveyor.SelectedText : ""; StockIn.FProducer = !ddlFProducer.SelectedValue.Equals("-1") ? ddlFProducer.SelectedText : "";//GasHelper.GetDropDownListArrayString(ddlFProducer.SelectedItemArray); StockIn.FProductionWorkshop = ddlWorkShop.SelectedValue; StockIn.FDate = txtFDate.SelectedDate; StockIn.CreateBy = CurrentUser.AccountName; StockInService.SaveChanges(); var prod = StockInDetailsService.FirstOrDefault( p => p.KeyId == txtKeyId.Text && p.FCompanyId == CurrentUser.AccountComId); if (prod != null) { prod.FItemCode = txtFCode.Text; prod.FQty = Convert.ToDecimal(txtFQty.Text); prod.FBottle = tbxFBottle.SelectedValue; prod.FBottleQty = Convert.ToInt16(txtFBottleQty.Text); prod.FCostPrice = Convert.ToDecimal(txtFCostPrice.Text); prod.FBalance = Convert.ToDecimal(txtFBalance.Text); prod.FCostPrice = Convert.ToDecimal(txtFCostPrice.Text); prod.FBalance = Convert.ToDecimal(txtFBalance.Text); StockInDetailsService.SaveChanges(); } var orders = new Dictionary <string, object>(); orders.Clear(); orders.Add("@KeyId", StockIn.KeyId); orders.Add("@companyId", CurrentUser.AccountComId); SqlService.ExecuteProcedureCommand("proc_ProuctOrder", orders); return(true); } return(false); }
/// <summary> /// 提交添加 /// </summary> private bool SubmintAdd() { var stock = StockInService.Where(p => p.KeyId == txtKeyId.Text.Trim() && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault(); if (stock != null) { ModifiedGrid(); var prod = StockInDetailsService.FirstOrDefault( p => p.KeyId == txtKeyId.Text && p.FCompanyId == CurrentUser.AccountComId); if (prod == null) { //生产产品入库 var product = new LHStockInDetails { KeyId = txtKeyId.Text, FItemCode = txtFCode.Text, FPrice = 0, FAmount = 0, FQty = Convert.ToDecimal(txtFQty.Text), FBottle = tbxFBottle.SelectedValue, FBottleQty = Convert.ToInt16(txtFBottleQty.Text), FBottleOweQty = 0, FCompanyId = CurrentUser.AccountComId, FCateId = 2000, FMemo = "生产入库", FCostPrice = Convert.ToDecimal(txtFCostPrice.Text), FBalance = Convert.ToDecimal(txtFBalance.Text), }; StockInDetailsService.Add(product); } else { prod.FItemCode = txtFCode.Text; prod.FQty = Convert.ToDecimal(txtFQty.Text); prod.FBottle = tbxFBottle.SelectedValue; prod.FBottleQty = Convert.ToInt32(txtFBottleQty.Text); prod.FCostPrice = Convert.ToDecimal(txtFCostPrice.Text); prod.FBalance = Convert.ToDecimal(txtFBalance.Text); StockInDetailsService.SaveChanges(); } //------------------------------------------------------------------- stock.FCompanyId = CurrentUser.AccountComId; stock.FFlag = 1; stock.FDeleteFlag = 0; stock.FMemo = txtFMemo.Text.Trim(); var parms = new Dictionary <string, object>(); parms.Clear(); parms.Add("@keyID", stock.KeyId); parms.Add("@companyId", CurrentUser.AccountComId); var amt = Convert.ToDecimal(SqlService.ExecuteProcedureCommand("proc_PurchaseAmt", parms).Tables[0].Rows[0][0]); stock.FAmount = amt; stock.FSurveyor = !ddlFSurveyor.SelectedValue.Equals("-1") ? ddlFSurveyor.SelectedText : ""; stock.FProducer = !ddlFProducer.SelectedValue.Equals("-1") ? ddlFProducer.SelectedText : "";//GasHelper.GetDropDownListArrayString(ddlFProducer.SelectedItemArray); stock.FBatchNumber = txtFBatchNumber.Text.Trim(); stock.FProductionWorkshop = ddlWorkShop.SelectedValue; stock.FCate = "内部"; stock.FCode = CurrentUser.AccountComId.ToString(CultureInfo.InvariantCulture); stock.FName = ""; stock.FDate = txtFDate.SelectedDate; StockInService.SaveChanges(); if (txtKeyId.Text.Contains("TM")) { //单据号问题 string newKeyId = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate), "PR", CurrentUser.AccountComId); var orderParms = new Dictionary <string, object>(); orderParms.Clear(); orderParms.Add("@oldKeyId", txtKeyId.Text); orderParms.Add("@newKeyId", newKeyId); orderParms.Add("@Bill", "6"); orderParms.Add("@companyId", CurrentUser.AccountComId); SqlService.ExecuteProcedureCommand("proc_num", orderParms); txtKeyId.Text = newKeyId; var orders = new Dictionary <string, object>(); orders.Clear(); orders.Add("@KeyId", newKeyId); orders.Add("@companyId", CurrentUser.AccountComId); SqlService.ExecuteProcedureCommand("proc_ProuctOrder", orders); //新增日志 var billStatus = new LHBillStatus { KeyId = newKeyId, FCompanyId = CurrentUser.AccountComId, FActionName = "新增", FDate = DateTime.Now, FDeptId = CurrentUser.AccountOrgId, FOperator = CurrentUser.AccountName, FMemo = String.Format("单据号{0},{1}新增生产单据。", newKeyId, CurrentUser.AccountName) }; GasHelper.AddBillStatus(billStatus); } return(true); } return(false); }