Exemplo n.º 1
0
    /// <summary>
    /// 設定頁面載入時,各個模式的畫面預設值

    /// </summary>
    private void SetPageStartValue()
    {
        #region 新增狀態

        if (this.hid_PageStatus.Value == "INSERT")
        {
            #region Tab_Up
            #region 設定初始值
            if (this.slp_up_CHAN_NO.Text == string.Empty ||
                this.slp_up_STORE.Text == string.Empty ||
                this.slp_up_SALE_ID.Text == string.Empty ||
                this.slp_up_Z_O.Text == string.Empty)
            {
                this.slp_up_CHAN_NO.Text = string.Empty;//通路
                this.slp_up_STORE.Text = string.Empty;//門市
                this.slp_up_Z_O.Text = string.Empty;//營業所
                this.slp_up_SALE_ID.Text = string.Empty;//營業人員
            }

            #region 設定訂單來源

            DataTable dt_Return = new DataTable();
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());//V_USERCODE
            ParameterList.Add(Session["UID"].ToString());//V_LOG_UPDATEUID

            BCO.MaintainCRMPublic bco = new BCO.MaintainCRMPublic(ConntionDB);
            dt_Return = bco.QUERY_LOGIN_CODEANDNAME(ParameterList);

            if (dt_Return.Rows.Count == 0 ||
                dt_Return.Rows[0]["NAME"].ToString() != "顧客服務Team")//訂單來源
            { ((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).SelectedValue = "0"; }
            else
            { ((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).SelectedValue = "1"; }

            #endregion

            this.slp_up_BUSUID.Text = Session["UID"].ToString();//訂單維護者
            this.slp_up_BUSDATE.Text = DateTime.Today.ToString("yyyy/MM/dd");//DateTime.Now.ToShortDateString();//訂單日期


            this.txt_up_PO_SOURCE_NO.Text = string.Empty;//PO單號預設
            this.txt_up_CODE.Text = "自動產生";//訂單編號
            this.txt_up_CRM_NO.Text = string.Empty;//流水編號
            slp_up_Z_O.ReadOnly = true;
            txt_up_CODE.Enabled = false;

            if (this.slp_up_CHAN_NO.Text != string.Empty && this.slp_up_STORE.Text != string.Empty)
            {
                #region 從資料庫查詢資料

                // ArrayList ParameterList = new ArrayList();//20091117

                ParameterList.Clear();
                ParameterList.Add(this.slp_up_STORE.Text);//門市
                ParameterList.Add(this.slp_up_CHAN_NO.Text);//通路
                ParameterList.Add(Session["UID"].ToString());
                //2009-06-01 cyhsu add 新增記錄 STORE and CHAN_NO
                s_CHAN_NO = this.slp_up_CHAN_NO.Text;
                s_STORE = this.slp_up_STORE.Text;

                //DataTable dt_Return = new DataTable();
                BCO.MaintainStore bco1 = new BCO.MaintainStore(ConntionDB);
                dt_Return = bco1.QUERY_STORE_BY_STOREANDCHAN(ParameterList);
                if (dt_Return.Rows.Count == 0)
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "CRM041.aspx",
                        "alert('查無門市資料');document.getElementById('" +
                        this.slp_up_STORE.TextBox_Code.ClientID +
                        "').focus();document.getElementById('" +
                        this.slp_up_STORE.TextBox_Code.ClientID + "').select();", true);
                }
                else
                {
                    if (this.hid_PageStatus.Value == "INSERT")
                    {
                        if (dt_Return.Rows[0]["MDC_END_DATE"].ToString() != string.Empty &&
                            ((DateTime)dt_Return.Rows[0]["MDC_END_DATE"]) < DateTime.Today)
                        {
                            throw new Exception("非有效門市,不可新增");
                        }
                    }
                    slp_up_CHAN_NO.Text = dt_Return.Rows[0]["CHAN_NO"].ToString();
                    slp_up_Z_O.Text = dt_Return.Rows[0]["Z_O"].ToString();
                    slp_up_SALE_ID.Text = dt_Return.Rows[0]["SAL_ID"].ToString();

                    #region 取得通路PO控制設定

                    GetChainPOSetting(dt_Return.Rows[0]["CHAN_NO"].ToString(),
                                      dt_Return.Rows[0]["STORE"].ToString());

                    #endregion

                    dt_Return.Dispose();
                }
                #endregion
            }
            #endregion

            #endregion
        }

        #endregion

        #region 查詢狀態

        else if (this.hid_PageStatus.Value == "QUERY")
        {
            #region Tab_Up

            #region 設定初始值

            this.slp_up_CHAN_NO.Text = string.Empty;//通路
            this.slp_up_STORE.Text = string.Empty;//門市
            this.slp_up_Z_O.Text = string.Empty;//營業所
            this.slp_up_BUSDATE.Text = string.Empty;//訂單日期
            this.slp_up_SALE_ID.Text = string.Empty;//營業人員
            this.slp_up_BUSUID.Text = string.Empty;//訂單維護者
            ((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).SelectedIndex = 0;//訂單來源
            this.txt_up_PO_SOURCE_NO.Text = string.Empty;//PO單號預設
            this.txt_up_CODE.Enabled = true;
            this.txt_up_CODE.Text = string.Empty;//訂單編號
            this.txt_up_CRM_NO.Text = string.Empty;//流水編號

            #endregion

            #endregion
        }

        #endregion

        #region 檢視狀態

        else if (this.hid_PageStatus.Value == "VIEW")
        { }

        #endregion

        #region 編輯狀態

        else if (this.hid_PageStatus.Value == "EDIT")
        {
            this.gv_Detail.DataSource = dt_Detail;
            this.gv_Detail.PageSize = 10;
            this.gv_Detail.PageIndex = 0;
            this.gv_Detail.DataBind();
            Panel1.Height = gv_Detail.Rows.Count * 45 + 60;
        }

        #endregion

        if (this.hid_PageStatus.Value == "INSERT")
        {
            DropDownList DL = ((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1"));
            if (DL.SelectedValue == "全部")
            {
                DL.Items.Remove(DL.SelectedItem);
            }
            //((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).Items.RemoveAt(0);
        }
        else if (this.hid_PageStatus.Value == "QUERY")
        {
            if (((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).Items.Count != 0)
                if (((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).Items[0].Value != "")
                    ((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).Items.Insert(0, new ListItem("全部", ""));
            ((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).SelectedIndex = 0;
        }
        try
        {
            AuthorityControls(this);
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
    }