Example #1
0
    /// <summary>
    /// 門市
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strStore"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    /// <param name="strCurrentPageMode"></param>
    /// <returns></returns>
    private string GetValueByPageMethod_STORE(string strChan, string strStore, string strUserID, string strPageTimeStamp, string strCurrentPageMode)
    {
        #region

        string strRtn = "", strTemp = "";
        bool bResult = false;
        try
        {
            if (Session[string.Format("CRM041_dtChainPOSetting_{0}", strPageTimeStamp)] != null)
            {
                Session[string.Format("CRM041_dtChainPOSetting_{0}", strPageTimeStamp)] = null;
            }

            #region 從資料庫查詢資料

            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(strStore);//門市
            ParameterList.Add(strChan);//通路
            ParameterList.Add(strUserID);

            Session[string.Format("CRM041_s_CHAN_NO_{0}", strPageTimeStamp)] = strChan;
            Session[string.Format("CRM041_s_STORE_{0}", strPageTimeStamp)] = strStore;

            DataTable dt_Return = new DataTable();
            BCO_CRM.MaintainStore BCO1 = new BCO_CRM.MaintainStore(ConntionDB);
            dt_Return = BCO1.QUERY_STORE_BY_STOREANDCHAN(ParameterList);
            BCO1.CloseConnection();

            #endregion

            if (dt_Return.Rows.Count == 0)
            {
                bResult = false;//查無門市資料
            }
            else
            {
                #region
                if (strCurrentPageMode == "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("非有效門市,不可新增");
                    }
                }

                bResult = true;

                strTemp = string.Format("{0};{1};{2}",
                    dt_Return.Rows[0]["CHAN_NO"].ToString(), dt_Return.Rows[0]["Z_O"].ToString(), dt_Return.Rows[0]["SAL_ID"].ToString());

                #region 取得通路PO控制設定
                ArrayList ParameterList2 = new ArrayList();
                ParameterList2.Clear();
                ParameterList2.Add(dt_Return.Rows[0]["CHAN_NO"].ToString());
                ParameterList2.Add(dt_Return.Rows[0]["STORE"].ToString());
                BCO_ALO.MaintainChainPOSetting BCO2 = new BCO_ALO.MaintainChainPOSetting(ConntionDB);
                Session[string.Format("CRM041_dtChainPOSetting_{0}", strPageTimeStamp)] = BCO2.QueryStorPOSettingByFind(ParameterList2);
                BCO2.CloseConnection();
                #endregion

                #endregion
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return strRtn = string.Format("{0};{1}", bResult.ToString().ToUpper(), strTemp);
        #endregion
    }
Example #2
0
    /// <summary>
    /// 根據傳入通路、門市取得通路PO設定
    /// </summary>
    /// <param name="CHAN_NO"></param>
    /// <param name="STORE"></param>
    private void GetChainPOSetting(string v_CHAN_NO, string v_STORE)
    {
        #region old code
        //{
        //    string SessionIDName = "CRM041_POSetting" + PageTimeStamp.Value;
        //    try
        //    {
        //        dtChainPOSetting = (DataTable)Session[SessionIDName];
        //    }
        //    catch { dtChainPOSetting = null; }
        //}
        //else
        //{
        //    dtChainPOSetting = null;
        //}
        #endregion

        if (dtChainPOSetting == null)
        {
            s_CHAN_NO = v_CHAN_NO;
            s_STORE = v_STORE;
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(v_CHAN_NO);
            ParameterList.Add(v_STORE);

            BCO_ALO.MaintainChainPOSetting bco_alo = new BCO_ALO.MaintainChainPOSetting(ConntionDB);
            dtChainPOSetting = bco_alo.QueryStorPOSettingByFind(ParameterList);
            //string SessionIDName = "CRM041_POSetting" + PageTimeStamp.Value;
            //Session["SessionID"] = SessionIDName;
            //Session[SessionIDName] = dtChainPOSetting;
        }


    }
Example #3
0
    private void GetChanPOSetting(string strChan)
    {
        #region
        try
        {
            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(strChan);
            ParameterList.Add(DBNull.Value);
            dtChanPOSetting = BCO.QueryStorPOSettingByFind(ParameterList);
        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion
    }
Example #4
0
    private void GetStorePOSetting(string strChan, string strStore)
    {
        #region
        try
        {
            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(strChan);
            ParameterList.Add(strStore);
            dtStorePOSetting = BCO.QueryStorPOSettingByFind(ParameterList);

            if (dtStorePOSetting == null || dtStorePOSetting.Rows.Count <= 0)
                dtStorePOSetting = dtChanPOSetting;
        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion
    }
Example #5
0
    private bool CheckPOSourceNO(ref string strErrMsg)
    {
        #region
        bool bResult = true;
        s_ChanNo = SLP_StoreChain1.Text;
        s_Store = SLP_Store2.Text;
        s_Item = SLP_SKU2.Text;
        s_Period = SLP_ItemPeriod1.Text;
        s_StAcceptDate = SLP_SLPDate2.Text;
        s_PoSourceNo = txt_POSourceNo.Text.Trim();        
        ArrayList ParameterList = new ArrayList();//20091113
        ArrayList ParameterList1 = new ArrayList();//20091113

        #region 比對是否 PK重複

        #region 先比對頁面資料
        DataTable dtTempMD = dtForMasterAndDetail;
        dtTempMD.PrimaryKey = new DataColumn[] { dtTempMD.Columns["chan_no"], 
                                                     dtTempMD.Columns["store"], 
                                                     dtTempMD.Columns["item"], 
                                                     dtTempMD.Columns["period"], 
                                                     dtTempMD.Columns["st_accept_date_show"],                                                   
                                                     dtTempMD.Columns["data_source"]
                                                     //,dtTempMD.Columns["po_source_no"]
                                                     };
        DataRow drFind_1 = dtTempMD.Rows.Find(new object[] { s_ChanNo, 
                                                               s_Store, 
                                                               s_Item, 
                                                               s_Period,
                                                               s_StAcceptDate,
                                                               1
                                                               //,s_PoSourceNo
                                                              });
        DataRow drFind_4 = dtTempMD.Rows.Find(new object[] { s_ChanNo, 
                                                               s_Store, 
                                                               s_Item, 
                                                               s_Period,
                                                               s_StAcceptDate,
                                                               4
                                                               //,s_PoSourceNo
                                                              });
        if (drFind_1 != null || drFind_4 != null)
        {
            //strErrMsg = string.Format("『PK重複,資料已存在於頁面(通路,門市,群分類,大分類,進貨日,PO單號)=({0},{1},{2},{3},{4},{5})。』",
            //    s_ChanNo, s_Store, s_ROOT_NO, s_PMA, s_StAcceptDate, s_PoSourceNo);
            strErrMsg = string.Format("『PK重複,手動匯入或通路單號匯入資料已存在於頁面(通路,門市,品號,期別進貨日)=({0},{1},{2},{3},{4})。』",
                              s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate);
            bResult = false;
            return bResult;
        }

        #endregion

        #region 比對待新增明細與實體資料庫
        ALOModel.MaintainChainPO BCO = new ALOModel.MaintainChainPO(ConnectionDB);

        ParameterList1.Clear();
        ParameterList1.Add(s_ChanNo);
        ParameterList1.Add(s_Store);
        ParameterList1.Add(s_Item);
        ParameterList1.Add(s_Period);
        ParameterList1.Add(s_StAcceptDate);
        ParameterList1.Add(s_PoSourceNo);

        bool bDataExist = BCO.CheckChainPODetlIsExistedByFind(ParameterList1);
        if (bDataExist)
        {
            strErrMsg = string.Format("『PK重複,資料已存在於實體資料表(通路,門市,品號,期別,進貨日,PO單號)=({0},{1},{2},{3},{4},{5})。』",
                s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate, s_PoSourceNo);
            bResult = false;
            return bResult;
        }

        #region 只檢查單店/品項/進貨日
        ParameterList1.Clear();
        ParameterList1.Add(s_ChanNo);
        ParameterList1.Add(s_Store);
        ParameterList1.Add(s_Item);
        ParameterList1.Add(s_Period);
        ParameterList1.Add(s_StAcceptDate);
        ParameterList1.Add("");

        bDataExist = BCO.CheckChainPODetlIsExistedByFind(ParameterList1);
        if (bDataExist)
        {
            strErrMsg = string.Format("『PK重複,資料已存在於實體資料表(通路,門市,品號,期別,進貨日)=({0},{1},{2},{3},{4})。』",
                        s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate);
            bResult = false;
            return bResult;
        }
        #endregion

        #endregion

        #endregion


        ALOModel.MaintainChainPOSetting BCO2 = new ALOModel.MaintainChainPOSetting(ConnectionDB);

        #region 依照品號取得所屬[群分類]、[大分類]

        ParameterList.Clear();
        BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", s_Item, "=", "and");
        BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConnectionDB);
        DataTable dt_Return = bco_itm.QuerySKUByFind_1(ParameterList);

        if (dt_Return != null && dt_Return.Rows.Count > 0)
        {
            s_PMA = dt_Return.Rows[0]["PMA"].ToString();//大分類
            s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類
        }

        #endregion

        #region 判斷 is_dis_bypo & is_multipo

        ParameterList1.Clear();
        ParameterList1.Add(s_ChanNo);
        ParameterList1.Add(s_Store);
        DataTable dtChainPOSetting = BCO2.QueryStorPOSettingByFind(ParameterList1);

        if (dtChainPOSetting != null && dtChainPOSetting.Rows.Count > 0)
        {
            for (Int32 i = 0; i <= dtChainPOSetting.Rows.Count - 1; i++)
            {
                if (s_ROOT_NO == dtChainPOSetting.Rows[i]["root_no"].ToString().Trim() && s_PMA == dtChainPOSetting.Rows[i]["pma"].ToString().Trim())
                {

                    if (dtChainPOSetting.Rows[i]["is_dis_bypo"].ToString().Trim() == "0")
                    {
                        if (s_PoSourceNo != "")//1.當[IS_DIS_BYPO]=否時,PO單號應不可輸入。
                        {
                            #region
                            strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時不可輸入通路單號。』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA);
                            bResult = false;
                            rfv_POSourceNo.Enabled = false;
                            break;
                            #endregion
                        }
                    }
                    else if (dtChainPOSetting.Rows[i]["is_dis_bypo"].ToString().Trim() == "1")
                    {
                        if (s_PoSourceNo == "")//2.當[IS_DIS_BYPO]=是時,允許輸入PO單號為必填欄位,應不可為空白。
                        {
                            #region
                            strErrMsg = string.Format("『請輸入通路單號。』");
                            bResult = false;
                            break;
                            #endregion
                        }

                        if (dtChainPOSetting.Rows[i]["is_multipo"].ToString().Trim() == "0")//3.當[IS_DIS_BYPO]=是且[IS_MULTIPO]=否時,代表(同門市/品號期別/門市進貨日)下,只能輸入一個PO單號。 
                        {
                            #region
                            if (bResult)
                            {
                                //20090716 modified
                                if (!bDetailEditing)//如果不是編輯狀態
                                {
                                    //檢查頁面暫存檔
                                    //DataTable dtTempMD = dtForMasterAndDetail;
                                    DataRow[] dRows = dtTempMD.Select(string.Format("chan_no='{0}' and store='{1}' and item='{2}' and period = '{3}' and st_accept_date_show='{4}' ",
                                                                       s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate));
                                    if (dRows.Length > 0)
                                    {
                                        strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時,只能輸入一個PO單號』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA);
                                        bResult = false;
                                    }

                                    //檢查資料庫
                                    ParameterList1.Clear();
                                    ParameterList1.Add(s_ChanNo);
                                    ParameterList1.Add(s_Store);
                                    ParameterList1.Add(s_Item);
                                    ParameterList1.Add(s_Period);
                                    ParameterList1.Add(s_StAcceptDate);
                                    ParameterList1.Add(null);

                                    bool bTemp = BCO.CheckChainPODetlIsExistedByFind(ParameterList1);
                                    if (bTemp)
                                    {
                                        strErrMsg = string.Format("『(通路,門市,群分類,大分類,進貨日)=({0},{1},{2},{3},{4})時,只能輸入一個PO單號』",
                                            s_ChanNo, s_Store, s_ROOT_NO, s_PMA, s_StAcceptDate);
                                        bResult = false;
                                    }
                                }

                            }
                            #endregion
                        }
                        else if (dtChainPOSetting.Rows[i]["is_multipo"].ToString().Trim() == "1")//3.當[IS_DIS_BYPO]=是且[IS_MULTIPO]=是時,代表(同門市/品號期別/門市進貨日)下,允許多重PO。 
                        {
                            #region
                            if (bResult)
                            {
                                ParameterList1.Clear();
                                ParameterList1.Add(s_ChanNo);
                                ParameterList1.Add(s_Store);
                                ParameterList1.Add(s_Item);
                                ParameterList1.Add(s_Period);
                                ParameterList1.Add(s_StAcceptDate);
                                ParameterList1.Add(s_PoSourceNo);

                                DataTable dtTempPoDetl = BCO.QueryChainPODetlByFind(ParameterList1);

                                if (dtTempPoDetl != null && dtTempPoDetl.Rows.Count > 0)
                                {
                                    for (Int32 j = 0; j <= dtTempPoDetl.Rows.Count - 1; j++)
                                    {
                                        if (dtTempPoDetl.Rows[j]["po_source_no"].ToString().Trim() != s_PoSourceNo)
                                        {
                                            strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時不允許多重PO。』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA);
                                            bResult = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                    }

                }
            }


        }


        #endregion

        return bResult;
        #endregion
    }
Example #6
0
    private DataTable GetPOSettingData()
    {
        #region
        ALOModel.MaintainChainPOSetting BCOPOsetting = new ALOModel.MaintainChainPOSetting(ConnectionDB);

        ArrayList ParameterList1 = new ArrayList();//20091113

        ParameterList1.Clear();
        ParameterList1.Add(SLP_StoreChain1.Text.Trim());
        ParameterList1.Add(SLP_Store2.Text.Trim());
        DataTable dt = null;
        try
        {
            dt = BCOPOsetting.QueryStorPOSettingByFind(ParameterList1);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }


        return dt;

        #endregion
    }
Example #7
0
    }//end EditCancelButton_Click

    /// <summary>
    ///  編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {
        #region
        bool bResult = false;

        try
        {
            #region 取得畫面元件的值


            DateTime processtime = DateTime.Now;
            string v_ID = "";
            #endregion

            #region 取得更新前舊值


            #region 使用XML轉回DataSet

            DataSet DsMaster = new DataSet();
            System.IO.StringReader srM = new System.IO.StringReader(MasterOLDData.InnerHtml);
            DsMaster.ReadXml(srM);
            DataTable dtMaster = DsMaster.Tables[0];
            ArrayList ParameterList = new ArrayList();//20091113

            //DataSet DsDetail = new DataSet();
            //System.IO.StringReader srD = new System.IO.StringReader(DetailOLDData.InnerHtml);
            //DsDetail.ReadXml(srD);
            //DataTable dtDetail = DsDetail.Tables[0];

            //dtDetail.Columns.Add("NEW_UPDATEDATE");
            //dtDetail.Columns.Add("NEW_UPDATEUID");
            //dtDetail.Columns.Add("NEW_IS_DIS_BYPO");
            //dtDetail.Columns.Add("NEW_IS_MULTIPO");

            #endregion

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

            #endregion

            #region Master
            ParameterList.Clear();
            ParameterList.Add(dtMaster.Rows[0]["ID"]);
            ParameterList.Add(dtMaster.Rows[0]["CODE"]);
            ParameterList.Add(dtMaster.Rows[0]["NAME"]);
            ParameterList.Add(dtMaster.Rows[0]["ENABLE"]);
            ParameterList.Add(dtMaster.Rows[0]["CREATEDATE"]);
            ParameterList.Add(dtMaster.Rows[0]["CREATEUID"]);
            ParameterList.Add(dtMaster.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(dtMaster.Rows[0]["UPDATEUID"]);
            ParameterList.Add(dtMaster.Rows[0]["CHAIN_CODE"]);
            ParameterList.Add(dtMaster.Columns.Contains("STORE_CODE") == true ? dtMaster.Rows[0]["STORE_CODE"].ToString() : "");
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());

            #endregion



            #region Detail
            DataTable dtDetail = new DataTable();
            dtDetail.Columns.Add("CREATEDATE");
            dtDetail.Columns.Add("CREATEUID");
            dtDetail.Columns.Add("UPDATEDATE");
            dtDetail.Columns.Add("UPDATEUID");
            dtDetail.Columns.Add("PMA");
            dtDetail.Columns.Add("IS_DIS_BYPO");
            dtDetail.Columns.Add("IS_MULTIPO");
            dtDetail.Columns.Add("ROOT_NO");

            for (Int32 i = 0; i <= GridView2.Rows.Count - 1; i++)
            {
                DataRow newRowDETL = dtDetail.NewRow();

                CheckBox chk_ISEXISTED_Sgl = (CheckBox)GridView2.Rows[i].FindControl("chk_ISEXISTED_Sgl");
                CheckBox chk_single = (CheckBox)GridView2.Rows[i].FindControl("chk_POSingle_Sgl");
                CheckBox chk_multi = (CheckBox)GridView2.Rows[i].FindControl("chk_POMulti_Sgl");
                Label lbl_PMA = (Label)GridView2.Rows[i].FindControl("lbl_PMA");
                Label lbl_root_no = (Label)GridView2.Rows[i].FindControl("lbl_root_no");

                if (chk_ISEXISTED_Sgl.Checked)
                {
                    newRowDETL["CREATEDATE"] = processtime;
                    newRowDETL["CREATEUID"] = Session["UID"].ToString();
                    newRowDETL["UPDATEDATE"] = processtime;
                    newRowDETL["UPDATEUID"] = Session["UID"].ToString();
                    newRowDETL["PMA"] = lbl_PMA.Text.Trim();
                    newRowDETL["IS_DIS_BYPO"] = chk_single.Checked ? 1 : 0;
                    newRowDETL["IS_MULTIPO"] = chk_multi.Checked ? 1 : 0;
                    newRowDETL["ROOT_NO"] = lbl_root_no.Text.Trim();
                    dtDetail.Rows.Add(newRowDETL);
                }
            }
            #endregion

            #region Detail OLD
            //v_ID = dtMaster.Rows[0]["ID"].ToString().Trim();// dtDetail.Rows[k]["PID"].ToString().Trim();
            //for (Int32 i = GridView2.Rows.Count - 1; i >= 0; i--)
            //{
            //    CheckBox chk_ISEXISTED_Sgl = (CheckBox)GridView2.Rows[i].FindControl("chk_ISEXISTED_Sgl");
            //    CheckBox chk_single = (CheckBox)GridView2.Rows[i].FindControl("chk_POSingle_Sgl");
            //    CheckBox chk_multi = (CheckBox)GridView2.Rows[i].FindControl("chk_POMulti_Sgl");
            //    Label lbl_PMA = (Label)GridView2.Rows[i].FindControl("lbl_PMA");
            //    Label lbl_root_no = (Label)GridView2.Rows[i].FindControl("lbl_root_no");

            //    if (chk_ISEXISTED_Sgl.Checked)
            //    {
            //        for (Int32 k = dtDetail.Rows.Count - 1; k >= 0; k--)
            //        {
            //            if (dtDetail.Rows[k]["PMA"].ToString().Trim() == lbl_PMA.Text.Trim())
            //            {
            //                //dtDetail.Rows[k]["PID"] = v_ID;
            //                //dtDetail.Rows[k]["NEW_UPDATEDATE"] = processtime;
            //                //dtDetail.Rows[k]["NEW_UPDATEUID"] = Session["UID"].ToString();
            //                //dtDetail.Rows[k]["NEW_IS_DIS_BYPO"] = chk_single.Checked ? 1 : 0;
            //                //dtDetail.Rows[k]["NEW_IS_MULTIPO"] = chk_multi.Checked ? 1 : 0;
            //                break;
            //            }
            //        }
            //    }
            //    else
            //    {
            //        for (Int32 k = dtDetail.Rows.Count - 1; k >= 0; k--)
            //        {
            //            if (dtDetail.Rows[k]["PMA"].ToString().Trim() == lbl_PMA.Text.Trim())
            //            {
            //                dtDetail.Rows.RemoveAt(k);
            //            }
            //        }
            //    }
            //}
            #endregion

            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);

            bResult = BCO.UpdateMasterAndDetail(ParameterList, dtDetail, null);

            if (!bResult)
            {
                throw new Exception("更新0筆資料!");
            }
            else
            {
                //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('更新完成');"), true);//location.replace('ALO232.aspx?ID={0}&Code=ALO23');", v_ID
                ResultMsgLabel.Text = "更新完成";
                SwitchFormviewMode(FormViewMode.ReadOnly);
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }//end EditCommitButton_Click
Example #8
0
    /// <summary>
    /// 繫結資料到控制項
    /// </summary>
    /// <param name="vdb"></param>
    private void QueryData()
    {
        #region

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
        ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);

        DataTable dt = null;

        if (CheckBoxLikeSearch.Checked)
        {
            dt = BCO.QueryMasterByLike(GetQueryParams());
        }
        else
        {
            dt = BCO.QueryMasterByFind(GetQueryParams());
        }

        Session[SessionIDName] = dt;
        Int32 iRowCount = 0;
        aryParamsPKey.Clear();


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

        if (dt != null && dt.Rows.Count > 0)
        {
            iRowCount = dt.Rows.Count;


            foreach (DataRow dr in dt.Rows)
            {
                #region
                aryParamsPKey.Add(dr["ID"]);
                #endregion
            }

            if (btn_Export.Visible == true)
            {
                btn_Export.Enabled = true;
            }
        }
        else
        {
            ResultMsgLabel.Text = "查無資料";

            if (btn_Export.Visible == true)
            {
                btn_Export.Enabled = false;
            }
        }


        Session[string.Format("{0}_{1}", strPreFixed, PageTimeStamp.Value)] = aryParamsPKey;

        LabelQueryRecordCount.Text = string.Format(" {0} Rows ", iRowCount);

        #endregion
    }
Example #9
0
    }//end InsertCancelButton_Click

    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region 取得畫面元件的值

            string v_Chain_Code = ((STM_SLP_StoreChain)FormView1.FindControl("SLP_StoreChain1")).Text.Trim();
            string v_Store_Code = ((PIC.VDS2G.WebUI.SLP.SLP_Store)FormView1.FindControl("SLP_Store1")).Text.Trim();
            DateTime processtime = DateTime.Now;

            #endregion
            // 2009-05-04 cyhsu 在Server Site 存檔前,檢查門市與通路關連正確性

            ArrayList ParameterList = new ArrayList();//20091113

            #region 檢查通路與門市
            //檢查門市是否屬於該通路
            if ((v_Chain_Code != "") && (v_Store_Code != ""))
            {
                ParameterList.Clear();
                ParameterList.Add(v_Chain_Code); // 通路
                ParameterList.Add(v_Store_Code);      // 門市
                ParameterList.Add(Session["UID"].ToString());
                PIC.VDS2G.BSM.CRM.QueryCRMCommon bco = new PIC.VDS2G.BSM.CRM.QueryCRMCommon(ConnectionDB);
                bool b_CheckRes;
                b_CheckRes = bco.CheckChanAndStore(ParameterList);
                if (!b_CheckRes)
                {
                    sb.Length = 0;
                    sb.AppendFormat("門市[{1}]不屬於通路[{0}]!",
                                                       v_Chain_Code,
                                                       v_Store_Code);
                    throw new Exception(sb.ToString());
                }

            }
            #endregion
            #region 加入輸入條件

            #region Master
            ParameterList.Clear();
            ParameterList.Add(string.Format("{0}_{1}", v_Chain_Code, v_Store_Code));
            ParameterList.Add(string.Format("{0}_{1}", v_Chain_Code, v_Store_Code));
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(v_Chain_Code);
            ParameterList.Add(v_Store_Code);
            #endregion

            #region Detail
            DataTable dtDetail = new DataTable();
            dtDetail.Columns.Add("CREATEDATE");
            dtDetail.Columns.Add("CREATEUID");
            dtDetail.Columns.Add("UPDATEDATE");
            dtDetail.Columns.Add("UPDATEUID");
            dtDetail.Columns.Add("PMA");
            dtDetail.Columns.Add("IS_DIS_BYPO");
            dtDetail.Columns.Add("IS_MULTIPO");

            //20090105 added for spec changed
            dtDetail.Columns.Add("ROOT_NO");

            for (Int32 i = 0; i <= GridView2.Rows.Count - 1; i++)
            {
                DataRow newRowDETL = dtDetail.NewRow();

                CheckBox chk_ISEXISTED_Sgl = (CheckBox)GridView2.Rows[i].FindControl("chk_ISEXISTED_Sgl");
                CheckBox chk_single = (CheckBox)GridView2.Rows[i].FindControl("chk_POSingle_Sgl");
                CheckBox chk_multi = (CheckBox)GridView2.Rows[i].FindControl("chk_POMulti_Sgl");
                Label lbl_PMA = (Label)GridView2.Rows[i].FindControl("lbl_PMA");
                Label lbl_root_no = (Label)GridView2.Rows[i].FindControl("lbl_root_no");

                if (chk_ISEXISTED_Sgl.Checked)
                {
                    newRowDETL["CREATEDATE"] = processtime;
                    newRowDETL["CREATEUID"] = Session["UID"].ToString();
                    newRowDETL["UPDATEDATE"] = processtime;
                    newRowDETL["UPDATEUID"] = Session["UID"].ToString();
                    newRowDETL["PMA"] = lbl_PMA.Text.Trim();
                    newRowDETL["IS_DIS_BYPO"] = chk_single.Checked ? 1 : 0;
                    newRowDETL["IS_MULTIPO"] = chk_multi.Checked ? 1 : 0;
                    newRowDETL["ROOT_NO"] = lbl_root_no.Text.Trim();
                    dtDetail.Rows.Add(newRowDETL);
                }
            }
            #endregion

            #endregion

            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);
            string v_ID = "";
            v_ID = BCO.CreateMasterAndDetail(ParameterList, dtDetail, null).ToString();

            if (v_ID == "")
            {
                throw new Exception("新增0筆資料!");
            }
            else
            {
                b_CopyNew = false;
                s_ID = v_ID;
                ResultMsgLabel.Text = "新增完成";
                SwitchFormviewMode(FormViewMode.ReadOnly);
                aryParamsPKey.Clear();//清空ID ArrayList

            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }//end InsertButton_Click
