Exemplo n.º 1
0
    private void QueryData(string v_store, string v_date)
    {
        try
        {
            #region 將變數資料清空

            ds_Data.Tables.Clear();

            //ds_Data.Clear();

            #endregion

            #region 門市基本、配送屬性
            STMModel.MaintainStoreBase BCO = new STMModel.MaintainStoreBase(ConnectionDB);

            DataTable Dt;
            ParameterList.Clear();

            ParameterList.Add(v_store);
            ParameterList.Add(DateTime.Parse(v_date.Trim()).ToString("yyyy/MM/dd"));
            ParameterList.Add(DateTime.Parse(v_date.Trim()).ToString("yyyy/MM/dd"));
            for (int i = 0; i <= 34; i++)
            {
                ParameterList.Add(null);
            }
            ParameterList.Add(">=");
            for (int i = 0; i <= 9; i++)
            {
                ParameterList.Add(null);
            }
            ParameterList.Add(">=");
            for (int i = 0; i <= 16; i++)
            {
                ParameterList.Add(null);
            }

            ParameterList.Add(null);

            Dt = BCO.QuerySwitch(STMModel.MaintainStoreBase.QueryType.QueryByLike, ParameterList);

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
                return;
            }

            #region 取得畫面元件的值

            TextBox txt_TELAREA = (TextBox)this.SLP_TEL_NO.FindControl("T1");
            TextBox txt_TELNO = (TextBox)this.SLP_TEL_NO.FindControl("T2");
            TextBox txt_FAXAREA = (TextBox)this.SLP_FAX_NO.FindControl("T1");
            TextBox txt_FAXNO = (TextBox)this.SLP_FAX_NO.FindControl("T2");

            CheckBox rdo_DIS_SW = (CheckBox)this.SLP_DIS_SW.FindControl("C1");
            CheckBox rdo_MARKET_RESEARCH = (CheckBox)this.SLP_MARKET_RESEARCH.FindControl("C1");
            CheckBox rdo_SING_VEN = (CheckBox)this.SLP_SING_VEN.FindControl("C1");
            RadioButtonList rdo_MDC_TAXABLE = (RadioButtonList)this.SLP_MDC_TAXABLE.FindControl("R1");
            RadioButtonList rdo_MDC_TAXFREE = (RadioButtonList)this.SLP_MDC_TAXFREE.FindControl("R1");

            CheckBox chk_W1 = (CheckBox)this.SLP_Boolean1.FindControl("C1");
            CheckBox chk_W2 = (CheckBox)this.SLP_Boolean2.FindControl("C1");
            CheckBox chk_W3 = (CheckBox)this.SLP_Boolean3.FindControl("C1");
            CheckBox chk_W4 = (CheckBox)this.SLP_Boolean4.FindControl("C1");
            CheckBox chk_W5 = (CheckBox)this.SLP_Boolean5.FindControl("C1");
            CheckBox chk_W6 = (CheckBox)this.SLP_Boolean6.FindControl("C1");
            CheckBox chk_W7 = (CheckBox)this.SLP_Boolean7.FindControl("C1");

            #endregion

            this.txtSTORE.Text = Dt.Rows[0]["STORE"].ToString();
            this.txtSTORE_NAME.Text = Dt.Rows[0]["STORE_NAME"].ToString();
            this.SLP_MDC_START_DATE.Text = Dt.Rows[0]["MDC_START_DATE"].ToString();
            this.SLP_MDC_END_DATE.Text = Dt.Rows[0]["MDC_END_DATE"].ToString();
            this.SLP_CHAN_NO.Text = Dt.Rows[0]["CHAN_NO"].ToString();
            this.SLP_GROUP_NO.Text = Dt.Rows[0]["GROUP_NO"].ToString();
            this.txtOLD_STORE.Text = Dt.Rows[0]["OLD_STORE"].ToString();
            this.SLP_STORE_OPEN_DATE.Text = Dt.Rows[0]["STORE_OPEN_DATE"].ToString();
            this.SLP_STORE_CLOSE_DATE.Text = Dt.Rows[0]["STORE_CLOSE_DATE"].ToString();
            this.SLP_REOPEN_DATE.Text = Dt.Rows[0]["REOPEN_DATE"].ToString();
            this.SLP_REMODEL_DATE.Text = Dt.Rows[0]["REMODEL_DATE"].ToString();
            this.SLP_Z_O.Text = Dt.Rows[0]["Z_O"].ToString();
            this.SLP_D_O.Text = Dt.Rows[0]["D_O"].ToString();
            this.SLP_STORE_TYPE.Text = Dt.Rows[0]["STORE_TYPE"].ToString();
            this.txtSTORE_ZIP.Text = Dt.Rows[0]["STORE_ZIP"].ToString();
            txt_TELAREA.Text = Dt.Rows[0]["STORE_TEL_AREA"].ToString();
            txt_TELNO.Text = Dt.Rows[0]["STORE_TEL_NO"].ToString();
            txt_FAXAREA.Text = Dt.Rows[0]["STORE_FAX_AREA"].ToString();
            txt_FAXNO.Text = Dt.Rows[0]["STORE_FAX_NO"].ToString();
            this.txtSTORE_ADDRESS.Text = Dt.Rows[0]["STORE_ADDRESS"].ToString();
            this.txtVIRTUAL_FLAG.Text = Dt.Rows[0]["VIRTUAL_FLAG"].ToString();

            this.SLP_AREA_NO.Text = Dt.Rows[0]["AREA_NO"].ToString();
            this.SLP_AREA_CODE.Text = Dt.Rows[0]["AREA_CODE"].ToString();
            this.SLP_SHELVE_CM3.Text = Dt.Rows[0]["SHELVE_CM3"].ToString();
            if (Dt.Rows[0]["DIS_SW"].ToString() == "1")
                this.SLP_DIS_SW.Text = "1";
            //rdo_DIS_SW.Checked = true;
            else
                this.SLP_DIS_SW.Text = "0";
            //rdo_DIS_SW.Checked = false;
            this.SLP_ALLOCATION_TIMES.Text = Dt.Rows[0]["ALLOCATION_TIMES"].ToString();
            if (Dt.Rows[0]["MARKET_RESEARCH"].ToString() == "1")
                this.SLP_MARKET_RESEARCH.Text = "1";
            //rdo_MARKET_RESEARCH.Checked = true;
            else
                this.SLP_MARKET_RESEARCH.Text = "0";
            //rdo_MARKET_RESEARCH.Checked = false;
            this.SLP_AC_UID.Text = Dt.Rows[0]["AC_UID"].ToString();
            this.SLP_SAL_ID.Text = Dt.Rows[0]["SAL_ID"].ToString();
            this.SLP_FEAT_GRADE.Text = Dt.Rows[0]["FEAT_GRADE"].ToString();
            this.txtPAY_RFNO.Text = Dt.Rows[0]["PAY_RFNO"].ToString();
            if (Dt.Rows[0]["SING_VEN"].ToString() == "1")
                //rdo_SING_VEN.Checked = true;
                this.SLP_SING_VEN.Text = "1";
            else
                //rdo_SING_VEN.Checked = false;
                this.SLP_SING_VEN.Text = "0";
            MDC_TAXABLE_ID = Dt.Rows[0]["MDC_TAXABLE"].ToString();
            MDC_TAXFREE_ID = Dt.Rows[0]["MDC_TAXFREE"].ToString();
            SLP_CREATE_DATE.Text = Dt.Rows[0]["CREATEDATE"].ToString();
            SLP_CREATE_UID.Text = Dt.Rows[0]["CREATEUID"].ToString();
            SLP_UPDATE_DATE.Text = Dt.Rows[0]["UPDATEDATE"].ToString();
            SLP_UPDATE_UID.Text = Dt.Rows[0]["UPDATEUID"].ToString();
            txtEFF_DATE_TO.Text = Dt.Rows[0].IsNull("EFF_DATE_TO") ? "" : Convert.ToDateTime(Dt.Rows[0]["EFF_DATE_TO"]).ToShortDateString();
            #endregion

            #region 屬性
            STMModel.MaintainStoreProperty BCO_Property = new STMModel.MaintainStoreProperty(ConnectionDB);

            DataTable Dt_Property;
            ParameterList.Clear();

            ParameterList.Add(v_store);

            Dt_Property = BCO_Property.QuerySwitch(STMModel.MaintainStoreProperty.QueryType.CODE, ParameterList);

            if (Dt_Property != null && Dt_Property.Rows.Count > 0)
            {
                this.txtCOPY_SOURCE.Text = Dt_Property.Rows[0]["COPY_SOURCE"].ToString();
                this.SLP_PSM.Text = Dt_Property.Rows[0]["PSM"].ToString();
                this.SLP_BUSINESS_NO.Text = Dt_Property.Rows[0]["BUSINESS_NO"].ToString();
                this.SLP_OPEN_TIME.Text = Dt_Property.Rows[0]["OPEN_TIME"].ToString();
                this.SLP_CLOSE_TIME.Text = Dt_Property.Rows[0]["CLOSE_TIME"].ToString();
                this.SLP_COMPETITION.Text = Dt_Property.Rows[0]["COMPETITION"].ToString();
                this.SLP_REMARK.Text = Dt_Property.Rows[0]["REMARK"].ToString();
                this.SLP_STORE_SPE.Text = Dt_Property.Rows[0]["STORE_SPE"].ToString();
                if (Dt_Property.Rows[0]["BUSINESS_W1"].ToString() == "1")
                    this.SLP_Boolean1.Text = "1";
                //chk_W1.Checked = true;
                else
                    //chk_W1.Checked = false;
                    this.SLP_Boolean1.Text = "0";
                if (Dt_Property.Rows[0]["BUSINESS_W2"].ToString() == "1")
                    this.SLP_Boolean2.Text = "1";
                //chk_W2.Checked = true;
                else
                    this.SLP_Boolean2.Text = "0";
                //chk_W2.Checked = false;
                if (Dt_Property.Rows[0]["BUSINESS_W3"].ToString() == "1")
                    this.SLP_Boolean3.Text = "1";
                // chk_W3.Checked = true;
                else
                    this.SLP_Boolean3.Text = "0";
                //chk_W3.Checked = false;
                if (Dt_Property.Rows[0]["BUSINESS_W4"].ToString() == "1")
                    this.SLP_Boolean4.Text = "1";
                //chk_W4.Checked = true;
                else
                    this.SLP_Boolean4.Text = "0";
                //chk_W4.Checked = false;
                if (Dt_Property.Rows[0]["BUSINESS_W5"].ToString() == "1")
                    this.SLP_Boolean5.Text = "1";
                //chk_W5.Checked = true;
                else
                    this.SLP_Boolean5.Text = "0";
                //chk_W5.Checked = false;
                if (Dt_Property.Rows[0]["BUSINESS_W6"].ToString() == "1")
                    this.SLP_Boolean6.Text = "1";
                //chk_W6.Checked = true;
                else
                    this.SLP_Boolean6.Text = "0";
                //chk_W6.Checked = false;
                if (Dt_Property.Rows[0]["BUSINESS_W7"].ToString() == "1")
                    this.SLP_Boolean7.Text = "1";
                // chk_W7.Checked = true;
                else
                    this.SLP_Boolean7.Text = "0";
                //chk_W7.Checked = false;          
            }

            #endregion

            #region 貨架設置
            STMModel.MaintainStoreShelf BCO_Shelf = new STMModel.MaintainStoreShelf(ConnectionDB);

            DataTable Dt_Shelf;
            ParameterList.Clear();

            ParameterList.Add(v_store);

            Dt_Shelf = BCO_Shelf.QuerySwitch(STMModel.MaintainStoreShelf.QueryType.STORE, ParameterList);

            GridView1.DataSource = Dt_Shelf;

            //設定分頁大小
            //   GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            GridView1.PageIndex = 0;
            GridView1.DataBind();
            GridView1.Visible = true;

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                return;
            }

            #endregion

            #region 路線、路順、到店時間
            STMModel.MaintainStoreBase STM = new STMModel.MaintainStoreBase(ConntionDB);

            ParameterList.Clear();
            ParameterList.Add(SLP_CHAN_NO.Text.Trim());//通路
            ParameterList.Add(txtSTORE.Text.Trim());//門市

            DataTable dt = STM.GetRouteInfo(ParameterList);
            if (dt.Rows.Count == 1)
            {
                SLP_ROUTE_ID.Text = dt.Rows[0]["ROUTE"].ToString();
                SLP_ROUTE_STEP.Text = dt.Rows[0]["STEP"].ToString();
                SLP_ROUTE_ARRIVE_TIME.Text = dt.Rows[0]["ARRIVE_TIME"].ToString();
            }
            #endregion

            #region 取得審核狀態
            lblARMK.Text = Dt.Rows[0]["STORE_ARMK"].ToString();
            #endregion

            #region 將資料寫入變數

            Dt.TableName = "VDS_STM_STORE";
            Dt_Property.TableName = "VDS_STM_STORE_PROPERTY";
            Dt_Shelf.TableName = "VDS_STM_STORE_SHELF";

            ds_Data.Tables.Add(Dt.Copy());
            ds_Data.Tables.Add(Dt_Property.Copy());
            ds_Data.Tables.Add(Dt_Shelf.Copy());

            DataSet ds = new DataSet();
            ds.Tables.Add(Dt_Shelf.Copy());
            DataColumn[] keys = new DataColumn[2];
            keys[0] = ds.Tables[0].Columns["STORE"];
            keys[1] = ds.Tables[0].Columns["SHELF_NO"];
            ds.Tables[0].PrimaryKey = keys;
            Session["STM012_" + PageTimeStamp.Value] = ds;
            Session["Report_" + PageTimeStamp.Value] = ds.Tables["VDS_STM_STORE"];
            #endregion

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { }
    }
