protected void Btn_Query_Click(object sender, EventArgs e)
    {
        try
        {

            ErrorMsgLabel.Text = "";

            this.hidCheckAllFlag.Value = "Y";

            DataTable Dt = new DataTable();

            #region 清空靜態變數
            dt_Detail = null;
            #endregion


            #region 處理查詢

            BCO.MaintainMarketSurveyStore bco = new MaintainMarketSurveyStore(ConntionDB);

            Dt = bco.QuerySelectStore(this.getParameterList());

            #endregion


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

            }



            #region 設定查詢結果

            this.GridView1.DataSource = Dt;
            this.GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            this.GridView1.PageIndex = 0;
            this.GridView1.DataBind();

            #endregion

            #region 將GridView的資訊寫入TempTable

            Set_PageValue_To_TempTable();

            #endregion


        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }

    }
    protected void Btn_Execute_Click(object sender, EventArgs e)
    {
        try
        {
            string errMsg = "";
            if (txtOldInvestigator.Text.Trim() == "")
                errMsg += "「原市調人員」不可空白<br \\>";

            if (txtNewInvestigator.Text.Trim() == "")
                errMsg += "「新市調人員」不可空白";
            if (errMsg != "")
            {
                ErrorMsgLabel.Text = errMsg;
                return;
            }

            #region 儲存新增資料

            string strMsg = "";

            BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);

            // 做資料儲存的動作
            bco.ExchangeInvestigator(this.getParameterList(), null, out strMsg);

            if (strMsg != "")
            {
                this.ErrorMsgLabel.Text = strMsg;
                return;
            }

            #endregion

            #region 關掉POP視窗
            //Response.Write("<script>alert('儲存成功');window.close();</script>");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Window", "alert('儲存成功');window.close();", true);
            #endregion
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }

    }
    public static string GetStoreRelatedData(string strStore)
    {
        #region 取得STORE_STATUS(關店門市狀態),SAL_ID,CHAN_NO by store

        String rtnValue = "";
        if (strStore != "")
        {

            BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);

            // 取得STORE_STATUS(關店門市狀態),SAL_ID,CHAN_NO by store
            ParameterList.Clear();
            ParameterList.Add(strStore);

            DataTable dt = bco.QueryRelatedStoreData(ParameterList);
            if (dt.Rows.Count > 0)
            {
                rtnValue = dt.Rows[0][0].ToString();
            }
            else
            {
                rtnValue = "";
            }

        }

        return rtnValue;

        #endregion
    }
