示例#1
0
        private void btAdd_Click(object sender, System.EventArgs e)
        {
            CMSMStruct.MaterialSStruct mss = new CMSMStruct.MaterialSStruct();

            if (txtBatchNo.Text.Trim() == "")
            {
                this.SetErrorMsgPageBydirHistory("原材料批次不能为空!");
                return;
            }
            else
            {
                mss.strBatchNo = txtBatchNo.Text.Trim();
            }

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

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

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

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

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

            if (!ms1.InsertMaterial(mss))
            {
                this.SetErrorMsgPageBydir("添加原材料资料失败,请重试!");
                return;
            }
            else
            {
                this.SetSuccMsgPageBydir("添加原材料资料成功!", "");
                return;
            }
        }