Exemplo n.º 2
0
    protected void txtSTORE_TextChanged(object sender, EventArgs e)
    {
        #region 取得屬性,貨架設置資料
        string mode = "";
        mode = Request.QueryString["mode"].ToString();
        if (mode == "insert")
        {
            #region 屬性
            if (this.txtCOPY_SOURCE.Text.Trim().Length == 0 && this.SLP_PSM.Text.Trim().Length == 0 && this.SLP_BUSINESS_NO.Text.Trim().Length == 0 &&
                this.SLP_OPEN_TIME.Text.Trim().Length == 0 && this.SLP_CLOSE_TIME.Text.Trim().Length == 0)
            {
                CheckBox chk_W1 = (CheckBox)this.SLP_Boolean1.FindControl("C1");
                CheckBox chk_W2 = (CheckBox)this.SLP_Boolean2.FindControl("C1");
                CheckBox chk_W3 = (CheckBox)this.SLP_Boolean3.FindControl("C1");
                CheckBox chk_W4 = (CheckBox)this.SLP_Boolean4.FindControl("C1");
                CheckBox chk_W5 = (CheckBox)this.SLP_Boolean5.FindControl("C1");
                CheckBox chk_W6 = (CheckBox)this.SLP_Boolean6.FindControl("C1");
                CheckBox chk_W7 = (CheckBox)this.SLP_Boolean7.FindControl("C1");

                STMModel.MaintainStoreProperty BCO_Property = new STMModel.MaintainStoreProperty(ConnectionDB);

                DataTable Dt_Property;
                ParameterList.Clear();
                ParameterList.Add(txtSTORE.Text);

                Dt_Property = BCO_Property.QuerySwitch(STMModel.MaintainStoreProperty.QueryType.CODE, ParameterList);

                if (Dt_Property != null && Dt_Property.Rows.Count > 0)
                {
                    this.txtCOPY_SOURCE.Text = Dt_Property.Rows[0]["COPY_SOURCE"].ToString();
                    this.SLP_PSM.Text = Dt_Property.Rows[0]["PSM"].ToString();
                    this.SLP_BUSINESS_NO.Text = Dt_Property.Rows[0]["BUSINESS_NO"].ToString();
                    this.SLP_OPEN_TIME.Text = Dt_Property.Rows[0]["OPEN_TIME"].ToString();
                    this.SLP_CLOSE_TIME.Text = Dt_Property.Rows[0]["CLOSE_TIME"].ToString();
                    this.SLP_COMPETITION.Text = Dt_Property.Rows[0]["COMPETITION"].ToString();
                    this.SLP_REMARK.Text = Dt_Property.Rows[0]["REMARK"].ToString();
                    this.SLP_STORE_SPE.Text = Dt_Property.Rows[0]["STORE_SPE"].ToString();
                    if (Dt_Property.Rows[0]["BUSINESS_W1"].ToString() == "1")
                        chk_W1.Checked = true;
                    else
                        chk_W1.Checked = false;
                    if (Dt_Property.Rows[0]["BUSINESS_W2"].ToString() == "1")
                        chk_W2.Checked = true;
                    else
                        chk_W2.Checked = false;
                    if (Dt_Property.Rows[0]["BUSINESS_W3"].ToString() == "1")
                        chk_W3.Checked = true;
                    else
                        chk_W3.Checked = false;
                    if (Dt_Property.Rows[0]["BUSINESS_W4"].ToString() == "1")
                        chk_W4.Checked = true;
                    else
                        chk_W4.Checked = false;
                    if (Dt_Property.Rows[0]["BUSINESS_W5"].ToString() == "1")
                        chk_W5.Checked = true;
                    else
                        chk_W5.Checked = false;
                    if (Dt_Property.Rows[0]["BUSINESS_W6"].ToString() == "1")
                        chk_W6.Checked = true;
                    else
                        chk_W6.Checked = false;
                    if (Dt_Property.Rows[0]["BUSINESS_W7"].ToString() == "1")
                        chk_W7.Checked = true;
                    else
                        chk_W7.Checked = false;
                }
            }
            #endregion

            #region 貨架設置
            if (txtSTORE.Text.Trim().Length != 0 && GridView1.Rows.Count == 0)
            {
                STMModel.MaintainStoreShelf BCO_Shelf = new STMModel.MaintainStoreShelf(ConnectionDB);

                DataTable Dt_Shelf;
                ParameterList.Clear();

                ParameterList.Add(txtSTORE.Text);

                Dt_Shelf = BCO_Shelf.QuerySwitch(STMModel.MaintainStoreShelf.QueryType.STORE, ParameterList);

                GridView1.DataSource = Dt_Shelf;

                GridView1.PageIndex = 0;
                GridView1.DataBind();

                DataSet ds = new DataSet();
                ds.Tables.Add(Dt_Shelf.Copy());
                DataColumn[] keys = new DataColumn[2];
                keys[0] = ds.Tables[0].Columns["STORE"];
                keys[1] = ds.Tables[0].Columns["SHELF_NO"];
                ds.Tables[0].PrimaryKey = keys;
                Session["STM012_" + PageTimeStamp.Value] = ds;

            }
            else
            {
                DataSet ds = (DataSet)Session["STM012_" + PageTimeStamp.Value];

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr.RowState != DataRowState.Deleted)
                    {
                        dr.BeginEdit();
                        dr["CODE"] = txtSTORE.Text + dr["SHELF_NO"].ToString();
                        dr["NAME"] = txtSTORE_NAME.Text;
                        dr["STORE"] = txtSTORE.Text;
                        dr.EndEdit();
                    }
                }
            }
            #endregion
        }
        #endregion
    }