Ejemplo n.º 4
0
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtInvestigator.Text.Trim() == "")
            {
                ErrorMsgLabel.Text = "「市調人員」不可空白";
                return;
            }

            string strErrMsg = "";

            if (Session["MKT12_POP_SelectStore" + PageTimeStamp.Value] == "")
            {
                ErrorMsgLabel.Text = "請選擇新門市";
                return;
            }



            #region 組合查詢條件至ArrayList

            string strInvestigator = this.txtInvestigator.Text;
            ArrayList returnList = new ArrayList();

            returnList.Clear();
            returnList.Add(GetValueSetParameter(strInvestigator, "string"));
            returnList.Add(Session["UID"].ToString());
            #endregion

            #region 儲存新增資料

            string strMsg = "";

            BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);

            int intCount = bco.CreateMultiSurveyStore(returnList, ((DataTable)Session["MKT12_POP_SelectStore" + PageTimeStamp.Value]), null, out strMsg);

            //儲存異常
            if (strMsg != "")
            {
                this.ErrorMsgLabel.Text = strMsg;
                return;
            }

            Session.Remove("MKT12_POP_SelectStore" + PageTimeStamp.Value);

            strErrMsg = "新增資料" + intCount.ToString() + "筆 成功";
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('"+strErrMsg+"');location.replace('MKT121.aspx?Code=MKT12');", true);

            #endregion

        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }

    }
    protected void Btn_Execute_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            string strZ_O = this.SLP_CodeFile1.Text;
            string strOldChanNo = this.SLP_StoreChain_OLD.Text;
            string strOldStore = this.SLP_Store_OLD.Text;
            string strSurveyDate = this.txtSURVEY_DATE.Text;
            string strNewChanNo = this.SLP_StoreChain_NEW.Text;
            string strNewStore = this.SLP_Store_NEW.Text;

            #region 門市 營業所Check
            if (SLP_CodeFile1.Text != "")
            {
                #region 原門市 營業所Check

                ParameterList.Clear();
                ParameterList.Add(GetValueSetParameter(strOldStore, "string"));

                BCO.MaintainMarketSurveyRecords bcoOldZ_O = new BCO.MaintainMarketSurveyRecords(ConnectionDB);

                DataTable dtZ_O = bcoOldZ_O.QueryZ_OByStore(ParameterList);

                if (dtZ_O == null || dtZ_O.Rows.Count == 0 || dtZ_O.Rows[0][0].ToString() != strZ_O)
                {
                    ErrorMsgLabel.Text = "原門市不屬於此營業所範圍";
                    return;
                }
                #endregion

                #region 新門市 營業所Check

                ParameterList.Clear();
                ParameterList.Add(GetValueSetParameter(strNewStore, "string"));

                BCO.MaintainMarketSurveyRecords bcoNewZ_O = new BCO.MaintainMarketSurveyRecords(ConnectionDB);

                DataTable dtZ_ONew = bcoNewZ_O.QueryZ_OByStore(ParameterList);

                if (dtZ_ONew == null || dtZ_ONew.Rows.Count == 0 || dtZ_ONew.Rows[0][0].ToString() != strZ_O)
                {
                    ErrorMsgLabel.Text = "新門市不屬於此營業所範圍";
                    return;
                }

                #endregion
            }
            #endregion

            #region 檢查原門市資料是否已存在市調計畫

            ParameterList.Clear();
            ParameterList.Add("");
            ParameterList.Add("");
            ParameterList.Add(GetValueSetParameter(strOldChanNo, "string"));
            ParameterList.Add(GetValueSetParameter(strOldStore, "string"));
            ParameterList.Add(GetValueSetParameter(strSurveyDate, "date"));
            ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string"));
            ParameterList.Add(GetValueSetParameter(SLP_CodeFile1.Text, "string")); //營業所


            BCO.MaintainMarketSurveyRecords bcoMainOld = new BCO.MaintainMarketSurveyRecords(ConnectionDB);

            DataTable dtExistMainOld = bcoMainOld.QueryExistPk(ParameterList);

            if (dtExistMainOld == null || dtExistMainOld.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "原門市資料不存在市調計畫,無法複製";
                return;
            }

            #endregion
            
            #region 組合複製市調計畫條件至ArrayList
            
            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(strOldChanNo, "string"));
            ParameterList.Add(GetValueSetParameter(strOldStore, "string"));
            ParameterList.Add(GetValueSetParameter(strNewChanNo, "string"));
            ParameterList.Add(GetValueSetParameter(strNewStore, "string"));
            ParameterList.Add(GetValueSetParameter(strSurveyDate, "date"));
            ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string"));
            ParameterList.Add(GetValueSetParameter(SLP_CodeFile1.Text, "string")); //營業所

            #endregion


            #region 新門市必需存在於市調門市檔

            BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);

            DataTable dtExist = bco.QueryExistPk(ParameterList);

            if (dtExist == null || dtExist.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "新門市不存在於市調門市檔";
                return;
            }

            #endregion

            #region 檢查新門市資料是否已存在市調計畫

            BCO.MaintainMarketSurveyRecords bcoMain = new BCO.MaintainMarketSurveyRecords(ConnectionDB);

            DataTable dtExistMain = bcoMain.QueryExistPk(ParameterList);

            if (dtExistMain != null && dtExistMain.Rows.Count > 0)
            {
                ErrorMsgLabel.Text = "複製市調計畫至新門市失敗, 新門市資料已存在市調計畫";
                return;
            }

            #endregion

            #region 複製市調計畫至新門市

            BCO.MaintainMarketSurveyRecords bcoCopy = new BCO.MaintainMarketSurveyRecords(ConnectionDB);

            // 執行複製市調計畫至新門市的動作
            bcoCopy.CopyToNewStore(ParameterList, null);
                        
            #endregion

            this.ErrorMsgLabel.Text = "複製市調計畫成功";

            #region 關掉POP視窗
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Window", "alert('儲存成功');window.close();", true);
            #endregion
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }

    }
Ejemplo n.º 6
0
    protected void Btn_Delete_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        if (this.hid_PageStatus.Value == "VIEW")
        {
            ErrorMsgLabel.Text = "";

            #region 取得更新前舊值


            #region 使用XML轉回DataSet

            DataSet DsMaster = new DataSet();
            System.IO.StringReader srM = new System.IO.StringReader(MasterOLDData.InnerHtml);
            DsMaster.ReadXml(srM);
            DataTable dtMasterOLD = DsMaster.Tables[0];

            #endregion

            //if (dtDetailOLD.Rows.Count == 0)
            //{
            //    throw new Exception("抓取不到舊值,更新失敗!");
            //}

            #endregion

            #region  處理刪除作業
            #region 組合刪除條件至ArrayList

            string v_Store = this.SLP_Store1.Text;
            string v_Investigator = this.txtInvestigator.Text;

            ArrayList returnList = new ArrayList();

            returnList.Clear();
            returnList.Add(GetValueSetParameter(v_Store, "string"));
            returnList.Add(GetValueSetParameter(v_Investigator, "string"));
            returnList.Add(Session["UID"].ToString());
            //returnList.Add("1");
            #endregion

            try
            {
                string strMsg = "";

                BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);

                bco.DeleteSurveyStore(returnList, dtMasterOLD.Rows[0], null, out strMsg);

                if (strMsg != "")
                {
                    //刪除異常
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('"+strMsg+"');location.replace('MKT121.aspx?Code=MKT12');", true);
                    return;
                }

                ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('刪除完成');location.replace('MKT121.aspx?Code=MKT12');", true);

            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            #endregion
        }
    }
