示例#1
0
        private void btAdd_Click(object sender, System.EventArgs e)
        {
            CMSMStruct.LoginStruct ls1 = (CMSMStruct.LoginStruct)Session["Login"];
            if (ls1.strDeptID == "CEN00" || ls1.strNewDeptID == "")
            {
                this.Popup("没有操作权限,请使用部门帐号!");
                this.btnQuery.Enabled = false;
                this.btAdd.Enabled    = false;
                return;
            }
            if (this.txtMaterialCode.Text.Trim() == "")
            {
                this.SetErrorMsgPageBydirHistory("请选择要入库有原材料!");
                return;
            }
            string strOutCount = this.txtOutCount.Text.Trim();

            if (strOutCount == "")
            {
                this.SetErrorMsgPageBydirHistory("请输入本次出库数量!");
                return;
            }
            if (!this.JudgeIsNum(strOutCount, "本次出库数量"))
            {
                return;
            }

            CMSMStruct.MaterialOutStruct mes1 = new CommCenter.CMSMStruct.MaterialOutStruct();
            mes1.dOutCount       = Math.Round(double.Parse(strOutCount), 2);
            mes1.strBatchNo      = this.txtBatchNo.Text.Trim();
            mes1.strMaterialCode = this.txtMaterialCode.Text.Trim();
            mes1.strMaterialName = this.txtMaterialName.Text.Trim();
            mes1.strStandardUnit = this.txtStandardUnit.Text.Trim();
            mes1.strUnit         = this.txtUnit.Text.Trim();
            mes1.dPrice          = Math.Round(double.Parse(this.txtPrice.Text.Trim()), 2);
            mes1.strProviderName = this.txtProviderName.Text.Trim();
            mes1.strMaterialType = this.ddlMaterialType.SelectedValue;
            mes1.dLastCount      = Math.Round(double.Parse(this.txtCurCount.Text.Trim()), 2);
            mes1.dCount          = mes1.dLastCount - mes1.dOutCount;
            mes1.strOperType     = "0";
            mes1.strOutDate      = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();
//			mes1.strDeptID=ls1.strNewDeptID;
            mes1.strDeptID   = ls1.strDeptID;
            mes1.strOperDate = mes1.strOutDate;
            mes1.strOperName = ls1.strOperName;

            Hashtable htapp   = (Hashtable)Application["appconf"];
            string    strcons = (string)htapp["cons"];

            msb1 = new MaterialSBusi(strcons);

            CMSMStruct.MaterialSStruct msscur = msb1.GetMaterialInfo(mes1.strBatchNo, mes1.strMaterialCode);
            if (msscur.dCurCount < mes1.dOutCount)
            {
                this.Popup("当前数量不足!");
                return;
            }
            if (msscur.dCurCount != mes1.dLastCount)
            {
                this.SetErrorMsgPageBydir("当前数量可能有变动,请重新录入!");
                return;
            }

            if (msb1.InsertMaterialOut(mes1))
            {
                this.SetSuccMsgPageBydir("录入原材料出库成功!", "");
                return;
            }
            else
            {
                this.SetErrorMsgPageBydir("录入原材料出库失败,请重试!");
                return;
            }
        }