Exemple #1
0
    /// <summary>
    /// 繫結資料到控制項
    /// </summary>
    /// <param name="vdb"></param>
    private void databind()
    {
        
        #region

        //抓取本頁初次登記的時間

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        STMModel.MaintainPromoteExhibition BCO = new STMModel.MaintainPromoteExhibition(ConnectionDB);

        ParameterList.Clear();

        //檔期活動
        ParameterList.Add(DBNull.Value);
        ParameterList.Add(GetValueSetParameter(this.txtPROMOTE_ID.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtPROMOTE_NAME.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_PROMOTE_MONTH.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCT_MONTH.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_COL_DAYS.Text, "string", false));
        ParameterList.Add(DBNull.Value);  //V_COL_DAYS_EXPLAIN
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCEPT_DATE_START.StartDate,"string",false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCEPT_DATE_START.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCEPT_DATE_END.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCEPT_DATE_END.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCEPT_FIRST_DATE.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ACCEPT_FIRST_DATE.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_RETURN_DATE_START.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_RETURN_DATE_START.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_RETURN_DATE_END.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_RETURN_DATE_END.EndDate, "string", false));
        if (this.ddlPROMOTE_TYPE.SelectedValue == "0")
            ParameterList.Add(DBNull.Value);
        else
            ParameterList.Add(this.ddlPROMOTE_TYPE.SelectedValue.ToString());
        ParameterList.Add(DBNull.Value);  //V_PROMOTE_TYPE_EXPLAIN
        if (this.ddlDISCOUNT_TYPE.SelectedValue == "0") 
            ParameterList.Add(DBNull.Value);
        else
            ParameterList.Add(this.ddlDISCOUNT_TYPE.SelectedValue.ToString());
        ParameterList.Add(DBNull.Value);  //V_DISCOUNT_TYPE_EXPLAIN
        ParameterList.Add(GetValueSetParameter(this.SLP_NOTES.Text, "string", false));  //N_NOTES
        ParameterList.Add(DBNull.Value);
        ParameterList.Add(((DropDownList)SLP_PRICE_SUBSIDY_PERCENT.FindControl("D1")).SelectedItem.Text);
        ParameterList.Add(GetValueSetParameter(this.SLP_PRICE_SUBSIDY_PERCENT.Text, "Decimal", CheckBoxLikeSearch.Checked));
        ParameterList.Add(((DropDownList)SLP_COST_SUBSIDY_PERCENT.FindControl("D1")).SelectedItem.Text);
        ParameterList.Add(GetValueSetParameter(this.SLP_COST_SUBSIDY_PERCENT.Text, "Decimal", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter("", "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(DBNull.Value);  //V_AC_UNAME
        if (this.SLP_CONFIRM_CODE.Text == "")
           ParameterList.Add(DBNull.Value);
        else
           ParameterList.Add(GetValueSetParameter(this.SLP_CONFIRM_CODE.Text, "string", false));
        ParameterList.Add(DBNull.Value); //V_CONFIRM_CODE_EXPLAIN
        ParameterList.Add(DBNull.Value);  //N_DISCOUNT_KIND
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_DATE.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_DATE.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_UID.Text, "string", false));
        ParameterList.Add(DBNull.Value);  //V_CREATEUNAME
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_DATE.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_DATE.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_UID.Text, "string", false));
        ParameterList.Add(DBNull.Value);  //V_UPDATEUNAME
       
        //折扣設定
        ParameterList.Add(GetValueSetParameter(this.SLP_GROUP_NO.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_ITEM.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_PERIOD.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_COST_SUBSIDY_PERCENT2.Text, "Decimal", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_PRICE_SUBSIDY_PERCENT2.Text, "Decimal", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_DATE2.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_DATE2.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_UID2.Text, "string", false));
        ParameterList.Add(DBNull.Value);  //V_CREATEUNAME
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_DATE2.StartDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_DATE2.EndDate, "string", false));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_UID2.Text, "string", false));
        ParameterList.Add(DBNull.Value);  //V_UPDATEUNAME
        ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false));
   
        DataTable Dt = BCO.QuerySwitch(STMModel.MaintainPromoteExhibition.QueryType.QueryByLike , ParameterList);
        
        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;

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

        LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString());

        if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
        {
            ErrorMsgLabel.Text = "查無資料";
        }

        #region 將Key值存到Session中

        ArrayList arl_Key = new ArrayList();

        foreach (DataRow drRow in Dt.Rows)
        { arl_Key.Add("promote_id=" + drRow["PROMOTE_ID"].ToString()); }

        Session["STM272_SortKey" + this.PageTimeStamp.Value] = arl_Key;

        #endregion

        #endregion
    }//databind