Ejemplo n.º 7
0
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            SLP_User1.Text = Page.Request.Form[SLP_User1.TextBox_Code.UniqueID];
            #region 資料儲存
            if (txtInvestigator.Text.Trim() == "")
            {
                ErrorMsgLabel.Text = "請輸入「市調人員」";
                return;
            }
            BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);

            {
                switch (this.hid_PageStatus.Value)
                {
                    case "INSERT":
                        #region  處理新增作業

                        {
                            DataTable dtExist = new DataTable();
                            dtExist = bco.QueryExistPk(this.getParameterList());
                            if (dtExist != null && dtExist.Rows.Count > 0)
                            {
                                ErrorMsgLabel.Text = "新增失敗, 門市(" + this.SLP_Store1.Text + ")資料已存在";
                                return;
                            }

                            #region 儲存新增資料

                            string strMsg = "";

                            // 做資料儲存的動作
                            int vPID = bco.CreateSurveyStore(this.getParameterList(), null, out strMsg);

                            if (strMsg != "")
                            {
                                //資料儲存異常
                                this.ErrorMsgLabel.Text = strMsg;
                                return;
                            }

                            this.hiddenID.Value = Convert.ToString(vPID);

                            #endregion

                        }

                        #endregion

                        break;
                    case "EDIT":
                        {
                            #region 使用XML轉回DataSet

                            DataTable MasterOldDt = null;
                            if (MasterOLDData.InnerHtml != "" && MasterOLDData.InnerHtml != "<NewDataSet />")
                            {
                                DataSet Ds = new DataSet();
                                System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
                                Ds.ReadXml(sr);
                                MasterOldDt = Ds.Tables[0];

                            }

                            #endregion

                            string strMsg = "";

                            // 做資料儲存的動作
                            bco.UpdateSurveyStore(this.getParameterList(),
                                                      MasterOldDt.Rows[0],
                                                      null,
                                                      out strMsg);

                            if (strMsg != "")
                            {
                                //資料儲存異常
                                this.ErrorMsgLabel.Text = strMsg;
                                return;
                            }

                            break;
                        }
                        break;
                }

                #region 存檔後資料重新讀取
                databind_Mst();

                #endregion

                #region 存檔後狀態設定

                this.hid_PageStatus.Value = "VIEW";
                this.txt_PageStatus.Text = "VIEW";
                #endregion
            }

            #endregion
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally
        {
            SetPageStatus();
            SetDefaultValue();
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 繫結資料 MST
    /// </summary>
    private void databind_Mst()
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            BCO.MaintainMarketSurveyStore bco = new BCO.MaintainMarketSurveyStore(ConnectionDB);
            ParameterList.Clear();
            ParameterList.Add(this.hiddenID.Value);
            DataTable Dt = bco.QuerySurveryStoreGetByID(ParameterList);

            #region 使用XML放置到前端資料
            MasterOLDData.InnerHtml = Dt.DataSet.GetXml();
            #endregion
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }//databind_Mst
Ejemplo n.º 9
0
    /// <summary>
    /// 設定本次市調門市
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Btn_SurveyStore_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            DataTable Dt = new DataTable();

            #region 取得查詢參數: 營業所

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.SLP_CodeFile1.Text, "string")); //營業所起
            ParameterList.Add(GetValueSetParameter(this.SLP_CodeFile1.Text, "string")); //營業所迄
            ParameterList.Add(GetValueSetParameter("", "string")); //市調人員 不納入查詢條件
            ParameterList.Add(GetValueSetParameter("9999", "int"));

            #endregion

            #region 處理查詢

            BCO.MaintainMarketSurveyStore bco = new MaintainMarketSurveyStore(ConnectionDB);

            Dt = bco.QuerySurveryStore(ParameterList);

            #endregion

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "MKT133.aspx", "alert(' 查無資料 ');", true);
                ErrorMsgLabel.Text = "查無資料";
            }
            else
            {
                //dt_Detail = Dt.Copy();
            }

            #region 設定查詢結果

            this.GridView1.DataSource = Dt;
            this.GridView1.PageSize = 20;// (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            this.GridView1.PageIndex = 0;
            this.GridView1.DataBind();

            Session["MKT133_MAIN_" + PageTimeStamp.Value] = Dt;

            #endregion
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }
    }