private void Page_Load(object sender, System.EventArgs e)
 {
     // 在此处放置用户代码以初始化页面
     this.Response.Expires         = -1;
     this.Response.ExpiresAbsolute = DateTime.Now.AddMilliseconds(-1);
     this.Response.CacheControl    = "no-cache";
     this.Button2.Attributes.Add("onclick", "window.returnValue='cccc';window.close()");
     if (!this.IsPostBack)
     {
         Bind();
         string strflag     = this.Request.QueryString["flag"].ToString();
         string strinvccode = this.Request.QueryString["invccode"].ToString();
         if (strflag == "add")
         {
             this.lblTitle.Text = "添加存货档案";
             ListItem liInvCCode = this.ddlInvCCode.Items.FindByValue(strinvccode);
             if (liInvCCode != null)
             {
                 liInvCCode.Selected = true;
             }
             BindUnit();
             string strnewinvcode = this.GetInvCode(strinvccode);
             this.txtInvCode.Text = strnewinvcode;
             //this.txtInvCode.Enabled = false;
         }
         if (strflag == "modify")
         {
             this.lblTitle.Text = "修改存货档案";
             string           strinvcode = this.Request.QueryString["invcode"].ToString();
             string           strsql     = "select * from tbInventory where cnvcInvCode='" + strinvcode + "'";
             DataTable        dtInv      = Helper.Query(strsql);
             Entity.Inventory inv        = new AMSApp.zhenghua.Entity.Inventory(dtInv);
             BindInv(inv);
             //this.txtInvCode.Enabled = false;
         }
         this.txtInvCode.Enabled  = false;
         this.ddlInvCCode.Enabled = false;
         this.txtInvNCost.Enabled = false;
     }
 }
        private Entity.Inventory GetInv()
        {
            if (this.txtInvCCost.Text == "")
            {
                this.txtInvCCost.Text = "0";
            }
            if (this.txtInvNCost.Text == "")
            {
                this.txtInvNCost.Text = "0";
            }
            if (this.txtSafeNum.Text == "")
            {
                this.txtSafeNum.Text = "0";
            }
            if (this.txtLowSum.Text == "")
            {
                this.txtLowSum.Text = "0";
            }
            if (this.txtRetailPrice.Text == "")
            {
                this.txtRetailPrice.Text = "0";
            }
            if (this.txtExpire.Text == "")
            {
                this.txtExpire.Text = "0";
            }
            if (this.txtDue.Text == "")
            {
                this.txtDue.Text = "5";
            }
            Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory();
            inv.cnvcInvCode    = this.txtInvCode.Text;
            inv.cnvcInvName    = this.txtInvName.Text;
            inv.cnvcInvCCode   = this.ddlInvCCode.SelectedValue;
            inv.cnbProductBill = this.chkProductBill.Checked;
            inv.cnbSale        = this.chkSale.Checked;
            inv.cnbPurchase    = this.chkPurchase.Checked;
            inv.cnbSelf        = this.chkSelf.Checked;
            inv.cnbComsume     = this.chkComsume.Checked;
            inv.cniInvCCost    = Convert.ToDecimal(this.txtInvCCost.Text);
            inv.cniInvNCost    = Convert.ToDecimal(this.txtInvNCost.Text);
            inv.cniSafeNum     = Convert.ToDecimal(this.txtSafeNum.Text);
            inv.cniLowSum      = Convert.ToDecimal(this.txtLowSum.Text);
            if (this.txtSDate.Text == "")
            {
                inv.cndSDate = DateTime.MinValue;
            }
            else
            {
                inv.cndSDate = Convert.ToDateTime(this.txtSDate.Text);
            }
            if (this.txtEDate.Text == "")
            {
                inv.cndEDate = DateTime.MinValue;
            }
            else
            {
                inv.cndEDate = Convert.ToDateTime(this.txtEDate.Text);
            }
            inv.cnvcValueType       = this.ddlValueType.SelectedValue;
            inv.cnvcInvStd          = this.txtInvStd.Text;
            inv.cnvcGroupCode       = this.ddlGroupCode.SelectedValue;
            inv.cnvcComUnitCode     = this.ddlComUnitCode.SelectedValue;
            inv.cnvcPUComUnitCode   = this.ddlPUComUnitCode.SelectedValue;
            inv.cnvcSAComUnitCode   = this.ddlSAComUnitCode.SelectedValue;
            inv.cnvcSTComUnitCode   = this.ddlSTComUnitCode.SelectedValue;
            inv.cnvcShopUnitCode    = this.ddlShopUnitCode.SelectedValue;
            inv.cnvcProduceUnitCode = this.ddlProduceUnitCode.SelectedValue;
            inv.cnfRetailPrice      = Convert.ToDecimal(this.txtRetailPrice.Text);
            inv.cnvcFeel            = this.txtFeel.Text;
            inv.cnvcOrganise        = this.txtOrganise.Text;
            inv.cnvcColor           = this.txtColor.Text;
            inv.cnvcTaste           = this.txtTaste.Text;

            //添加字段
            inv.cnnExpire = Convert.ToInt32(this.txtExpire.Text);
            inv.cnnDue    = Convert.ToInt32(this.txtDue.Text);
            return(inv);
        }