Пример #1
0
        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;
            }
            this.txtUnit.Enabled = false;
            string    strMoveID = Request.QueryString["ID"];
            Hashtable htapp     = (Hashtable)Application["appconf"];
            string    strcons   = (string)htapp["cons"];

            StoBusi = new BusiComm.StorageBusi(strcons);
            if (!IsPostBack)
            {
                if (strMoveID == "" || strMoveID == null)
                {
                    strBeginDate        = DateTime.Now.ToShortDateString();
                    this.btnAdd.Enabled = true;
                    this.FillDropDownList("NewDept", this.ddlInDept, "vcCommSign='SalesRoom'");
                    this.FillDropDownList("NewDept", this.ddlOutDept, "vcCommSign='SalesRoom'");
                    this.FillDropDownList("Goods", this.ddlProduct);

                    string strProductCode = this.ddlProduct.SelectedValue;
                    try
                    {
                        string strUnit = StoBusi.GetGoodsUnit(strProductCode);
                        if (strUnit == null || strUnit == "")
                        {
                            this.txtUnit.Text = "不存在";
                        }
                        else
                        {
                            this.txtUnit.Text = strUnit;
                        }
                    }
                    catch (Exception er)
                    {
                        this.clog.WriteLine(er);
                        this.SetErrorMsgPageBydir("查询错误,请重试!");
                        return;
                    }

                    DataTable dtout = new DataTable();
                    dtout.Columns.Add("cnvcProductCode");
                    dtout.Columns.Add("cnvcProductName");
                    dtout.Columns.Add("cnvcUnit");
                    dtout.Columns.Add("cnnMoveCount");
                    dtout.Columns.Add("cnnLoseCount");
                    dtout.Columns.Add("cnnRealMoveCount");
                    dtout.Columns.Add("cnvcComments");
                    Session["MoveDetail"]     = dtout;
                    this.DataGrid1.DataSource = dtout;
                    this.DataGrid1.DataBind();
                    this.DataGrid1.Columns[5].Visible = false;
                    this.DataGrid1.Columns[6].Visible = false;
                    this.DataGrid1.Columns[7].Visible = false;
                    this.btnPrint.Enabled             = false;
                    this.txtInOperID.Enabled          = false;
                }
                else
                {
                    this.txtMoveID.Text = strMoveID;
                    this.btnAdd.Enabled = false;
                    this.FillDropDownList("NewDept", this.ddlInDept, "vcCommSign='SalesRoom'");
                    this.FillDropDownList("NewDept", this.ddlOutDept, "vcCommSign='SalesRoom'");
                    DataSet   dsout    = StoBusi.GetMoveOneLog(strMoveID);
                    DataTable dtLog    = dsout.Tables["MoveLog"];
                    DataTable dtDetail = dsout.Tables["MoveDetail"];
                    Session["MoveDetail"] = dtDetail;

                    this.ddlInDept.SelectedIndex  = this.ddlInDept.Items.IndexOf(this.ddlInDept.Items.FindByValue(dtLog.Rows[0]["cnvcInDeptID"].ToString()));
                    this.ddlOutDept.SelectedIndex = this.ddlOutDept.Items.IndexOf(this.ddlOutDept.Items.FindByValue(dtLog.Rows[0]["cnvcOutDeptID"].ToString()));

                    Session.Remove("BillPrint");
                    DataSet dsprint = new DataSet("面包工坊调拨单");
                    dtLog.Rows[0]["cnvcInDeptID"]  = this.ddlInDept.SelectedItem.Text;
                    dtLog.Rows[0]["cnvcOutDeptID"] = this.ddlOutDept.SelectedItem.Text;
                    dsprint.Tables.Add(dtLog.Copy());
                    dsprint.Tables.Add(dtDetail.Copy());
                    Session["BillPrint"] = dsprint;

                    strBeginDate              = dtLog.Rows[0]["cndMoveDate"].ToString();
                    this.txtInOperID.Text     = dtLog.Rows[0]["cnvcInOperID"].ToString();
                    this.txtOutOperID.Text    = dtLog.Rows[0]["cnvcOutOperID"].ToString();
                    this.txtBillState.Text    = dtLog.Rows[0]["cnvcBillState"].ToString();
                    this.ddlInDept.Enabled    = false;
                    this.ddlOutDept.Enabled   = false;
                    this.txtOutOperID.Enabled = false;

                    this.ddlProduct.Enabled  = false;
                    this.txtCount.Enabled    = false;
                    this.txtComments.Enabled = false;
                    this.btnPrint.Enabled    = true;

                    switch (this.txtBillState.Text.Trim())
                    {
                    case "0":
                        this.btnMoveNew.Text = "调拨单-收货";
                        ((BoundColumn)this.DataGrid1.Columns[4]).ReadOnly = true;
                        this.DataGrid1.Columns[8].Visible = false;
                        this.btnMoveNew.Attributes.Add("onclick", "return confirm('请确认你已经正确填写了\"损耗量和实际数量\",并要进行本调拨单收货确认。\\n\\n确认收货?');");
                        break;

                    case "1":
                        this.btnMoveNew.Text              = "调拨单";
                        this.btnMoveNew.Enabled           = false;
                        this.txtInOperID.ReadOnly         = false;
                        this.DataGrid1.Columns[7].Visible = false;
                        this.DataGrid1.Columns[8].Visible = false;
                        break;
                    }

                    this.DataGrid1.DataSource = dtDetail;
                    this.DataGrid1.DataBind();
                }
            }
            else
            {
                strBeginDate = Request.Form["txtBegin"].ToString();
            }
        }