Beispiel #1
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;
        }


    }
Beispiel #2
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
    }
Beispiel #3
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
    }
Beispiel #4
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
    }
Beispiel #5
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
    }
Beispiel #6
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
    }