示例#1
0
        private void LoadData()
        {
            //单据ID
            int mainID = 0;

            using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                int id = Convert.ToInt32(Request.QueryString["CommitDetailedID"]);
                CommitInDetailed SID = db.CommitInDetailed.SingleOrDefault(a => a.CommitDetailedID == id);


                if (SID != null)
                {
                    //单据id
                    mainID = SID.CommitInID;
                    CommitIn SI = db.CommitIn.SingleOrDefault(u => u.CommitInID == mainID);

                    this.txtStorageinNum.Text = SI.CommitInCode;

                    this.txtMaterialCode.Text     = SID.MaterialInfo.FinanceCode;
                    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.txtRemark.Text          = SID.Remark.ToString();

                    //再次新建初始化委外物料名称
                    //关系表存放的新建物料索引值唯一
                    RelationCommitIn rci = db.RelationCommitIn.SingleOrDefault(u => u.CommitMaterial == SID.CommitDetailedID);

                    StorageCommitOutRealDetails scord = db.StorageCommitOutRealDetails.SingleOrDefault(u => u.StorageCommitOutRealDetailsID == rci.CommitOutMaterial);
                    strCmit = "物料名称:" + scord.StorageCommitOutDetails.TableOfStocks.MaterialInfo.MaterialName + " | " + "物料编码:" + scord.StorageCommitOutDetails.TableOfStocks.MaterialInfo.MaterialCode;

                    this.txtCommitMaterialCode.Text = strCmit;
                    this.txtID.Text = scord.StorageCommitOutRealDetailsID.ToString();
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('记录不存在! ');</script>");
                    Response.Redirect("CommitInDetailedManage.aspx?CommitInID=" + Request.QueryString["CommitInID"] + "");
                }
            }
        }
示例#2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    CommitProduce SID = new CommitProduce();


                    SID.StorageInID = Convert.ToInt32(Request.QueryString["StorageInID"]);
                    SID.MaterialID  = Convert.ToInt32(this.txtID.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.ddlproject.SelectedIndex == 0)
                    {
                        ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('请选择预期使用项目!')</script>");
                        return;
                    }


                    SID.ExpectedProject = Convert.ToInt32(this.ddlproject.SelectedValue.Trim());


                    SID.ExpectedTime = this.DateTimeStorageIn.SelectedDate;


                    if (this.ddlbatch.SelectedItem.Text == "--请选择--")
                    {
                        ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('请选择入库批次')</script>");
                        return;
                    }

                    SID.BatchIndex = this.ddlbatch.SelectedItem.Text.ToString();
                    var SevTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                    SID.CreateTime = SevTime.First();
                    SID.Creator    = reEmpId(SPContext.Current.Web.CurrentUser.LoginName);
                    SID.Remark     = this.txtRemark.Text.Trim();

                    db.CommitProduce.InsertOnSubmit(SID);
                    db.SubmitChanges();


                    //写入委外关系表
                    RelationCommitIn rci = new RelationCommitIn();
                    rci.CommitMaterial    = SID.StorageInProduceID;
                    rci.CommitOutMaterial = this.txtcommitID.Text.Trim();
                    var STime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                    rci.CreateTime = STime.First();
                    db.RelationCommitIn.InsertOnSubmit(rci);
                    db.SubmitChanges();
                }
                if (!string.IsNullOrEmpty(Request.QueryString["TaskStorageID"]))
                {
                    Response.Redirect("StorageDetailedManage.aspx?StorageInID=" + Request.QueryString["StorageInID"] + "&&TaskStorageID=" + Request.QueryString["TaskStorageID"] + "");
                }
                else
                {
                    Response.Redirect("StorageDetailedManage.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_INSERTERROR));
            }
        }
示例#3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                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;
                }



                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;
                    }

                    CommitInDetailed SID = db.CommitInDetailed.SingleOrDefault(u => u.CommitDetailedID == Convert.ToInt32(Request.QueryString["CommitDetailedID"]));
                    SID.CommitInID = Convert.ToInt32(Request.QueryString["CommitInID"]);

                    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());
                    ////财务编码重复
                    //CommitInDetailed code = db.CommitInDetailed.SingleOrDefault(u => u.financeCode == this.txtMaterialfinance.Text.Trim());
                    //if (code != null)
                    //{
                    //    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 (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.Remark = this.txtRemark.Text.Trim();



                    db.SubmitChanges();


                    if (!string.IsNullOrEmpty(this.txtID.Text.Trim()))
                    {
                        //更新委外关系表
                        RelationCommitIn rc = db.RelationCommitIn.SingleOrDefault(u => u.CommitMaterial == Convert.ToInt32(Request.QueryString["CommitDetailedID"]));
                        rc.CommitMaterial    = SID.CommitDetailedID;
                        rc.CommitOutMaterial = Convert.ToInt32(this.txtID.Text.Trim());
                        rc.CreateTime        = this.DateTimeStorageIn.SelectedDate;
                        db.SubmitChanges();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('委外数据获取异常!')</script>");
                        return;
                    }



                    //判断是否有任务
                    if (!string.IsNullOrEmpty(Request.QueryString["TaskStorageID"]))
                    {
                        Response.Redirect("CommitInDetailedManage.aspx?CommitInID=" + Request.QueryString["CommitInID"] + "&&TaskStorageID=" + Request.QueryString["TaskStorageID"] + "&&CommitMid=" + this.txtID.Text.Trim() + "");
                    }
                    else
                    {
                        Response.Redirect("CommitInDetailedManage.aspx?CommitInID=" + Request.QueryString["CommitInID"] + "&&CommitMid=" + this.txtID.Text.Trim() + "");
                    }
                }
            }
            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_INSERTERROR));
            }
        }