예제 #1
0
        private void btMod_Click(object sender, System.EventArgs e)
        {
            CMSMStruct.MaterialSStruct mssold = (CMSMStruct.MaterialSStruct)Session["mssold"];
            if (mssold.strMaterialCode == "")
            {
                this.SetErrorMsgPageBydir("获取原材料编号错误!");
                return;
            }

            CMSMStruct.MaterialSStruct mssnew = new CMSMStruct.MaterialSStruct();
            mssnew.strMaterialCode = mssold.strMaterialCode;

            if (txtMaterialName.Text.Trim() == "")
            {
                this.SetErrorMsgPageBydirHistory("原材料名称不能为空!");
                return;
            }
            else if (ms1.ChkNewMaterialNameDup(txtBatchNo.Text.Trim(), txtMaterialName.Text.Trim(), mssold.strMaterialCode))
            {
                mssnew.strMaterialName = txtMaterialName.Text.Trim();
            }
            else
            {
                this.SetErrorMsgPageBydirHistory("该原材料名称已经存在,请重新输入!");
                return;
            }

            if (txtPrice.Text.Trim() == "")
            {
                this.SetErrorMsgPageBydirHistory("单价不能为空!");
                return;
            }
            else
            {
                mssnew.dPrice = double.Parse(txtPrice.Text.Trim());
            }

            if (txtUnit.Text.Trim() == "")
            {
                this.SetErrorMsgPageBydirHistory("单位不能为空!");
                return;
            }
            else
            {
                mssnew.strUnit = txtUnit.Text.Trim();
            }

            if (txtProviderName.Text.Trim() == "")
            {
                this.SetErrorMsgPageBydirHistory("供应商不能为空!");
                return;
            }
            else
            {
                mssnew.strProviderName = txtProviderName.Text.Trim();
            }

            mssnew.strStandardUnit = this.txtStandardUnit.Text.Trim();
            mssnew.strMaterialType = this.ddlMaterialType.SelectedValue;

            if (!ms1.UpdateMaterial(mssnew, mssold))
            {
                this.SetErrorMsgPageBydir("保存原材料修改信息失败,请重试!");
                return;
            }
            else
            {
                this.SetSuccMsgPageBydir("保存原材料修改信息成功!", "");
                return;
            }
        }