private void ddlProvider_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            this.ddlProduct.Items.Clear();
            string    strProvider = this.ddlProvider.SelectedValue;
            Hashtable htapp       = (Hashtable)Application["appconf"];
            string    strcons     = (string)htapp["cons"];

            StoBusi = new BusiComm.StorageBusi(strcons);
            try
            {
                DataTable dtout = StoBusi.GetMaterialInfoByProvider(strProvider, this.txtMaterialFilter.Text.Trim());
                if (dtout == null)
                {
                    this.SetErrorMsgPageBydir("查询出错,请重试!");
                    return;
                }
                else
                {
                    this.FillDropDownList(dtout, this.ddlProduct);
                    if (this.ddlProduct.Items.Count > 0)
                    {
                        DataTable dtmaterial = (DataTable)Application["AllMaterial"];
                        DataView  dview      = dtmaterial.DefaultView;
                        dview.RowFilter            = "vcCommCode='" + this.ddlProduct.SelectedValue + "'";
                        this.lblUnit.Text          = dview[0]["cnvcUnit"].ToString();
                        this.txtStandardUnit.Text  = dview[0]["cnvcStandardUnit"].ToString();
                        this.txtStandardCount.Text = dview[0]["cnnStatdardCount"].ToString();
                    }
                }
            }
            catch (Exception er)
            {
                this.clog.WriteLine(er);
                this.SetErrorMsgPageBydir("查询错误,请重试!");
                return;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            if (Session["Login"] == null)
            {
                Response.Redirect("../Exit.aspx");
                return;
            }
            string    strBillEnterID = Request.QueryString["ID"];
            Hashtable htapp          = (Hashtable)Application["appconf"];
            string    strcons        = (string)htapp["cons"];

            StoBusi = new BusiComm.StorageBusi(strcons);
            if (!IsPostBack)
            {
                this.txtStandardUnit.ReadOnly  = true;
                this.txtStandardCount.ReadOnly = true;
                if (strBillEnterID == "" || strBillEnterID == null)
                {
                    strBeginDate        = DateTime.Now.ToShortDateString();
                    this.btnAdd.Enabled = true;
                    this.FillDropDownList("Provider", this.ddlProvider);
                    this.ddlEnterType.Items.Add(new ListItem("采购入库", "CA01"));
                    this.ddlEnterType.Items.Add(new ListItem("剩余回入", "CA03"));
                    this.ddlEnterType.Items.Add(new ListItem("工具类材料归还", "CA05"));
                    this.ddlEnterType.SelectedIndex = 0;
                    DataTable dtout = new DataTable();
                    dtout.Columns.Add("cnvcProviderCode");
                    dtout.Columns.Add("cnvcProviderName");
                    dtout.Columns.Add("cnvcProductCode");
                    dtout.Columns.Add("cnvcProductName");
                    dtout.Columns.Add("cnvcStandardUnit");
                    dtout.Columns.Add("cnnStandardCount");
                    dtout.Columns.Add("cnvcUnit");
                    dtout.Columns.Add("cnnPrice");
                    dtout.Columns.Add("cnnCount");
                    dtout.Columns.Add("cnnSum");
                    Session["EnterDetail"]    = dtout;
                    this.DataGrid1.DataSource = dtout;
                    this.DataGrid1.DataBind();
                    this.btnPrint.Enabled = false;

                    this.ddlProduct.Items.Clear();
                    string strProvider = this.ddlProvider.SelectedValue;
                    try
                    {
                        DataTable dtMaterial = StoBusi.GetMaterialInfoByProvider(strProvider, "");
                        if (dtMaterial == null)
                        {
                            this.SetErrorMsgPageBydir("查询出错,请重试!");
                            return;
                        }
                        else
                        {
                            this.FillDropDownList(dtMaterial, this.ddlProduct);
                            if (this.ddlProduct.Items.Count > 0)
                            {
                                DataTable dtmaterial = (DataTable)Application["AllMaterial"];
                                DataView  dview      = dtmaterial.DefaultView;
                                dview.RowFilter            = "vcCommCode='" + this.ddlProduct.SelectedValue + "'";
                                this.lblUnit.Text          = dview[0]["cnvcUnit"].ToString();
                                this.txtStandardUnit.Text  = dview[0]["cnvcStandardUnit"].ToString();
                                this.txtStandardCount.Text = dview[0]["cnnStatdardCount"].ToString();
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        this.clog.WriteLine(er);
                        this.SetErrorMsgPageBydir("查询错误,请重试!");
                        return;
                    }
                }
                else
                {
                    this.btnAdd.Enabled = false;
                    this.FillDropDownList("Provider", this.ddlProvider);
                    this.ddlEnterType.Items.Add(new ListItem("采购入库", "Stock"));
                    this.ddlEnterType.Items.Add(new ListItem("剩余回入", "Leave"));
                    this.ddlEnterType.Items.Add(new ListItem("工具类材料归还", "CA05"));
                    this.ddlEnterType.SelectedIndex = 0;
                    DataSet dsout = StoBusi.GetBillOfEnterStorageOneLog(strBillEnterID);
                    dsout.DataSetName = "面包工坊原料(材料)进仓单";
                    Session.Remove("BillPrint");
                    Session["BillPrint"] = dsout.Copy();
                    DataTable dtLog    = dsout.Tables["EnterLog"];
                    DataTable dtDetail = dsout.Tables["EnterDetail"];

                    this.ddlProvider.SelectedIndex  = this.ddlProvider.Items.IndexOf(this.ddlProvider.Items.FindByValue(dtLog.Rows[0]["cnvcProviderCode"].ToString()));
                    this.ddlEnterType.SelectedIndex = this.ddlEnterType.Items.IndexOf(this.ddlEnterType.Items.FindByText(dtLog.Rows[0]["cnvcEnterType"].ToString()));
                    strBeginDate                   = dtLog.Rows[0]["cndEnterDate"].ToString().Substring(0, 10);
                    this.txtDeliverMan.Text        = dtLog.Rows[0]["cnvcDeliverMan"].ToString();
                    this.txtValidateOper.Text      = dtLog.Rows[0]["cnvcValidateOperID"].ToString();
                    this.txtSafeOper.Text          = dtLog.Rows[0]["cnvcSafeOperID"].ToString();
                    this.txtStorageOper.Text       = dtLog.Rows[0]["cnvcStorageOperID"].ToString();
                    this.txtBillOper.Text          = dtLog.Rows[0]["cnvcBillOperID"].ToString();
                    this.ddlProvider.Enabled       = false;
                    this.ddlEnterType.Enabled      = false;
                    this.txtDeliverMan.Enabled     = false;
                    this.txtValidateOper.Enabled   = false;
                    this.txtSafeOper.Enabled       = false;
                    this.txtStorageOper.Enabled    = false;
                    this.txtBillOper.Enabled       = false;
                    this.btnEnterNew.Enabled       = false;
                    this.txtMaterialFilter.Enabled = false;

                    this.ddlProduct.Enabled      = false;
                    this.txtStandardUnit.Enabled = false;
                    this.txtPrice.Enabled        = false;
                    this.txtCount.Enabled        = false;
                    this.txtSum.Enabled          = false;
                    this.btnAdd.Enabled          = false;
                    if (this.ddlEnterType.SelectedItem.Text == "采购入库")
                    {
                        this.btnPrint.Enabled = true;
                    }
                    else
                    {
                        this.btnPrint.Enabled = false;
                    }

                    this.DataGrid1.DataSource = dtDetail;
                    this.DataGrid1.DataBind();

                    this.DataGrid1.Columns[this.DataGrid1.Columns.Count - 1].Visible = false;
                }
            }
            else
            {
                strBeginDate = Request.Form["txtBegin"].ToString();
            }
        }