private void LoadData() { //单据ID int mainID = 0; using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { int id = Convert.ToInt32(Request.QueryString["StorageDetailedID"]); StorageInDetailed SID = db.StorageInDetailed.SingleOrDefault(a => a.StorageDetailedID == id); if (SID != null) { //单据id mainID = SID.StorageInID; StorageIn SI = db.StorageIn.SingleOrDefault(u => u.StorageInID == mainID); this.txtStorageinNum.Text = SI.StorageInCode; this.txtMaterialCode.Text = SID.MaterialInfo.MaterialCode; this.txtMaterialMod.Text = SID.SpecificationModel; this.txtMaterialQuantity.Text = SID.Quantity.ToString(); this.txtGTJ.Text = SID.QuantityGentaojian.ToString(); this.txtMetre.Text = SID.QuantityMetre.ToString(); this.txtTon.Text = SID.QuantityTon.ToString(); this.ddlUnit.SelectedIndex = reIndex(SID.CurUnit.ToString()); this.txtMaterialUnitPrice.Text = SID.UnitPrice.ToString(); this.txtMaterialAmount.Text = SID.Amount.ToString(); this.ddlStorage.SelectedValue = SID.PileInfo.StorageID.ToString(); this.ddlPile.SelectedValue = SID.PileInfo.PileID.ToString(); this.txtMaterialfinance.Text = SID.financeCode.ToString(); this.DateTimeStorageIn.SelectedDate = SID.StorageTime; this.ddlSupplier.SelectedValue = SID.SupplierInfo.SupplierID.ToString(); this.txtManager.Text = db.EmpInfo.SingleOrDefault(u => u.EmpID == SID.MaterialsManager).Account; this.txtWarehouseWorker.Text = db.EmpInfo.SingleOrDefault(u => u.EmpID == SID.WarehouseWorker).Account; this.ddlbatch.SelectedValue = SID.BatchIndex.Trim(); this.txtRemark.Text = SID.Remark.ToString(); } else { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('记录不存在! ');</script>"); Response.Redirect("StorageInDetailedManage.aspx?StorageInID=" + Request.QueryString["StorageInID"] + ""); } } }
private bool checkInFlow(string selID) { using (MMSProDBDataContext data = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { StorageInDetailed sid = data.StorageInDetailed.SingleOrDefault(u => u.StorageInID == Convert.ToInt32(Request.QueryString["StorageInID"]) && u.StorageDetailedID == Convert.ToInt32(selID)); string CurBatch = sid.BatchIndex; var temp = from a in data.TaskStorageIn where a.StorageInID == Convert.ToInt32(Request.QueryString["StorageInID"]) && a.StorageInType == "正常入库" && a.QCBatch == CurBatch select a; if (temp.ToList().Count > 0) { return(false); } } return(true); }
public void btnSave_Click(object sender, EventArgs e) { try { #region 输入验证 if (!PageValidate.IsNumberTwoDecimal(this.txtMaterialQuantity.Text.Trim())) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('数量只能是数字 ')</script>"); return; } if (!PageValidate.IsNumberTwoDecimal(this.txtMaterialUnitPrice.Text.Trim())) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('单价只能是数字,且只能有两位小数 ')</script>"); return; } if (!PageValidate.IsNumberTwoDecimal(this.txtMaterialAmount.Text.Trim())) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('金额只能是数字,且只能有两位小数 ')</script>"); return; } #endregion using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { MaterialInfo mi = db.MaterialInfo.SingleOrDefault(u => u.MaterialCode == this.txtMaterialCode.Text.Trim()); if (mi == null) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('系统中不存在此物料编码,请先创建!')</script>"); return; } StorageInDetailed SID = db.StorageInDetailed.SingleOrDefault(k => k.StorageDetailedID == Convert.ToInt32(Request.QueryString["StorageDetailedID"])); SID.StorageInID = Convert.ToInt32(Request.QueryString["StorageInID"]); SID.MaterialID = mi.MaterialID; SID.SpecificationModel = this.txtMaterialMod.Text.Trim(); SID.QuantityGentaojian = Convert.ToDecimal(this.txtGTJ.Text.Trim()); SID.QuantityMetre = Convert.ToDecimal(this.txtMetre.Text.Trim()); SID.QuantityTon = Convert.ToDecimal(this.txtTon.Text.Trim()); if (this.ddlUnit.SelectedItem.Text == "--请选择--") { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('所选单位不能为空')</script>"); return; } SID.CurUnit = this.ddlUnit.SelectedItem.Text; SID.Quantity = Convert.ToDecimal(this.txtMaterialQuantity.Text.Trim()); SID.UnitPrice = Convert.ToDecimal(this.txtMaterialUnitPrice.Text.Trim()); SID.Amount = Convert.ToDecimal(this.txtMaterialAmount.Text.Trim()); if (this.ddlStorage.SelectedIndex == 0) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('请选择所属仓库!')</script>"); return; } if (this.ddlPile.SelectedIndex == 0) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('请选择所属垛位!')</script>"); return; } SID.PileID = Convert.ToInt32(this.ddlPile.SelectedValue.Trim()); //财务编码重复判断 //StorageInDetailed code = db.StorageInDetailed.SingleOrDefault(u => u.financeCode == this.txtMaterialfinance.Text.Trim()); //if (code == null) //{ // SID.financeCode = this.txtMaterialfinance.Text.Trim(); //} //else //{ // if (SID.StorageDetailedID == code.StorageDetailedID) // { // SID.financeCode = this.txtMaterialfinance.Text.Trim(); // } // else // { // ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('财务编码重复!')</script>"); // return; // } //} SID.financeCode = this.txtMaterialfinance.Text.Trim(); SID.StorageTime = this.DateTimeStorageIn.SelectedDate; if (this.ddlSupplier.SelectedIndex == 0) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('请选择供应商!')</script>"); return; } SID.SupplierID = Convert.ToInt32(this.ddlSupplier.SelectedValue.Trim()); if (reEmpId(this.txtWarehouseWorker.Text.Trim()) == 0) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('不存在物资管理员,请同步AD账户!')</script>"); return; } if (reEmpId(this.txtManager.Text.Trim()) == 0) { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('不存在仓库员,请同步AD账户!')</script>"); return; } SID.MaterialsManager = reEmpId(this.txtManager.Text.Trim()); SID.WarehouseWorker = reEmpId(this.txtWarehouseWorker.Text.Trim()); SID.BatchIndex = this.ddlbatch.SelectedValue.ToString(); SID.Remark = this.txtRemark.Text.Trim(); db.SubmitChanges(); if (!string.IsNullOrEmpty(Request.QueryString["TaskStorageID"])) { Response.Redirect("StorageInDetailedManage.aspx?StorageInID=" + Request.QueryString["StorageInID"] + "&&TaskStorageID=" + Request.QueryString["TaskStorageID"] + ""); } else { Response.Redirect("StorageInDetailedManage.aspx?StorageInID=" + Request.QueryString["StorageInID"] + ""); } } } catch (Exception ex) { MethodBase mb = MethodBase.GetCurrentMethod(); LogToDBHelper lhelper = LogToDBHelper.Instance; lhelper.WriteLog(ex.Message, "错误", string.Format("{0}.{1}", mb.ReflectedType.Name, mb.Name)); ClientScript.RegisterClientScriptBlock(typeof(string), "提示", string.Format("<script>alert('{0}')</script>", LogToDBHelper.LOG_MSG_UPDATEERROR)); } }