Exemple #2
0
    private void QueryData(string v_promote_id)
    {
        bool AuthUpdateSTM22 = false;

        try
        {
            #region 將變數資料清空

            ds_Data.Tables.Clear();

            #endregion

            #region 檔期活動
            STMModel.MaintainPromoteExhibition BCO = new STMModel.MaintainPromoteExhibition(ConnectionDB);

            DataTable Dt;
            ParameterList.Clear();

            ParameterList.Add(null);
            ParameterList.Add(v_promote_id);
            for (int i = 2; i <= 53; i++)
            {
                if ((i == 23) || (i == 25))
                    ParameterList.Add(">=");
                else
                    ParameterList.Add(null);
            }
            ParameterList.Add("1");

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

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

            this.txtPROMOTE_ID.Text = Dt.Rows[0]["PROMOTE_ID"].ToString();
            this.txtPROMOTE_NAME.Text = Dt.Rows[0]["PROMOTE_NAME"].ToString();
            this.txtPROMOTE_MONTH.Text = Dt.Rows[0]["PROMOTE_MONTH"].ToString();
            this.txtACCT_MONTH.Text = Dt.Rows[0]["ACCT_MONTH"].ToString();
            this.SLP_COL_DAYS.Text = Dt.Rows[0]["COL_DAYS"].ToString();
            this.SLP_ACCEPT_DATE_START.Text = Dt.Rows[0]["ACCEPT_DATE_START"].ToString();
            this.SLP_ACCEPT_DATE_END.Text = Dt.Rows[0]["ACCEPT_DATE_END"].ToString();
            this.SLP_ACCEPT_FIRST_DATE.Text = Dt.Rows[0]["ACCPET_FIRST_DATE"].ToString();
            this.hdfACCEPT_FIRST_DATE.Value = Dt.Rows[0]["ACCPET_FIRST_DATE"].ToString();
            this.SLP_RETURN_DATE_START.Text = Dt.Rows[0]["RETURN_DATE_START"].ToString();
            this.SLP_RETURN_DATE_END.Text = DateTime.Parse(Dt.Rows[0]["RETURN_DATE_END"].ToString()).ToString("yyyy/MM/dd");
            if (Dt.Rows[0]["CONFIRM_CODE"].ToString() == "1")
                this.txtCONFIRM_CODE.Text = "已審核";
            else
                this.txtCONFIRM_CODE.Text = "未審核";

            this.ddlPROMOTE_TYPE.SelectedValue = Dt.Rows[0]["PROMOTE_TYPE"].ToString();
            this.ddlDISCOUNT_TYPE.SelectedValue = Dt.Rows[0]["DISCOUNT_TYPE"].ToString();
            this.SLP_NOTES.Text = Dt.Rows[0]["NOTES"].ToString();
            this.SLP_PRICE_SUBSIDY_PERCENT.Text = Dt.Rows[0]["PRICE_SUBSIDY_PERCENT"].ToString();
            this.SLP_COST_SUBSIDY_PERCENT.Text = Dt.Rows[0]["COST_SUBSIDY_PERCENT"].ToString();

            string strPrefixed = "POP_STM2732";
            Session[string.Format("{0}_FIRST_DATE", strPrefixed)] = this.SLP_ACCEPT_FIRST_DATE.Text;
            Session[string.Format("{0}_RETURN_DATE", strPrefixed)] = this.SLP_RETURN_DATE_END.Text;

            if (this.txtCONFIRM_CODE.Text == "已審核")
            { btnPASS.Enabled = false; }
            if (this.txtCONFIRM_CODE.Text == "未審核")
            { btnNOPASS.Enabled = false; }

            //檔期審核權限
            DataTable DtC = GetFunctionCRUD("STM22");
            if (DtC.Rows.Count > 0)
            { AuthUpdateSTM22 = bool.Parse(DtC.Rows[0]["CanUpdate"].ToString()); }

            btnPASS.Enabled = (AuthUpdateSTM22) ? btnPASS.Enabled : false;
            btnNOPASS.Enabled = (AuthUpdateSTM22) ? btnNOPASS.Enabled : false;

            #endregion

            #region 門市
            STMModel.MaintainPromoteExhibition BCO_Store = new STMModel.MaintainPromoteExhibition(ConnectionDB);

            DataTable Dt_Store;
            ParameterList.Clear();

            ParameterList.Add(v_promote_id);

            Dt_Store = BCO_Store.QuerySwitch(STMModel.MaintainPromoteExhibition.QueryType.STORE, ParameterList);

            GridView1.DataSource = Dt_Store;
            //門市筆數
            this.txtCount_Store.Value = GridView1.Rows.Count.ToString();

            string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
            Session[SessionIDName] = Dt_Store;

            //設定分頁大小
            GridView1.PageIndex = 0;
            GridView1.DataBind();
            this.txtCount_Store.Value = GridView1.Rows.Count.ToString();

            #endregion

            #region 商品
            STMModel.MaintainPromoteExhibition BCO_Item = new STMModel.MaintainPromoteExhibition(ConnectionDB);

            DataTable Dt_Item;
            ParameterList.Clear();

            ParameterList.Add(v_promote_id);
            ParameterList.Add(Session["UID"].ToString());

            Dt_Item = BCO_Item.QuerySwitch(STMModel.MaintainPromoteExhibition.QueryType.ITEM, ParameterList);

            DataView dv_Item = new DataView(Dt_Item);
            dv_Item.RowFilter = "STORE = '" + (Dt_Store.Rows.Count == 0 ? "" : Dt_Store.Rows[0]["STORE"].ToString()) + "'";

            //顯示商品Panel-門市代號
            if (Dt_Store.Rows.Count != 0)
            {
                txtITEM_STORE.Text = Dt_Store.Rows[0]["STORE"].ToString();
                lblITEM_STORE_NAME.Text = Dt_Store.Rows[0]["STORE_NAME"].ToString();
                lblITEM_GROUP_NO.Text = Dt_Store.Rows[0]["GROUP_NO"].ToString();
                lblITEM_COST.Text = Dt_Store.Rows[0]["PRICE_SUBSIDY_PERCENT"].ToString();
            }

            GridView2.DataSource = dv_Item;
            string SessionIDName2 = string.Format("{0}_{1}", PAGE_DT_02, PageTimeStamp.Value);
            Session[SessionIDName2] = dv_Item;
            //設定分頁大小
            GridView2.PageIndex = 0;
            GridView2.DataBind();
            //商品筆數
            this.txtCount_Item.Value = Dt_Item.Rows.Count.ToString();

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

            #endregion

            #region 將資料寫入變數

            Dt.TableName = "VDS_STM_PROMOTE_MST";
            Dt_Store.TableName = "VDS_STM_PROMOTE_STORE";
            Dt_Item.TableName = "VDS_STM_PROMOTE_DTL";

            ds_Data.Tables.Add(Dt.Copy());
            ds_Data.Tables.Add(Dt_Store.Copy());
            ds_Data.Tables.Add(Dt_Item.Copy());

            //門市
            DataSet ds_store = new DataSet();
            ds_store.Tables.Add(Dt_Store.Copy());
            DataColumn[] keys_store = new DataColumn[2];
            keys_store[0] = ds_store.Tables[0].Columns["GROUP_NO"];
            keys_store[1] = ds_store.Tables[0].Columns["STORE"];

            ds_store.Tables[0].PrimaryKey = keys_store;
            Session["STM272_Store" + PageTimeStamp.Value] = ds_store;

            //商品
            DataSet ds = new DataSet();
            ds.Tables.Add(Dt_Item.Copy());
            DataColumn[] keys = new DataColumn[4];
            keys[0] = ds.Tables[0].Columns["PROMOTE_CODE"];
            keys[1] = ds.Tables[0].Columns["STORE"];
            keys[2] = ds.Tables[0].Columns["ITEM"];
            keys[3] = ds.Tables[0].Columns["PERIOD"];

            ds.Tables[0].PrimaryKey = keys;
            Session["STM272_" + PageTimeStamp.Value] = ds;

            #endregion

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { }
    }