Example #10
0
    /// <summary>
    /// 繫結資料 DTL
    /// </summary>
    private void databind_Dtl(string strID)
    {
        #region
        try
        {
            string SessionIDName = "ALO23_DTL_" + PageTimeStamp.Value;
            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);
            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(strID);

            DataTable dtTemp = BCO.QueryLineSwitch(ALOModel.MaintainChainPOSetting.QueryType.ID, ParameterList);

            #region 使用XML放置到前端資料


            DataSet Ds = dtTemp.DataSet;
            DetailOLDData.InnerHtml = Ds.GetXml();

            #endregion

            Session[SessionIDName] = dtTemp;

            

            strDisabledCheckbox = "";

            iDetlRowsCount = dtTemp.Rows.Count;
            GridView2.DataSource = dtTemp;
            GridView2.PageIndex = 0;
            GridView2.DataBind();

            if (strDisabledCheckbox != "")
                ScriptManager.RegisterStartupScript(this, this.GetType(), "DisabledCheckbox", string.Format("LockOrUnlockControls('{0}',true);CheckSelectIsAllSelect_ALO23();", strDisabledCheckbox), true);

        }
        catch (Exception ex)
        {
            throw ex;
        }
        #endregion
    }//databind_Dtl
Example #11
0
    }//QueryData

    /// <summary>
    /// 繫結資料 MST
    /// </summary>
    private void databind_Mst(string strID)
    {
        #region
        try
        {
            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);
            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(strID);
            this.hiddenID.Value = strID;
            DataTable dtTemp = BCO.QuerySwitch(ALOModel.MaintainChainPOSetting.QueryType.ID, ParameterList);

            #region 使用XML放置到前端資料

            MasterOLDData.InnerHtml = dtTemp.DataSet.GetXml();

            #endregion

            FormView1.DataSource = dtTemp;
            FormView1.DataBind();


            if (dtTemp == null || dtTemp.Rows.Count <= 0)
            {
                throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!");           
            }

            if (dtTemp.Rows[0]["ENABLE"].ToString() == "0")
            {
                ((Button)FormView1.FindControl("EditButton")).Visible = false;
                ((Button)FormView1.FindControl("DeleteButton")).Visible = false;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion
    }//databind_Mst
Example #12
0
    /// <summary>
    /// 取得Detail項目資料以新增
    /// </summary>
    private void SetGridViewForInsertMode()
    {
        #region
        try
        {
            string SessionIDName = "ALO23_DTL_" + PageTimeStamp.Value;
            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);
            DataTable Dt = BCO.QueryPMAFormSYS_CODE_DETL();

            #region 使用XML放置到前端資料

            DataSet Ds = Dt.DataSet;
            DetailOLDData.InnerHtml = Ds.GetXml();

            #endregion
            iDetlRowsCount = Dt.Rows.Count;
            GridView2.DataSource = Dt;
            GridView2.PageIndex = 0;
            GridView2.DataBind();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }//SetGridViewForInsertMode
Example #13
0
    }//end EditCommitButton_Click

    /// <summary>
    /// 於檢視模式,按下刪除鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region 取得畫面元件的值

            DateTime processtime = DateTime.Now;

            #endregion

            ArrayList ParameterList = new ArrayList();//20091113


            #region 取得刪除前舊值


            #region 使用XML轉回DataSet

            DataSet Ds = new DataSet();
            System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
            Ds.ReadXml(sr);
            DataTable Dt = Ds.Tables[0];

            #endregion

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

            #endregion

            #region 加入更新條件

            //master
            ParameterList.Clear();
            //舊值
            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["CHAIN_CODE"]);
            ParameterList.Add(Dt.Columns.Contains("STORE_CODE") == true ? Dt.Rows[0]["STORE_CODE"].ToString() : "");

            //需要更新值
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());

            //detail
            ParameterList1.Clear();
            ParameterList1.Add(Dt.Rows[0]["ID"]);
            ParameterList1.Add(Dt.Rows[0]["CREATEUID"]);
            #endregion

            ALOModel.MaintainChainPOSetting BCO = new ALOModel.MaintainChainPOSetting(ConnectionDB);

            BCO.DeleteMasterAndDetail(ParameterList, ParameterList1, null);

            ResultMsgLabel.Text = "刪除完成";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientScript", string.Format("location.replace('ALO231.aspx?Code=ALO23&Requery=true&PageTimeStamp={0}');", PageTimeStamp.Value), true);//alert('刪除完成');
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }//DeleteButton_Click