예제 #1
0
    /// <summary>
    /// </summary>
    /// <param name="dt">列印資料</param>
    private void Show_Report2(DataTable dt)
    {
        TextBox txt_BUSDATE_B = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode");
        TextBox txt_BUSDATE_E = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode");

        string s_FileName = txt_Out_FileName.Text;
        if (s_FileName.ToLower().IndexOf(".xls") > 0)
        {
            s_FileName = s_FileName.Substring(0, s_FileName.Length - 4) + ".pdf";
        }
        else
        {
            s_FileName = s_FileName + ".pdf";
        }
        s_FileName = HttpUtility.UrlEncode(s_FileName, System.Text.Encoding.UTF8);

        string s_LocalUser = "";
        string s_LocalRole = "";
        #region 取得使用者名稱
        BCO.QueryCRMCommon comm = new BCO.QueryCRMCommon(ConntionDB);
        comm.GetUserAndRoleName(Session["UID"].ToString(), ref s_LocalUser, ref s_LocalRole);
        #endregion

        report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        // Load report
        report.Load(Server.MapPath("./REPORT/CRM161/CRM161_Report_Detl.rpt"));
        report.SetDataSource(dt);
        // Set Parameter
        report.SetParameterValue("par_Program_ID", this.PageCode);
        //report.SetParameterValue("par_LoginUser", Session["UID"].ToString());
        report.SetParameterValue("par_LoginUser", s_LocalUser.ToString());
        report.SetParameterValue("par_Role", s_LocalUser.ToString());
        report.SetParameterValue("par_BUSDATE", txt_BUSDATE_B.Text.Trim() + "~" + txt_BUSDATE_E.Text.Trim());
        report.SetParameterValue("par_CHAN_NO", this.slp_CHAN_NO.Text.Trim());
        report.SetParameterValue("par_ITEM", this.slp_ITEM.Text.Trim());
        report.SetParameterValue("par_Z_O", this.slp_Z_O_B.Text.Trim() + "~" + this.slp_Z_O_E.Text.Trim());
        report.SetParameterValue("par_MANUFACTURE", this.slp_MANUFACTURE_B.Text.Trim() + "~" + this.slp_MANUFACTURE_E.Text.Trim());
        report.SetParameterValue("par_STATUS", this.rdb_STATUS.SelectedItem.Text.Trim());


        System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);
        stream.Seek(0, System.IO.SeekOrigin.Begin);

        //export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

        Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
        report.Close();
    }
예제 #2
0
    private bool GetOpenDateByStore(string strChan, string strStore)
    {
        #region
        bool bResult = false;
        try
        {
            CRMModel.QueryCRMCommon BCO = new CRMModel.QueryCRMCommon(ConnectionDB);
            ArrayList ParameterList1 = new ArrayList();

            ParameterList1.Clear();
            ParameterList1.Add(strStore);
            ParameterList1.Add(strChan);
            ParameterList1.Add(Session["UID"].ToString());
            DataTable dtTemp = BCO.QUERY_STORE_BY_STOREANDCHAN(ParameterList1);

            if (dtTemp != null && dtTemp.Rows.Count != 0 && dtTemp.Rows[0]["STORE_OPEN_DATE"] != null && dtTemp.Rows[0]["STORE_OPEN_DATE"].ToString().Trim() != "")
            {
                s_STORE_OPEN_DATE = DateTime.Parse(dtTemp.Rows[0]["STORE_OPEN_DATE"].ToString()).ToString("yyyy/MM/dd");
                s_STORE_NAME = dtTemp.Rows[0]["STORE_NAME"].ToString();
                bResult = true;
            }
            else
            {
                s_STORE_OPEN_DATE = "";
                s_STORE_NAME = "";
                bResult = false;
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }

        return bResult;
        #endregion
    }
예제 #3
0
    /// <summary>
    /// 根據傳入參數取得商品庫存
    /// </summary>
    /// <param name="CHAN_NO"></param>
    /// <param name="STORE"></param>
    private void GetStock(string v_ROOT_NO, string v_Item, string v_Period)
    {

        //string SessionIDName = "CRM041_Stock" + PageTimeStamp.Value;
        if ((v_Item == String.Empty) || (v_Period == String.Empty))
        {
            v_Item = this.slp_down_ITEM.Text;
            v_Period = this.txt_down_PERIOD.Text;
        }

        ArrayList ParameterList = new ArrayList();//20091117


        if (v_ROOT_NO == String.Empty)
        {
            #region 依照品號取得所屬[群分類]、[大分類]

            ParameterList.Clear();
            BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", v_Item, "=", "and");

            BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
            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();//群分類
                v_ROOT_NO = s_ROOT_NO;
            }
            bco_itm = null;
            dt_Return.Dispose();

            #endregion
        }

        if (dtStock == null)
        {
            ParameterList.Clear();
            ParameterList.Add(v_ROOT_NO);
            ParameterList.Add(v_Item);
            ParameterList.Add(v_Period);
            ParameterList.Add(Session["UID"].ToString());
            BCO.QueryCRMCommon bco_Common = new BCO.QueryCRMCommon(ConntionDB);
            dtStock = bco_Common.QueryCRMItemPeriodStock(ParameterList);
            //Session["SessionID"] = SessionIDName;
            //Session[SessionIDName] = dtStock;
            bco_Common = null;
        }
    }
예제 #4
0
    /// <summary>
    /// 將變更後的內部變量this.CallBackValue返回給前台JavaScript方法ReceiveServerData(string Value)。

    /// </summary>
    /// <returns></returns>
    string ICallbackEventHandler.GetCallbackResult()
    {
        if (CallBackValue != string.Empty)
        {
            try
            {
                #region 取得頁面元件
                TextBox txt_up_CHAN_NO = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("TextBoxCode");//通路
                TextBox txt_up_CHAN_NAME = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("TextBoxName");//通路名稱

                TextBox txt_up_STORE = (TextBox)((ASP.stm_slp_slp_store_ascx)slp_up_STORE).FindControl("TextBoxCode");//門市

                TextBox txt_up_Z_O = (TextBox)((ASP.sys_slp_slp_codefile_ascx)slp_up_Z_O).FindControl("TextBoxCode");//營業所
                TextBox txt_up_Z_O_NAME = (TextBox)((ASP.sys_slp_slp_codefile_ascx)slp_up_Z_O).FindControl("TextBoxName");//營業所名稱

                TextBox txt_up_BUSDATE = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_up_BUSDATE).FindControl("TextBoxCode");//訂單日期
                TextBox txt_up_SALE_ID = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("TextBoxCode");//營業人員
                TextBox txt_up_SALE_NAME = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("TextBoxName");//營業人員名稱

                TextBox txt_up_BUSUID = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_BUSUID).FindControl("TextBoxCode");//訂單維護者

                Image img_up_CHAN_NO = (Image)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("Image1");//通路img
                Image img_up_STORE = (Image)((ASP.stm_slp_slp_store_ascx)slp_up_STORE).FindControl("Image1");//門市img
                Image img_up_BUSDATE = (Image)((ASP.wui_slp_slp_slpdate_ascx)slp_up_BUSDATE).FindControl("Image1");//訂單日期img
                Image img_up_SALE_ID = (Image)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("Image1");//營業人員img
                Image img_up_BUSUID = (Image)((ASP.sys_slp_slp_user_ascx)slp_up_BUSUID).FindControl("Image1");//訂單維護者img
                Image img_down_ITEM = (Image)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("Image1");//品號img
                Image img_down_REQUEST_QTY = (Image)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("Image1");//訂貨量img
                Image img_down_RTN_DDL = (Image)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("Image1");//退書截止日img

                TextBox txt_down_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxCode");//品號
                TextBox txt_down_ITEM_NAME = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxName");//品名
                TextBox txt_down_REQUEST_QTY = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxCode");//訂貨量
                TextBox txt_down_REQUEST_QTY_NAME = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxName");//訂貨量名稱
                TextBox txt_down_RTN_DDL = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("TextBoxCode");//退書截止日
                CheckBox chk_down_IS_OVERDUE = (CheckBox)((ASP.wui_slp_slp_boolean_ascx)slp_down_IS_OVERDUE).FindControl("C1");//逾期客訂
                #endregion
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Remove(0, sb.Length);
                CallBackValue = CallBackValue.Trim();
                string[] s_Client_String = System.Text.RegularExpressions.Regex.Split(CallBackValue, "<partition>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                ArrayList ParameterList = new ArrayList();//20091117

                #region 新增模式下異動欄位[門市]

                if (s_Client_String[0] == "新增模式下異動欄位[門市]")
                {
                    if (dtChainPOSetting != null)
                    { dtChainPOSetting = null; }

                    s_STORE = s_Client_String[1].ToString().Trim();//門市
                    s_CHAN_NO = s_Client_String[2].ToString().Trim();//通路

                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//門市
                    ParameterList.Add(s_Client_String[2]);//通路
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return = new DataTable();
                    BCO.MaintainStore bco = new BCO.MaintainStore(ConntionDB);
                    dt_Return = bco.QUERY_STORE_BY_STOREANDCHAN(ParameterList);

                    #endregion

                    #region 設定回傳Client端資訊
                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增模式下異動欄位[門市]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("查無門市資料<partition>");
                        sb.Append(txt_up_STORE.ClientID + "<partition>");//設定焦點的欄位
                        sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");
                        sb.Append(txt_up_Z_O.ClientID + "<partition>");
                        sb.Append(txt_up_SALE_ID.ClientID);
                    }
                    else
                    {
                        sb.Append("新增模式下異動欄位[門市]<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return.Rows[0]["CHAN_NO"].ToString() + "<partition_Detail>" + txt_up_CHAN_NO.ClientID + "<partition>");
                        sb.Append(dt_Return.Rows[0]["Z_O"].ToString() + "<partition_Detail>" + txt_up_Z_O.ClientID + "<partition>");
                        //sb.Append(dt_Return.Rows[0]["SAL_ID"].ToString() + "<partition_Detail>" + txt_up_SALE_ID.ClientID);
                        sb.Append(dt_Return.Rows[0]["SAL_ID"].ToString() + "<partition_Detail>" + txt_up_SALE_ID.ClientID + "<partition>");

                        sb.Append("<partition_Detail>" + txt_up_CHAN_NAME.ClientID + "<partition>");
                        sb.Append("<partition_Detail>" + txt_up_Z_O_NAME.ClientID + "<partition>");
                        sb.Append("<partition_Detail>" + txt_up_SALE_NAME.ClientID);

                        #region 取得通路PO控制設定

                        GetChainPOSetting(dt_Return.Rows[0]["CHAN_NO"].ToString(),
                                          dt_Return.Rows[0]["STORE"].ToString());

                        #endregion
                    }
                    #endregion
                }

                #endregion

                #region 新增或編輯模式下異動欄位[二段碼]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[二段碼]")
                {
                    #region 從資料庫查詢資料:群分類、品號、期別

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_Client_String[2]);//一段碼
                    ParameterList.Add(s_Client_String[3]);//二段碼

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

                    DataTable dt_Return = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return = bco.QueryItemPeriodInfoByBarcode(ParameterList);

                    #endregion

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增或編輯模式下異動欄位[二段碼]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("此一段碼/二段碼不存在對應商品期別資訊,請重新輸入<partition>");
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                        sb.Append(txt_down_ITEM.ClientID + "<partition>");
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");
                        sb.Append(txt_down_RTN_DDL.ClientID);
                    }
                    else
                    {
                        sb.Append("新增或編輯模式下異動欄位[二段碼]<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return.Rows[0]["ITEM"].ToString() + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");
                        sb.Append(dt_Return.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID + "<partition>");
                        sb.Append(DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);

                        //期別或品號有異動時,重取庫存
                        if (s_ITEM != dt_Return.Rows[0]["ITEM"].ToString() ||
                            s_PERIOD != dt_Return.Rows[0]["PERIOD"].ToString()
                           )

                        { dtStock = null; }
                        s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();
                        s_ITEM = dt_Return.Rows[0]["ITEM"].ToString();
                        s_PERIOD = dt_Return.Rows[0]["PERIOD"].ToString();

                        GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);
                    }
                }

                #endregion

                #region 新增或編輯模式下異動欄位[一段碼]onchange

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[一段碼]onchange")
                {
                    #region  根據一段碼帶出品號,最大發行期別,二段碼
                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_STORE);//通路
                    ParameterList.Add(s_Client_String[3]);//一段碼
                    ParameterList.Add(string.Empty);//二段碼
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return = bco.QueryItemPeriodInfoByBarcode2(ParameterList);


                    #endregion

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("此一段碼不存在已發行對應商品期別資訊,請重新輸入<partition>");
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                        sb.Append(txt_down_ITEM.ClientID + "<partition>");
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");
                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                        sb.Append(this.txt_down_BARCODE.ClientID);//設定焦點的欄位

                    }
                    else
                    {
                        if (dt_Return.Rows[0]["CAN_DELIVER"].ToString() == "1")
                        {
                            //期別或品號有異動時,重取庫存
                            dtStock = null;
                            s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();
                            s_ITEM = dt_Return.Rows[0]["ITEM"].ToString();
                            s_PERIOD = dt_Return.Rows[0]["PERIOD"].ToString();

                            GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);

                            sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");//找到對應商品期別資訊,設定商品期別
                            sb.Append("TRUE<partition>");
                            sb.Append(s_ITEM + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");
                            sb.Append(dt_Return.Rows[0]["PERIOD_BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                            sb.Append(DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID + "<partition>");
                            sb.Append(s_PERIOD + "<partition_Detail>" + this.txt_down_PERIOD.ClientID);
                        }
                        else
                        {
                            sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");
                            sb.Append("FALSE<partition>");
                            sb.Append("此一段碼對應品號" + s_ITEM + "客服區域限制不可出貨,請重新輸入<partition>");
                            sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                            sb.Append(txt_down_ITEM.ClientID + "<partition>");
                            sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");
                            sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");
                            sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                            sb.Append(this.txt_down_BARCODE.ClientID);//設定焦點的欄位
                        }
                    }
                    //sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");
                    //sb.Append("TRUE<partition>");
                    //sb.Append(txt_down_ITEM.ClientID + "<partition>"); //異動一段碼時,清空 Item、 Period 、退貨日、儲區、逾期客訂,設定焦點到ITEM
                    //sb.Append(this.txt_down_PERIOD.ClientID + "<partition>"); //期別
                    //sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); //二段碼
                    //sb.Append(txt_down_RTN_DDL.ClientID + "<partition>"); //預定退貨日
                    //sb.Append(this.txt_down_RECOMMAND_LOCATION);//建議儲區

                }

                #endregion

                #region 新增或編輯模式下異動欄位[品號/品名]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[品號/品名]")
                {
                    //s_PMA = string.Empty;//大分類
                    //s_ROOT_NO = string.Empty;//群分類
                    s_ITEM = s_Client_String[1].ToString().Trim();//品號

                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//品號
                    ParameterList.Add(s_CHAN_NO);//通路
                    ParameterList.Add(s_STORE);//門市                    
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return_1 = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return_1 = bco.GetMaxDeiveryPeriod2(ParameterList);

                    #endregion

                    if (dt_Return_1 == null || dt_Return_1.Rows.Count == 0 ||
                        dt_Return_1.Rows[0]["PERIOD"].ToString() == string.Empty)
                    {
                        sb.Length = 0;
                        sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("查無資料<partition>");
                        sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位

                    }
                    else
                    {
                        //設定品號、期別
                        s_ITEM = s_Client_String[1];
                        s_PERIOD = dt_Return_1.Rows[0]["PERIOD"].ToString();
                        //設定群分類、大分類
                        s_PMA = dt_Return_1.Rows[0]["PMA"].ToString();//大分類
                        s_ROOT_NO = dt_Return_1.Rows[0]["ROOT_NO"].ToString();//群分類

                        if (dt_Return_1.Rows[0]["CAN_DELIVER"].ToString() == "1")
                        {
                            sb.Length = 0;
                            sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                            sb.Append("TRUE<partition>");
                            sb.Append(dt_Return_1.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID);
                        }
                        else
                        {
                            sb.Length = 0;
                            sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                            sb.Append("FALSE<partition>");
                            sb.Append("客服區域限制不可出貨<partition>");
                            sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位
                        }

                        #region  OLD 取得商品主檔資訊

                        //DataTable dt_Return_2 = new DataTable();

                        //ParameterList.Clear();
                        //BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", s_Client_String[1], "=", "and");

                        //BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
                        //dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList);

                        //if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0)
                        //{
                        //    s_PMA = dt_Return_2.Rows[0]["PMA"].ToString();//大分類

                        //    s_ROOT_NO = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類
                        //}
                        //else
                        //{
                        //    sb = sb.Remove(0, sb.Length);
                        //    sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                        //    sb.Append("FALSE<partition>");
                        //    sb.Append("商品主檔中無對應品號<partition>");
                        //    sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位

                        //}

                        #endregion
                    }
                }

                #endregion

                #region 新增或編輯模式下異動欄位[期別]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[期別]")
                {
                    //期別或品號有異動時,重取庫存
                    if (s_ITEM != s_Client_String[3].ToString().Trim() ||
                          s_PERIOD != s_Client_String[4].ToString().Trim()
                       )

                    { dtStock = null; }

                    s_CHAN_NO = s_Client_String[1].ToString().Trim();//通路
                    s_STORE = s_Client_String[2].ToString().Trim();//門市

                    if (s_ITEM != s_Client_String[3].ToString().Trim())
                    {

                    }
                    s_ITEM = s_Client_String[3].ToString().Trim();//品號
                    s_PERIOD = s_Client_String[4].ToString().Trim();//期別


                    #region 檢查書店是否有未結案同品項訂單


                    if (s_Client_String[8] == string.Empty)
                    {

                        #region 從資料庫查詢資料

                        ParameterList.Clear();
                        ParameterList.Add(s_Client_String[1]);//通路
                        ParameterList.Add(s_Client_String[2]);//門市

                        ParameterList.Add(s_Client_String[3]);//品號
                        ParameterList.Add(s_Client_String[4]);//期別
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(this.txt_up_CODE.Text);//訂單單號

                        DataTable dt_Return_1 = new DataTable();
                        BCO.RecordCRMOrder bco_Record = new BCO.RecordCRMOrder(ConntionDB);
                        dt_Return_1 = bco_Record.CheckOrderItemExist(ParameterList);

                        #endregion

                        if (dt_Return_1.Rows.Count > 0)
                        {
                            sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                            sb.Append("檢查書店是否有未結案同品項訂單<partition>");
                            sb.Append("該門市已存在未結案之同品項訂單於訂單標號:[" + dt_Return_1.Rows[0]["CRM_REQUEST_NO"].ToString() + "],不可新增<partition>");
                            sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//設定焦點的欄位

                            sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                            sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                            sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                            sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                            sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                            sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                            sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                            sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                            sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                            sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                            sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區

                            return sb.ToString();
                        }
                    }

                    #endregion

                    #region 檢查牌價是否已經正確建立

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[2]);//門市
                    ParameterList.Add(s_Client_String[3]);//品號
                    ParameterList.Add(s_Client_String[4]);//期別
                    ParameterList.Add(DateTime.Today.ToString("yyyy/MM/dd")); // 系統日
                    ParameterList.Add(Session["UID"].ToString());
                    PIC.VDS2G.BSM.ALO.ProcessALOCommon co_process = new PIC.VDS2G.BSM.ALO.ProcessALOCommon(ConntionDB);
                    string sRes = co_process.CheckStAcceptDisPrice(ParameterList);
                    //bool bRes = co_process.CheckStAcceptDisPrice(ParameterList, null);
                    if (sRes != string.Empty)
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("檢查牌價是否已經正確建立<partition>");
                        sb.Append("期別" + s_PERIOD + "牌價未生效[" + sRes + "],不可新增<partition>");
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                        sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                        sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區
                        return sb.ToString();
                    }

                    #endregion

                    #region 設定二段碼、退書截止日與逾期客訂

                    string s_down_BARCODE = string.Empty;//一段碼
                    string s_down_PERIOD_BARCODE = string.Empty;//二段碼

                    string s_down_RTN_DDL = string.Empty;//退書截止日

                    s_down_BARCODE = s_Client_String[5];
                    s_down_PERIOD_BARCODE = s_Client_String[6];
                    s_down_RTN_DDL = s_Client_String[7];
                    BCO.QueryCRMCommon bco_Common = new BCO.QueryCRMCommon(ConntionDB);

                    // 不管原來有沒有值,只要品號改變,都重新查詢
                    //if (s_Client_String[5] == string.Empty ||//一段碼
                    //    s_Client_String[6] == string.Empty ||//二段碼

                    //    s_Client_String[7] == string.Empty)//退書截止日
                    //{
                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_Client_String[3]);//品號
                    ParameterList.Add(s_Client_String[4]);//期別
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return_2 = new DataTable();

                    dt_Return_2 = bco_Common.QueryItemPeriodInfo(ParameterList);

                    if (dt_Return_2.Rows.Count > 0)//有找到資料
                    {
                        s_down_BARCODE = dt_Return_2.Rows[0]["BARCODE"].ToString();
                        s_down_PERIOD_BARCODE = dt_Return_2.Rows[0]["PERIOD_BARCODE"].ToString();
                        s_down_RTN_DDL = DateTime.Parse(dt_Return_2.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd");

                    }
                    else//查無資料
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("設定二段碼、退書截止日與逾期客訂<partition>");
                        sb.Append("查無[一段碼][二段碼][退書截止日],無法新增<partition>");
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                        sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                        sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區

                        return sb.ToString();
                    }
                    //}

                    #endregion

                    #region 逾期客訂確認

                    TimeSpan time = new TimeSpan(11, 00, 00);
                    bool b_down_IS_OVERDUE = false;
                    DateTime d_Now;
                    DateTime d_RTN_DDL;

                    d_Now = DateTime.Now;
                    d_RTN_DDL = DateTime.Parse(s_down_RTN_DDL);

                    if (d_Now.DayOfWeek == DayOfWeek.Saturday ||
                        d_Now.DayOfWeek == DayOfWeek.Sunday ||
                        (d_Now.DayOfWeek == DayOfWeek.Friday && d_Now.TimeOfDay.CompareTo(time) >= 0))
                    {
                        //if (d_RTN_DDL.AddDays(-5).ToShortDateString().CompareTo(d_Now.ToShortDateString()) <= 0)
                        if (d_RTN_DDL.AddDays(-5).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        {
                            b_down_IS_OVERDUE = true;
                            b_IS_OVERDUE = true;
                        }
                    }
                    else
                    {
                        //if (d_RTN_DDL.AddDays(-2).ToShortDateString().CompareTo(d_Now.ToShortDateString()) <= 0)
                        if (d_RTN_DDL.AddDays(-2).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        {
                            b_down_IS_OVERDUE = true;
                            b_IS_OVERDUE = true;
                        }
                    }

                    //[@逾期客訂].檢查結果為True時,顯示Confirm訊息『商品已逾期,不可退貨,確定要新增?』

                    //使用者確認要新增時,可繼續編輯。

                    //使用者選擇不新增時,取消本筆明細新增。

                    if (b_down_IS_OVERDUE == true)
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("[逾期客訂]檢查結果為TRUE<partition>");
                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(s_ROOT_NO + "<partition>");//群分類

                        sb.Append(s_Client_String[3] + "<partition>");//品號
                        sb.Append(s_Client_String[4] + "<partition>");//期別
                        sb.Append(s_down_BARCODE + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(s_down_PERIOD_BARCODE + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(s_down_RTN_DDL + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);//退書截止日

                        return sb.ToString();
                    }
                    else
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("[逾期客訂]檢查結果為FALSE<partition>");
                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(s_down_BARCODE + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(s_down_PERIOD_BARCODE + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(s_down_RTN_DDL + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);//退書截止日
                    }

                    #endregion

                    #region 取得庫存資訊

                    GetStock(s_ROOT_NO, s_Client_String[3], s_Client_String[4]);

                    #endregion
                }

                #endregion

                #region 新增或編輯模式下異動欄位[期別]Confirm後

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[期別]Confirm後")
                {
                    if (dtStock != null)
                    { dtStock = null; }

                    if (s_Client_String[1] == "TRUE")//繼續編輯。
                    {
                        #region 取得商品主檔資訊

                        if (s_PMA == String.Empty || s_ROOT_NO == String.Empty)
                        {
                            DataTable dt_Return_2 = new DataTable();

                            ParameterList.Clear();
                            BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", slp_down_ITEM.Text, "=", "and");

                            BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
                            dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList);

                            if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0)
                            {
                                s_PMA = dt_Return_2.Rows[0]["PMA"].ToString();//大分類

                                s_ROOT_NO = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類
                            }
                            else
                            {
                                sb = sb.Remove(0, sb.Length);
                                sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>");
                                sb.Append("FALSE<partition>");
                                sb.Append("商品主檔中無對應品號<partition>");
                                sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位
                            }
                        }

                        #endregion

                        #region 取得庫存資訊

                        GetStock(s_ROOT_NO, s_Client_String[3], s_Client_String[4]);
                        #endregion
                    }
                    else if (s_Client_String[1] == "FALSE")//取消本筆明細新增。
                    {
                        #region 清空靜態變數

                        dtStock = null;//異動欄位[期別]
                        s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                        s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                        s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                        #endregion

                        #region 計算 dt_Detail 的筆數


                        int i_dt_Detail_Count = 0;
                        if (dt_Detail != null)
                        {
                            if (dt_Detail.GetChanges(DataRowState.Deleted) == null)
                            { i_dt_Detail_Count = dt_Detail.Rows.Count; }
                            else
                            { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; }
                        }

                        #endregion

                        sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>");
                        sb.Append(i_dt_Detail_Count.ToString() + "<partition>");//dt_Detail的筆數
                        sb.Append(this.hid_PageStatus.ClientID + "<partition>");//hid_PageStatus
                        sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                        sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼
                        sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                        sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量
                        sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱
                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                        sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路
                        sb.Append(txt_up_STORE.ClientID + "<partition>");//門市
                        sb.Append(txt_up_Z_O.ClientID + "<partition>");//營業所
                        sb.Append(txt_up_BUSDATE.ClientID + "<partition>");//訂單日期
                        sb.Append(txt_up_SALE_ID.ClientID + "<partition>");//營業人員
                        sb.Append(txt_up_BUSUID.ClientID + "<partition>");//訂單維護者
                        sb.Append(((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).ClientID + "<partition>");//訂單來源
                        sb.Append(this.txt_up_PO_SOURCE_NO.ClientID + "<partition>");//PO單號預設
                        sb.Append(this.txt_up_CODE.ClientID + "<partition>");//訂單編號
                        sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");//流水編號
                        sb.Append(img_up_CHAN_NO.ClientID + "<partition>");//通路img
                        sb.Append(img_up_STORE.ClientID + "<partition>");//門市img
                        sb.Append(img_up_BUSDATE.ClientID + "<partition>");//訂單日期img
                        sb.Append(img_up_SALE_ID.ClientID + "<partition>");//營業人員img
                        sb.Append(img_up_BUSUID.ClientID);//訂單維護者img
                    }
                }

                #endregion

                #region 新增或編輯模式下異動欄位[訂貨量]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[訂貨量]")
                {

                    #region 判斷庫存是否足夠
                    if ((dtStock == null) || (dtStock.Rows.Count < 1))
                    {

                        GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);
                    }
                    if (((dtStock == null) || (dtStock.Rows.Count < 1)) &&
                        (s_ROOT_NO != "2"))
                    {

                        sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("庫存量不足,請取消新增<partition>");
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                        return sb.ToString();
                    }
                    #endregion

                    DataView dvStock = new DataView(dtStock.Copy());

                    s_SRC_LOCATE_TYPE = string.Empty;
                    int i_REQUEST_QTY = 0;//畫面上使用者輸入的"訂貨量"
                    int i_ONHD_QTY = 0;//現有庫存量
                    int i_RESERVE_QTY = 0;//配本保留數
                    int i_Final_QTY = 0;//庫存儲區可配量
                    int i_DIS_ENABLE = 0;//可配量
                    string s_SRC_LOCATE_NO = string.Empty;//VDS_CRM_ORDER_DETL.SRC_LOCATE_NO欄位

                    i_REQUEST_QTY = int.Parse(s_Client_String[1]);

                    // 2009-07-30 cyshu 修改,逾期客訂可取退貨儲區庫存
                    #region [@群分類]=1(雜誌) 時

                    //if (s_ROOT_NO == "1" && s_Client_String[2] == "false")
                    if (s_ROOT_NO == "1")
                    {
                        #region 先檢查庫存儲區可用庫存

                        dvStock.RowFilter = "LOCATETYPE = '2'";
                        dvStock.Sort = "ONHD_QTY DESC";
                        #region Old Source
                        //if (dvStock.Count > 0)
                        //{
                        //    i_ONHD_QTY = 0;
                        //    i_RESERVE_QTY = 0;
                        //    for (int i = 0; i < dvStock.Count; i++)
                        //    {
                        //        i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                        //        i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                        //    }
                        //}
                        #endregion

                        #region new code
                        i_ONHD_QTY = 0;
                        i_RESERVE_QTY = 0;
                        bool b_Locate_Stock = false; //庫存儲區
                        for (int i = 0; i < dvStock.Count; i++)
                        {
                            i_ONHD_QTY = int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                            i_RESERVE_QTY = int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                            i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;//庫存儲區可配量
                            if (i_Final_QTY >= i_REQUEST_QTY)
                            {
                                s_SRC_LOCATE_TYPE = "2";
                                s_SRC_LOCATE_NO = dvStock[i]["LOCATE_NO"].ToString();//現有庫存儲區
                                try
                                {
                                    i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                                }
                                catch { i_DIS_ENABLE = 0; }
                                b_Locate_Stock = true;
                                break;
                            }
                        }
                        if (!b_Locate_Stock) //庫存儲區庫存不足
                        {

                            if (s_PMA == "13" ||
                                s_PMA == "14" ||
                                s_PMA == "15" ||
                                s_PMA == "16")
                            {
                                #region 外雜
                                sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                                sb.Append("FALSE<partition>");
                                sb.Append("外雜D儲區庫存量不足,無法新增訂單<partition>");
                                sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位

                                sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                                return sb.ToString();
                                #endregion
                            }
                            else
                            {
                                #region 檢查退貨儲區可用庫存

                                i_ONHD_QTY = 0;
                                i_RESERVE_QTY = 0;
                                i_Final_QTY = 0;
                                i_DIS_ENABLE = 0;
                                s_SRC_LOCATE_NO = string.Empty;

                                dvStock.RowFilter = "LOCATETYPE = '1'";
                                for (int i = 0; i < dvStock.Count; i++)
                                {
                                    i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                                    i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                                }

                                i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;

                                if (i_Final_QTY >= i_REQUEST_QTY)
                                {
                                    s_SRC_LOCATE_TYPE = "1";//退貨儲區
                                    s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                                    i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                                }
                                else
                                {
                                    sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                                    sb.Append("FALSE<partition>");
                                    sb.Append("庫存量不足,請取消新增<partition>");
                                    sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 
                                    sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                                    return sb.ToString();
                                }
                                #endregion
                            }

                        }
                        #endregion new code

                        #region old code2
                        //i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;//庫存儲區可配量

                        //// 庫存儲區可配量 >= 訂量時,設定建議儲區 = 庫存儲區
                        //if (i_Final_QTY >= i_REQUEST_QTY)
                        //{
                        //    s_SRC_LOCATE_TYPE = "2";//庫存儲區
                        //    s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                        //    try
                        //    {
                        //        i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                        //    }
                        //    catch { i_DIS_ENABLE = 0; }
                        //}
                        //else
                        //{
                        //    if (s_PMA == "13" ||
                        //        s_PMA == "14" ||
                        //        s_PMA == "15" ||
                        //        s_PMA == "16")
                        //    {
                        //        sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                        //        sb.Append("FALSE<partition>");
                        //        sb.Append("外雜D儲區庫存量不足,無法新增訂單<partition>");
                        //        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位

                        //        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                        //        return sb.ToString();
                        //    }
                        //    else
                        //    {
                        //        #region 檢查退貨儲區可用庫存

                        //        i_ONHD_QTY = 0;
                        //        i_RESERVE_QTY = 0;
                        //        i_Final_QTY = 0;
                        //        i_DIS_ENABLE = 0;
                        //        s_SRC_LOCATE_NO = string.Empty;

                        //        dvStock.RowFilter = "LOCATETYPE = '1'";
                        //        for (int i = 0; i < dvStock.Count; i++)
                        //        {
                        //            i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                        //            i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                        //        }

                        //        i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;

                        //        if (i_Final_QTY >= i_REQUEST_QTY)
                        //        {
                        //            s_SRC_LOCATE_TYPE = "1";//退貨儲區
                        //            s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                        //            i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                        //        }
                        //        else
                        //        {
                        //            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                        //            sb.Append("FALSE<partition>");
                        //            sb.Append("庫存量不足,請取消新增<partition>");
                        //            sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 
                        //            sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                        //            return sb.ToString();
                        //        }

                        //        #endregion
                        //    }
                        //}

                        #endregion old code2
                        #endregion
                    }

                    #endregion

                    #region [@群分類]=2(圖書)

                    else
                    {
                        dvStock.RowFilter = "LOCATETYPE = '2'";
                        dvStock.Sort = "ONHD_QTY DESC";

                        if (dvStock.Count > 0)
                        {
                            // 先作預設值
                            s_SRC_LOCATE_TYPE = "2"; // 庫存儲區
                            s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區

                            for (int i = 0; i < dvStock.Count; i++)
                            {
                                i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                                i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                            }

                            i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;

                            if (i_Final_QTY >= i_REQUEST_QTY)
                            {
                                s_SRC_LOCATE_TYPE = "2";//庫存儲區
                                s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                                i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                            }
                            else //圖書庫存不足仍可新增
                            {
                                s_SRC_LOCATE_TYPE = "2";//庫存儲區
                                s_SRC_LOCATE_NO = "D";
                                i_DIS_ENABLE = 0;
                                sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                                sb.Append("TRUE_ALERT<partition>");
                                sb.Append("圖書庫存不足,確認要新增?<partition>");
                                sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                                sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);
                                return sb.ToString();
                            }
                        }
                        else //圖書庫存不足仍可新增
                        {
                            #region 圖書庫存不足仍可新增
                            s_SRC_LOCATE_TYPE = "2";//庫存儲區
                            s_SRC_LOCATE_NO = "D";
                            i_DIS_ENABLE = 0;
                            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                            sb.Append("TRUE_ALERT<partition>");
                            sb.Append("圖書庫存不足,確認要新增?<partition>");
                            sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                            sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);
                            return sb.ToString();
                            #endregion
                        }
                    }

                    #endregion

                    if (sb.ToString() == string.Empty)
                    {
                        if (i_REQUEST_QTY > 100)
                        {
                            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                            sb.Append("TRUE_ALERT<partition>");
                            sb.Append("訂貨量大於100<partition>");
                            sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                            sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);

                            return sb.ToString();
                        }
                        else
                        {
                            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                            sb.Append("TRUE_NO_ALERT<partition>");
                            sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                            sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);

                            return sb.ToString();
                        }
                    }
                }

                #endregion

                #region 新增或編輯模式按下明細區[取消]鈕

                else if (s_Client_String[0] == "新增或編輯模式按下明細區[取消]鈕")
                {
                    #region 清空靜態變數

                    dtStock = null;//異動欄位[期別]
                    s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                    s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                    s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])
                    sb.Remove(0, sb.Length);

                    #endregion

                    #region 計算 dt_Detail 的筆數

                    int i_dt_Detail_Count = 0;
                    if (dt_Detail != null)
                    {
                        if (dt_Detail.GetChanges(DataRowState.Deleted) == null)
                        { i_dt_Detail_Count = dt_Detail.Rows.Count; }
                        else
                        { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; }
                    }

                    #endregion

                    sb.Append("新增或編輯模式按下明細區[取消]鈕<partition>");
                    sb.Append(i_dt_Detail_Count.ToString() + "<partition>");//dt_Detail的筆數
                    sb.Append(this.hid_PageStatus.ClientID + "<partition>");//hid_PageStatus
                    sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                    sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                    sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                    sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                    sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                    sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼
                    sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                    sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                    sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                    sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量
                    //sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱
                    sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                    sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                    sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路
                    sb.Append(txt_up_STORE.ClientID + "<partition>");//門市
                    sb.Append(txt_up_Z_O.ClientID + "<partition>");//營業所
                    sb.Append(txt_up_BUSDATE.ClientID + "<partition>");//訂單日期
                    sb.Append(txt_up_SALE_ID.ClientID + "<partition>");//營業人員
                    sb.Append(txt_up_BUSUID.ClientID + "<partition>");//訂單維護者
                    sb.Append(((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).ClientID + "<partition>");//訂單來源
                    sb.Append(this.txt_up_PO_SOURCE_NO.ClientID + "<partition>");//PO單號預設
                    sb.Append(this.txt_up_CODE.ClientID + "<partition>");//訂單編號
                    sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");//流水編號
                    sb.Append(img_up_CHAN_NO.ClientID + "<partition>");//通路img
                    sb.Append(img_up_STORE.ClientID + "<partition>");//門市img
                    sb.Append(img_up_BUSDATE.ClientID + "<partition>");//訂單日期img
                    sb.Append(img_up_SALE_ID.ClientID + "<partition>");//營業人員img
                    sb.Append(img_up_BUSUID.ClientID);//訂單維護者img
                }

                #endregion

                #region 新增或編輯模式按下GridView[編輯]鈕


                else if (s_Client_String[0] == "新增或編輯模式按下GridView[編輯]鈕")
                {
                    DataRow dRow = dt_Detail.Select("ID = " + s_Client_String[1])[0];
                    string s_IS_OVERDUE;
                    //改為已擷轉仍可修改 
                    //if (dRow["TRANS_RESULT"].ToString() == "1")//已擷轉
                    //{ sb.Append("此筆訂單品項已擷轉,不可編輯或刪除\r\n"); }

                    if (dRow["STATUS"].ToString() == "75")//已結案
                    { sb.Append("此筆訂單品項已結案,不可編輯或刪除\r\n"); }

                    #region 編輯前檢查錯誤


                    if (sb.ToString() != string.Empty)
                    {
                        sb.Insert(0, "新增或編輯模式按下GridView[編輯]鈕_編輯前檢查FALSE<partition>");
                        return sb.ToString();
                    }

                    #endregion

                    #region 取得庫存
                    i_Curr_Order_Qty = 0;
                    s_ROOT_NO = dRow["ROOT_NO"].ToString(); //群分類
                    s_ITEM = dRow["ITEM"].ToString();    //品號
                    s_PERIOD = dRow["PERIOD"].ToString();  //期別
                    i_Curr_Order_Qty = (dRow["REQUEST_QTY"].ToString().Trim() == string.Empty) ? 0 : int.Parse(dRow["REQUEST_QTY"].ToString().Trim());
                    s_SRC_LOCATE_NO = dRow["SRC_LOCATE_NO"].ToString();//原儲區
                    //取得目前庫存
                    dtStock = null;
                    GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);
                    //編輯模式下,可用庫存應加上原訂單需求量
                    AddStockForEditMode(s_SRC_LOCATE_NO, i_Curr_Order_Qty);
                    #endregion

                    #region 編輯前檢查正確
                    s_IS_OVERDUE = (dRow["IS_OVERDUE"].ToString() == "0") ? "false" : "true";

                    sb.Append("新增或編輯模式按下GridView[編輯]鈕_編輯前檢查TRUE<partition>");
                    sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路
                    sb.Append(txt_up_STORE.ClientID + "<partition>");//門市

                    sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                    sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                    sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                    sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                    sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                    sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                    sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                    sb.Append(s_IS_OVERDUE + "<partition_Detail>" + chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                    sb.Append(dRow["PO_SOURCE_NO"].ToString() + "<partition_Detail>" + this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                    sb.Append(dRow["BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                    sb.Append(dRow["PERIOD_BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                    sb.Append(dRow["ITEM"].ToString() + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");//品號
                    sb.Append(dRow["ITEM_NAME"].ToString() + "<partition_Detail>" + txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                    sb.Append(dRow["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID + "<partition>");//期別
                    sb.Append(dRow["REQUEST_QTY"].ToString() + "<partition_Detail>" + txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                    //sb.Append(dRow["REQUEST_QTY"].ToString() + ".0000<partition_Detail>" + txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                    sb.Append(DateTime.Parse(dRow["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                    sb.Append(dRow["SRC_LOCATE_NO"].ToString() + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                    sb.Append(dRow["ID"].ToString() + "<partition_Detail>" + this.hid_ID.ClientID);//hid_ID

                    #endregion
                }

                #endregion

                #region 新增或編輯模式按下明細區[新增明細]鈕

                else if (s_Client_String[0] == "新增或編輯模式按下明細區[新增明細]鈕")
                {
                    #region 清空靜態變數

                    dtStock = null;//異動欄位[期別]
                    s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                    s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                    s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                    #endregion
                }

                #endregion

                #region 新增模式異動欄位[流水編號]

                else if (s_Client_String[0] == "新增模式異動欄位[流水編號]")
                {
                    #region 檢查是否為有效流水編號


                    DataTable dt_Return = new DataTable();

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//流水編號
                    ParameterList.Add(Session["UID"].ToString());
                    ParameterList.Add(DateTime.Now);

                    BCO.RecordCRMRecord bco = new BCO.RecordCRMRecord(ConntionDB);
                    dt_Return = bco.QueryCRMRecordByCode_CheckExist(ParameterList);

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增模式異動欄位[流水編號]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");
                        sb.Append("[流水編號]不為存在的有效編號");
                    }

                    #endregion
                }

                #endregion

                CallBackValue = sb.ToString();
            }
            catch (Exception ex)
            { CallBackValue = "發生例外錯誤<partition>" + ex.Message; }
        }

        return CallBackValue;
    }
예제 #5
0
    /// <summary>
    /// 一段碼
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strStore"></param>
    /// <param name="strBarcode"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    /// <returns></returns>
    private string GetValueByPageMethod_BARCODE(string strChan, string strStore, string strBarcode, string strUserID, string strPageTimeStamp)
    {
        #region

        string strRtn = "", strTemp1 = "", strTemp2 = "";

        try
        {
            #region  根據一段碼帶出品號,最大發行期別,二段碼
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(strChan);//通路
            ParameterList.Add(strStore);//門市
            ParameterList.Add(strBarcode);//一段碼
            ParameterList.Add("");//二段碼
            ParameterList.Add(strUserID);

            DataTable dt_Return = new DataTable();
            BCO_CRM.QueryCRMCommon BCO1 = new BCO_CRM.QueryCRMCommon(ConntionDB);
            dt_Return = BCO1.QueryItemPeriodInfoByBarcode2(ParameterList);
            BCO1.CloseConnection();

            #endregion

            if (dt_Return.Rows.Count == 0)
            {
                strTemp1 = string.Format("FALSE");
                strTemp2 = string.Format("此一段碼不存在已發行對應商品期別資訊,請重新輸入");
            }
            else
            {
                if (dt_Return.Rows[0]["CAN_DELIVER"].ToString() == "1")
                {
                    #region
                    //期別或品號有異動時,重取庫存
                    Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = null;
                    Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["ROOT_NO"].ToString();
                    Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["ITEM"].ToString();
                    Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["PERIOD"].ToString();

                    GetStockByPageMethod(Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString(), Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString(), strUserID, strPageTimeStamp);

                    strTemp1 = string.Format("TRUE");
                    strTemp2 = string.Format("{0}-{1}-{2}-{3}",
                        Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString(),
                        Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString(),
                        dt_Return.Rows[0]["PERIOD_BARCODE"].ToString(),
                        DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd"));
                    #endregion
                }
                else
                {
                    #region
                    strTemp1 = string.Format("FALSE");
                    strTemp2 = string.Format("此一段碼對應品號:[{0}]客服區域限制不可出貨,請重新輸入",
                        Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString());
                    #endregion
                }
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }

        return strRtn = string.Format("{0};{1}", strTemp1, strTemp2);
        #endregion
    }
예제 #6
0
    private void QueryData()
    {
        #region
        string SessionIDName = "CRM20" + PageTimeStamp.Value;

        ParameterList.Clear();
        ParameterList.Add("%" + txtItemName.Text.Trim() + "%");
        ParameterList.Add(SLP_Item.Text.Trim());
        ParameterList.Add(Session["UID"].ToString());
        ParameterList.Add(SLP_ItemPeriod1.Text.Trim());
        ParameterList.Add(txt_Barcode.Text.Trim());

        BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

        DataTable dt = bco.QueryItemAndStock(ParameterList);

        if (dt.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "查無資料";
            Session[SessionIDName] = null;
            GridView1.DataBind();
            Panel_DetailQuery.Visible = false;
        }
        else
        {

            Session[SessionIDName] = dt;
            GridView1.DataSource = dt;
            GridView1.DataBind();
            Panel_DetailQuery.Visible = true;
        }
        #endregion
    }
예제 #7
0
    /// <summary>
    /// 檢查畫面條件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected System.Text.StringBuilder CheckPage()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        TextBox txt_Store = (TextBox)this.slp_Store.FindControl("TextBoxCode");
        TextBox txt_StoreChain = (TextBox)this.slp_StoreChain.FindControl("TextBoxCode");


        #region 檢查必填欄位
        if ((slp_Crm_Date.Text == "" || slp_Crm_Date.Text == "____/__/__") &&
             slp_Store.Text == "" && slp_StoreChain.Text == "")
        {
            throw new Exception("請至少輸入一項查詢條件");
        }

        #endregion
        //if (txt_Store.Text.Trim() == string.Empty)
        //{ sb.Append("門市欄位不可空白\\r\\n"); }
        //if (txt_StoreChain.Text.Trim() == string.Empty)
        //{ sb.Append("通路欄位不可空白\\r\\n"); }

        //檢查門市是否屬於該通路
        if ((this.slp_Store.Text != "") && (this.slp_StoreChain.Text != ""))
        {
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(this.slp_StoreChain.Text); // 通路
            ParameterList.Add(this.slp_Store.Text);      // 門市
            ParameterList.Add(Session["UID"].ToString());
            BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
            bool b_CheckRes;
            b_CheckRes = bco.CheckChanAndStore(ParameterList);
            if (!b_CheckRes)
            {
                sb.AppendFormat("門市[{1}]不屬於通路[{0}]! 請重新輸入查詢條件!",
                                                   this.slp_StoreChain.Text,
                                                   this.slp_Store.Text);
            }
        }

        return sb;
    }
예제 #8
0
    /// <summary>
    /// 品號
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strStore"></param>
    /// <param name="strItem"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    /// <returns></returns>
    private string GetValueByPageMethod_ITEM(string strChan, string strStore, string strItem, string strUserID, string strPageTimeStamp)
    {
        #region

        string strRtn = "", strTemp = "";
        bool bResult = false;

        try
        {
            #region
            //set s_ITEM by using PageMethod
            Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)] = strItem;

            #region 從資料庫查詢資料

            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(strItem);//品號
            ParameterList.Add(strChan);//通路
            ParameterList.Add(strStore);//門市                    
            ParameterList.Add(strUserID);

            DataTable dt_Return_1 = new DataTable();
            BCO_CRM.QueryCRMCommon BCO1 = new BCO_CRM.QueryCRMCommon(ConntionDB);
            dt_Return_1 = BCO1.GetMaxDeiveryPeriod2(ParameterList);
            BCO1.CloseConnection();
            #endregion

            if (dt_Return_1 == null || dt_Return_1.Rows.Count == 0 || dt_Return_1.Rows[0]["PERIOD"].ToString() == string.Empty)
            {
                #region
                bResult = false;
                strTemp = string.Format("{0};{1}", 0, "查無資料");
                #endregion
            }
            else
            {
                #region
                //設定品號、期別
                //s_ITEM
                //s_PERIOD    
                Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)] = strItem;
                Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)] = dt_Return_1.Rows[0]["PERIOD"].ToString();

                //設定群分類、大分類
                //s_PMA
                //s_ROOT_NO
                Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = dt_Return_1.Rows[0]["ROOT_NO"].ToString();//群分類
                Session[string.Format("CRM041_s_PMA_{0}", strPageTimeStamp)] = dt_Return_1.Rows[0]["PMA"].ToString();//大分類

                if (dt_Return_1.Rows[0]["CAN_DELIVER"].ToString() == "1")
                {
                    bResult = true;
                    strTemp = string.Format("{0};{1}", 1, dt_Return_1.Rows[0]["PERIOD"].ToString());
                }
                else
                {
                    bResult = false;
                    strTemp = string.Format("{0};{1}", 2, "客服區域限制不可出貨");
                }
                #endregion
            }
            #endregion
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return strRtn = string.Format("{0};{1}", bResult.ToString().ToUpper(), strTemp);
        #endregion
    }
예제 #9
0
    public static ALOModel.ALOCommon.PERIODWithSTOCK GetPeriodWithStock(ALOModel.ALOCommon.PERIODWithSTOCK PeriodStockObject,
                                                                        string ProcessUID,
                                                                        string RootNo,
                                                                        string StAcceptDate
                                                                        )
    {

        try
        {

            #region 期別處理

            ALOModel.MaintainDisRecord PeriodProc = new ALOModel.MaintainDisRecord(ConnectionDB);
            string ErrorMsg = "";
            string AlertMsg = "";

            #region 輸入變數
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            //品號
            ParameterList.Add(PeriodStockObject.Item);
            //期別
            ParameterList.Add(PeriodStockObject.Period);
            //門市進貨日 2009-07-02 cyhsu add
            ParameterList.Add(StAcceptDate);
            #endregion

            Hashtable ht = PeriodProc.CheckItemPeriodDisStateInfo(ParameterList, ref ErrorMsg, ref AlertMsg);

            if (ErrorMsg == "")//無錯誤
            {
                if (ht != null)
                {
                    //期別存在判斷
                    PeriodStockObject.PeriodExist = ht["PERIODEXIST"].ToString();
                    //配本日期
                    PeriodStockObject.DisDate = ht["DIS_DATE"].ToString();
                    //前一期別
                    PeriodStockObject.Period1 = ht["P_B1"].ToString();
                    //前二期別
                    PeriodStockObject.Period2 = ht["P_B2"].ToString();
                    //前三期別
                    PeriodStockObject.Period3 = ht["P_B3"].ToString();
                    //前四期別
                    PeriodStockObject.Period4 = ht["P_B4"].ToString();
                    //前五期別
                    PeriodStockObject.Period5 = ht["P_B5"].ToString();
                    //前六期別
                    PeriodStockObject.Period6 = ht["P_B6"].ToString();
                }
                //期別錯誤訊息
                PeriodStockObject.PeriodErrorMsg = ErrorMsg;
                //期別提示訊息
                PeriodStockObject.PeriodAlertMsg = AlertMsg;
            }

            #endregion

            #region 庫存處理

            if (ErrorMsg == "") //無錯誤
            {
                CRMModel.QueryCRMCommon StockProc = new CRMModel.QueryCRMCommon(ConnectionDB);

                #region 輸入變數

                ParameterList.Clear();
                //品號
                ParameterList.Add(PeriodStockObject.Item);
                //期別
                ParameterList.Add(PeriodStockObject.Period);
                //儲區類別(進貨)
                ParameterList.Add((int)PeriodStockLOCATEATTR.ToStockWithGoods);
                //使用者代碼            
                ParameterList.Add(ProcessUID);

                #endregion

                DataTable StockDt = StockProc.QueryItemPeriodStock(ParameterList);

                if (StockDt.Rows.Count > 0)
                {
                    //到貨數
                    PeriodStockObject.AcceptQTY = (StockDt.Rows[0]["ONHD_QTY"] == null) ? "0" : StockDt.Rows[0]["ONHD_QTY"].ToString();
                    //保留數
                    PeriodStockObject.ReserveQTY = (StockDt.Rows[0]["RESERVE_QTY"] == null) ? "0" : StockDt.Rows[0]["RESERVE_QTY"].ToString();
                    //實配數
                    PeriodStockObject.DISQTY = "0";
                    //預留數 = 到貨數 - 實配數 - 保留數 
                    int DISMDCQTY = int.Parse(PeriodStockObject.AcceptQTY) -
                                    int.Parse(PeriodStockObject.DISQTY) -
                                    int.Parse(PeriodStockObject.ReserveQTY);

                    PeriodStockObject.DISMDCQTY = DISMDCQTY.ToString();
                }
                else
                {
                    //到貨數
                    PeriodStockObject.AcceptQTY = "0";
                    //保留數
                    PeriodStockObject.ReserveQTY = "0";
                    //實配數
                    PeriodStockObject.DISQTY = "0";
                    //預留數 = 到貨數 - 實配數 - 保留數 
                    PeriodStockObject.DISMDCQTY = "0";
                }
            }

            #endregion

            #region 採購數處理

            if (ErrorMsg == "") //無錯誤
            {
                ALOModel.QueryALOCommon OrderQTYProc = new ALOModel.QueryALOCommon(ConnectionDB);

                #region 輸入變數

                ParameterList.Clear();
                //品號
                ParameterList.Add(PeriodStockObject.Item);
                //期別
                ParameterList.Add(PeriodStockObject.Period);
                //群分類代號
                ParameterList.Add(RootNo);

                #endregion

                PeriodStockObject.DISISUQTY = OrderQTYProc.QueryPurchaseQty(ParameterList).ToString();

            }

            #endregion

            return PeriodStockObject;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
예제 #10
0
    private void GetItemPeriodStock(string strItem, string strPeriod)
    {
        #region

        try
        {

            CRMModel.QueryCRMCommon BCO = new CRMModel.QueryCRMCommon(ConnectionDB);

            DataTable dtTemp = new DataTable();
            dtTemp.Clear();

            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();

            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);
            ParameterList.Add("0");//2009-10-08 cyhsu :0進貨1退貨2庫存
            ParameterList.Add(Session["UID"].ToString());
            dtTemp = BCO.QUERY_ITEM_PERIODSTOCK(ParameterList);

            i_ONHD_QTY = 0;
            i_ACCEPT_QTY = 0;
            i_RESERVE_QTY = 0;
            i_DIS_QTY = 0;
            i_DIS_MDC_QTY = 0;
            i_DIS_ISU_QTY = 0;

            if (dtTemp != null && dtTemp.Rows.Count != 0)
            {
                i_ONHD_QTY = Int32.Parse(dtTemp.Rows[0]["ONHD_QTY"].ToString());//庫存數
                i_ACCEPT_QTY = Int32.Parse(dtTemp.Rows[0]["ONHD_QTY"].ToString());//到貨數
                i_RESERVE_QTY = Int32.Parse(dtTemp.Rows[0]["RESERVE_QTY"].ToString());//保留數
                i_DIS_QTY = 0;// Int32.Parse(dtTemp.Rows[0]["DIS_QTY"].ToString());//實配數
                i_DIS_MDC_QTY = i_ONHD_QTY - i_DIS_QTY - i_RESERVE_QTY;//預留數
            }

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

            ArrayList ParameterList1 = new ArrayList();
            ParameterList1.Clear();
            ParameterList1.Add(strItem);
            ParameterList1.Add(strPeriod);
            ParameterList1.Add(s_ROOT_NO);

            i_DIS_ISU_QTY = BCO2.QueryPurchaseQty(ParameterList1);//採購數

        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion
    }
예제 #11
0
    /// <summary>
    /// 異動欄位[@品號/品名]設定值後
    /// </summary>
    /// <param name="strItem"></param>
    /// <param name="strUserID"></param>
    /// <returns></returns>
    private DataTable GetPeriodByItem(string strItem,string strUserID)
    {
        #region
        try
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(strItem);//品號
            ParameterList.Add(strUserID);
            CRMModel.QueryCRMCommon BCO = new CRMModel.QueryCRMCommon(ConnectionDB);
            return BCO.GetMaxDeiveryPeriod(ParameterList);
        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion
    }
예제 #12
0
    /// <summary>
    /// 異動欄位[@二段碼]設定值後
    /// </summary>
    /// <param name="strChanNo"></param>
    /// <param name="strBarcode"></param>
    /// <param name="strPeriodBarcode"></param>
    /// <param name="strUserID"></param>
    /// <returns></returns>
    private DataTable GetItemPeriodByBarCode(string strChanNo, string strBarcode, string strPeriodBarcode, string strUserID)
    {
        #region
        try
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(strChanNo);//通路
            ParameterList.Add(strBarcode);//一段碼
            ParameterList.Add(strPeriodBarcode);//二段碼
            ParameterList.Add(strUserID);
            CRMModel.QueryCRMCommon BCO = new CRMModel.QueryCRMCommon(ConnectionDB);
            return BCO.QueryItemPeriodInfoByBarcode(ParameterList);
        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion
    }
예제 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = string.Empty;
            AuthorityControls(this);

            if (!IsPostBack)
            { //寫入首次載入Page TimeStamp
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );
                ToolBarInit();

                TextBox txt_DateRange_B = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode"); ;
                TextBox txt_DateRange_E = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode"); ;

                #region  設定TabIndex
                txt_DateRange_B.TabIndex = 1;
                txt_DateRange_E.TabIndex = 2;
                slp_CHAN_NO.TextBox_Code.TabIndex = 3;
                slp_STORE.TextBox_Code.TabIndex = 4;
                slp_ITEM.TextBox_Code.TabIndex = 5;
                slp_Z_O_B.TextBox_Code.TabIndex = 6;
                slp_Z_O_E.TextBox_Code.TabIndex = 7;
                slp_MANUFACTURE_B.TextBox_Code.TabIndex = 8;
                slp_MANUFACTURE_E.TextBox_Code.TabIndex = 9;
                txt_Out_FileName.TabIndex = 10;
                but_Print.TabIndex = 11;
                but_Out.TabIndex = 12;
                #endregion

                #region 設定長度
                slp_STORE.TextBox_Name.Width = 200;
                slp_MANUFACTURE_B.TextBox_Name.Width = 200;
                slp_MANUFACTURE_E.TextBox_Name.Width = 200;
                #endregion

                #region 設定訂單狀況

                //預設為未結案
                this.rdb_STATUS.SelectedIndex = 1;
                //2010-05-06 新增列印本日訂單類別
                this.rdb_PrinTodayType.SelectedIndex = 0;
                #endregion

                #region 設定表單類別

                //預設為明細表
                this.rdb_Report_Status.SelectedIndex = 0;

                #endregion

                #region Attributes

                TextBox txt_BUSDATE_B = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode");//訂單日期起
                TextBox txt_BUSDATE_E = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode");//訂單日期迄
                TextBox txt_CHAN_NO = (TextBox)this.slp_CHAN_NO.FindControl("TextBoxCode");//通路
                TextBox txt_STORE = (TextBox)this.slp_STORE.FindControl("TextBoxCode");//店號
                TextBox txt_MANUFACTURE_B = (TextBox)this.slp_MANUFACTURE_B.FindControl("TextBoxCode");//供應商起
                TextBox txt_MANUFACTURE_E = (TextBox)this.slp_MANUFACTURE_E.FindControl("TextBoxCode");//供應商迄
                TextBox txt_Z_O_B = (TextBox)this.slp_Z_O_B.FindControl("TextBoxCode");//營業所起
                TextBox txt_Z_O_E = (TextBox)this.slp_Z_O_E.FindControl("TextBoxCode");//營業所迄

                //this.but_Cancel.Attributes["onclick"] += String.Format("SetButtonEnabled('true',{0},{1},{2});",
                //      this.but_Print.ClientID, this.but_Out.ClientID, this.but_Cancel.ClientID);

                //        this.but_Print.Attributes["onclick"] += String.Format("SetButtonEnabled('false',{0},{1},{2});__doPostBack({3},'');",
                //this.but_Print.ClientID, this.but_Out.ClientID, this.but_Cancel.ClientID, this.but_Print.UniqueID);

                #region 設定結束欄位預設值=開始欄位設定值

                //txt_BUSDATE_B.Attributes.Add("onblur", "SetTheSameValue1('" + txt_BUSDATE_B.ClientID + "','" + txt_BUSDATE_E.ClientID + "','Date');");
                txt_Z_O_B.Attributes.Add("onblur", "SetTheSameValue2('" + txt_Z_O_B.ClientID + "','" + txt_Z_O_E.ClientID + "','String');");
                txt_MANUFACTURE_B.Attributes.Add("onblur", "SetTheSameValue2('" + txt_MANUFACTURE_B.ClientID + "','" + txt_MANUFACTURE_E.ClientID + "','String');");

                #endregion

                #region 檢查結束欄位一定要大於或等於開始欄位

                txt_BUSDATE_E.Attributes.Add("onblur", "CheckValue('" + txt_BUSDATE_B.ClientID + "','" + txt_BUSDATE_E.ClientID + "');");
                txt_Z_O_E.Attributes.Add("onblur", "CheckValue('" + txt_Z_O_B.ClientID + "','" + txt_Z_O_E.ClientID + "');");
                txt_MANUFACTURE_E.Attributes.Add("onblur", "CheckValue('" + txt_MANUFACTURE_B.ClientID + "','" + txt_MANUFACTURE_E.ClientID + "');");

                #endregion

                #region 異動欄位[店號]設定值後

                txt_STORE.Attributes.Add("onblur", @"
if(this.value!='' &&
   document.all['" + txt_CHAN_NO.ClientID + @"'].value == '')
{
    CallServer_STORE('異動欄位[店號]設定值後<partition>' + this.value);
}");

                #endregion

                #endregion

                #region 預設系統功能鍵

                this.Form.Attributes.Add("onkeypress", "return WebForm_FireDefaultButton_Self(event,'" + this.but_Print.ClientID + "');");

                #endregion

                #region 設定RequiredFieldValidator

                //RequiredFieldValidator rfv_BUSDATE_B = (RequiredFieldValidator)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate1")).FindControl("RequiredFieldValidator1");//訂單日期起

                //rfv_BUSDATE_B.Enabled = true;
                //rfv_BUSDATE_B.ValidationGroup = "Validate";
                //rfv_BUSDATE_B.ErrorMessage = "[訂單日期]起日<br/>為必填欄位";
                //rfv_BUSDATE_B.SetFocusOnError = true;

                //RequiredFieldValidator rfv_BUSDATE_E = (RequiredFieldValidator)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate2")).FindControl("RequiredFieldValidator1");//訂單日期迄

                //rfv_BUSDATE_E.Enabled = true;
                //rfv_BUSDATE_E.ValidationGroup = "Validate";
                //rfv_BUSDATE_E.ErrorMessage = "[訂單日期]迄日<br/>為必填欄位";
                //rfv_BUSDATE_E.SetFocusOnError = true;

                #endregion

                #region 設定 hid_PageStauts 狀態

                this.hid_PageStauts.Value = "open";
                string s_ScriptManager_Script = @"
Set_Print_PageStatus
(
'" + this.PanelQuery.ClientID + @"',
'" + this.but_Print.ClientID + @"',
'" + this.but_Close.ClientID + @"',
'" + this.hid_PageStauts.Value + @"'
);
";
                ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "CRM161", s_ScriptManager_Script, true);

                #endregion

            }
            #region 取得使用者名稱及角色
            BCO.QueryCRMCommon comm = new BCO.QueryCRMCommon(ConntionDB);
            comm.GetUserAndRoleName(Session["UID"].ToString(), ref s_UserName, ref s_RoleName);

            UserID.Value = s_UserName;
            UserRole.Value = s_RoleName;
            #endregion

            #region 註冊 AJAX SCRIPT

            RegClientScript();

            #endregion

            #region 清空 CrystalReportViewer

            this.CryView.ReportSource = null;

            #endregion

            #region ToolBar 設定

            WUI_GMToolbarV uc = (WUI_GMToolbarV)this.GMToolbar1;
            uc.Btn_FindExport += new WUI_GMToolbarV.UCDelegate(UC_Export);

            #endregion

            #region 按下CrystalReportViewer的[匯出這份報表]

            if (this.hid_PageStauts.Value == "close")
            {
                if (Session["Rpt_Data" + PageTimeStamp.Value] != null)
                {
                    Show_Report((DataTable)Session["Rpt_Data" + PageTimeStamp.Value]);
                }
            }
            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
예제 #14
0
    private bool CheckCanDeliver(string s_Item, string s_ChanNo, string s_Store)
    {
        #region
        bool bResult = true;
        try
        {
            DataTable dtTemp = dtStorePOSetting;
            ArrayList ParameterList1 = new ArrayList();

            ParameterList1.Clear();
            ParameterList1.Add(s_Item);
            ParameterList1.Add(s_ChanNo);
            ParameterList1.Add(s_Store);
            ParameterList1.Add(Session["UID"].ToString());
            PIC.VDS2G.BSM.CRM.QueryCRMCommon crm_bco = new PIC.VDS2G.BSM.CRM.QueryCRMCommon(ConnectionDB);
            bResult = crm_bco.CheckCanDeliver_Web(ParameterList1);



        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        return bResult;

        #endregion
    }
예제 #15
0
    /// <summary>
    /// 繫結資料
    /// </summary>
    private void BindingData()
    {
        #region
        try 
        {

            if (dtDisTmpRecOld != null && dtDisTmpRecOld.Rows.Count > 0)
            {
                #region
                SLP_PARAM1.Text = dtDisTmpRecOld.Rows[0]["DIS_TYPE"].ToString().Trim();
                s_DIS_TYPE_Original = dtDisTmpRecOld.Rows[0]["DIS_TYPE"].ToString().Trim();
                #endregion
            }

            if (dtDisItemOld != null && dtDisItemOld.Rows.Count > 0)
            {
                #region
                txt1_PMA.Text = dtDisItemOld.Rows[0]["PMA"].ToString().Trim();
                txt2_DisStoQty.Text = dtDisItemOld.Rows[0]["DIS_STO_QTY"].ToString().Trim() == "" ? "0" : dtDisItemOld.Rows[0]["DIS_STO_QTY"].ToString().Trim();
                txt3_DisIsuQty.Text = dtDisItemOld.Rows[0]["DIS_ISU_QTY"].ToString().Trim() == "" ? "0" : dtDisItemOld.Rows[0]["DIS_ISU_QTY"].ToString().Trim();
                txt4_DisMdcQty.Text = dtDisItemOld.Rows[0]["DIS_MDC_QTY"].ToString().Trim() == "" ? "0" : dtDisItemOld.Rows[0]["DIS_MDC_QTY"].ToString().Trim();

                CRMModel.QueryCRMCommon BCO = new CRMModel.QueryCRMCommon(ConnectionDB);

                ArrayList ParameterList1 = new ArrayList();//20091106
                ParameterList1.Clear();
                ParameterList1.Add(s_ITEM);
                ParameterList1.Add(s_PERIOD);
                ParameterList1.Add(0);
                ParameterList1.Add(Session["UID"].ToString());

                DataTable dt = BCO.QUERY_ITEM_PERIODSTOCK(ParameterList1);
                if (dt != null && dt.Rows.Count > 0)
                {
                    txt5_ReserveQty.Text = dt.Rows[0]["RESERVE_QTY"].ToString().Trim() == "" ? "0" : dtDisItemOld.Rows[0]["RESERVE_QTY"].ToString().Trim();
                }
                else
                {
                    txt5_ReserveQty.Text = "0";
                }

                txt6_DisQty.Text = dtDisItemOld.Rows[0]["DIS_QTY"].ToString().Trim() == "" ? "0" : dtDisItemOld.Rows[0]["DIS_QTY"].ToString().Trim();
                txt7_AcceptQty.Text = dtDisItemOld.Rows[0]["ACCEPT_QTY"].ToString().Trim() == "" ? "0" : dtDisItemOld.Rows[0]["ACCEPT_QTY"].ToString().Trim();

                if (dtDisItemOld.Rows[0]["INCLUDE_NON_EFF"].ToString().Trim() == "1")
                    GetOrSetIncludeNonEff = 1;
                else
                    GetOrSetIncludeNonEff = 0;


                if (dtDisItemOld.Rows[0]["CHAN_TYPE"].ToString().Trim() == "1")
                {
                    GetOrSetDisChanType = 1;
                    btn_ChanSetting_Dis.Enabled = true;
                    hiddenCurrentChan.Value = "1";
                }
                else 
                {
                    GetOrSetDisChanType = 0;
                    btn_ChanSetting_Dis.Enabled = false;
                    hiddenCurrentChan.Value = "0";
                }

                txt_Remark.Text = dtDisItemOld.Rows[0]["MEMO"].ToString().Trim();

                s_ID_DisItem = dtDisItemOld.Rows[0]["ID"].ToString().Trim();
                s_UPDATEDATE = dtDisItemOld.Rows[0]["UPDATEDATE"].ToString().Trim();
                s_UPDATEUID = dtDisItemOld.Rows[0]["UPDATEUID"].ToString().Trim();
                #endregion
            }

            if (dtDisItemReferOld != null && dtDisItemReferOld.Rows.Count > 0)
            {
                #region
                gv_ItemRefer.DataSource = dtDisItemReferOld;
                gv_ItemRefer.DataBind();
                #endregion
            }

            if (dtDisChanOld != null && dtDisChanOld.Rows.Count > 0)
            {
                #region
                gv_Chan.DataSource = dtDisChanOld;
                gv_Chan.DataBind();

                hiddenChanReferCounts.Value = dtDisChanOld.Rows.Count.ToString();
                #endregion
            }

            

            hiddenOPValueStatus3.Value = "0";
            hiddenOPValueStatus4.Value = "0";
            hiddenOPValueStatus5.Value = "0";
            hiddenOPValueStatus6.Value = "0";
            hiddenOPValueStatus7.Value = "0";
            hiddenOPValueStatus8.Value = "0";

            if (dtDisAssistMainOld != null && dtDisAssistMainOld.Rows.Count > 0)
            {
                #region
                for (Int32 i = 0; i <= dtDisAssistMainOld.Rows.Count - 1; i++)
                {

                    if (!(dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "09" || dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "10"))
                    {

                        #region 通路
                        if (dtDisAssistMainOld.Rows[i]["CHAN_NO"].ToString().Trim() == "0")
                        {
                            rbtn_ChanAll2.Checked = true;
                            rbtn_ChanSingle2.Checked = false;
                            SLP_StoreChain1.Text = "";
                            SLP_StoreChain1.ReadOnly = true;
                            SLP_StoreChain1.IsRequired = false;
                        }
                        else
                        {
                            rbtn_ChanAll2.Checked = false;
                            rbtn_ChanSingle2.Checked = true;
                            SLP_StoreChain1.Text = dtDisAssistMainOld.Rows[i]["CHAN_NO"].ToString().Trim();
                            SLP_StoreChain1.ReadOnly = false;
                            SLP_StoreChain1.IsRequired = true;
                        }
                        #endregion

                        #region 01
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "01") 
                        {
                            chk11.Checked = true;
                        }
                        #endregion

                        #region 02
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "02")
                        {
                            chk21.Checked = true;
                        }
                        #endregion

                        #region 03
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "03")
                        {
                            chk31.Checked = true;

                            if (dtDisAssistMainOld.Rows[i]["OPERATOR1"].ToString().Trim() == "1")
                            {
                                rbtn311.Checked = true;
                                rbtn312.Checked = false;
                            }
                            else 
                            {
                                rbtn311.Checked = false;
                                rbtn312.Checked = true;
                            }

                            SLP_SLPNumber1.Text = dtDisAssistMainOld.Rows[i]["OP_VALUE1"].ToString().Trim();

                            if (dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim() == "0")
                            {
                                OP_VALUE_3W.Checked = true;
                                OP_VALUE_3X.Text = dtDisAssistMainOld.Rows[i]["CHANGE_RATE"].ToString().Trim();
                                OP_VALUE_3Y.Checked = false;
                                OP_VALUE_3Z.Enabled = false;
                            }
                            else
                            {
                                OP_VALUE_3W.Checked = false;
                                OP_VALUE_3X.Text = "";
                                OP_VALUE_3Y.Checked = true;
                                OP_VALUE_3Z.Enabled = true;
                            }

                            hiddenOPValueStatus3.Value = dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim();

                        }
                        #endregion

                        #region 04
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "04")
                        {
                            chk41.Checked = true;

                            if (dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim() == "0")
                            {
                                OP_VALUE_4W.Checked = true;
                                OP_VALUE_4X.Text = dtDisAssistMainOld.Rows[i]["CHANGE_RATE"].ToString().Trim();
                                OP_VALUE_4Y.Checked = false;
                                OP_VALUE_4Z.Enabled = false;
                            }
                            else
                            {
                                OP_VALUE_4W.Checked = false;
                                OP_VALUE_4X.Text = "";
                                OP_VALUE_4Y.Checked = true;
                                OP_VALUE_4Z.Enabled = true;
                            }

                            hiddenOPValueStatus4.Value = dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim();

                        }
                        #endregion

                        #region 05
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "05")
                        {
                            chk51.Checked = true;

                            if (dtDisAssistMainOld.Rows[i]["OPERATOR1"].ToString().Trim() == "1")
                            {
                                rbtn511.Checked = true;
                                rbtn512.Checked = false;
                            }
                            else
                            {
                                rbtn511.Checked = false;
                                rbtn512.Checked = true;
                            }

                            if (dtDisAssistMainOld.Rows[i]["OPERATOR2"].ToString().Trim() == "1")
                            {
                                rbtn521.Checked = true;
                                rbtn522.Checked = false;
                            }
                            else
                            {
                                rbtn521.Checked = false;
                                rbtn522.Checked = true;
                            }

                            SLP_SLPNumber2.Text = dtDisAssistMainOld.Rows[i]["OP_VALUE2"].ToString().Trim();

                            if (dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim() == "0")
                            {
                                OP_VALUE_5W.Checked = true;
                                OP_VALUE_5X.Text = dtDisAssistMainOld.Rows[i]["CHANGE_RATE"].ToString().Trim();
                                OP_VALUE_5Y.Checked = false;
                                OP_VALUE_5Z.Enabled = false;
                            }
                            else
                            {
                                OP_VALUE_5W.Checked = false;
                                OP_VALUE_5X.Text = "";
                                OP_VALUE_5Y.Checked = true;
                                OP_VALUE_5Z.Enabled = true;
                            }

                            hiddenOPValueStatus5.Value = dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim();

                        }
                        #endregion

                        #region 06
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "06")
                        {
                            chk61.Checked = true;

                            SLP_SLPNumber3.Text = dtDisAssistMainOld.Rows[i]["OP_VALUE1"].ToString().Trim();

                            if (dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim() == "0")
                            {
                                OP_VALUE_6W.Checked = true;
                                OP_VALUE_6X.Text = dtDisAssistMainOld.Rows[i]["CHANGE_RATE"].ToString().Trim();
                                OP_VALUE_6Y.Checked = false;
                                OP_VALUE_6Z.Enabled = false;
                            }
                            else
                            {
                                OP_VALUE_6W.Checked = false;
                                OP_VALUE_6X.Text = "";
                                OP_VALUE_6Y.Checked = true;
                                OP_VALUE_6Z.Enabled = true;
                            }

                            hiddenOPValueStatus6.Value = dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim();

                        }
                        #endregion

                        #region 07
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "07")
                        {
                            chk71.Checked = true;

                            SLP_SLPNumber4.Text = dtDisAssistMainOld.Rows[i]["OP_VALUE1"].ToString().Trim();

                            if (dtDisAssistMainOld.Rows[i]["OPERATOR2"].ToString().Trim() == "1")
                            {
                                rbtn721.Checked = true;
                                rbtn722.Checked = false;
                            }
                            else
                            {
                                rbtn721.Checked = false;
                                rbtn722.Checked = true;
                            }

                            SLP_SLPNumber5.Text = dtDisAssistMainOld.Rows[i]["OP_VALUE2"].ToString().Trim();


                            if (dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim() == "0")
                            {
                                OP_VALUE_7W.Checked = true;
                                OP_VALUE_7X.Text = dtDisAssistMainOld.Rows[i]["CHANGE_RATE"].ToString().Trim();
                                OP_VALUE_7Y.Checked = false;
                                OP_VALUE_7Z.Enabled = false;
                            }
                            else
                            {
                                OP_VALUE_7W.Checked = false;
                                OP_VALUE_7X.Text = "";
                                OP_VALUE_7Y.Checked = true;
                                OP_VALUE_7Z.Enabled = true;
                            }

                            hiddenOPValueStatus7.Value = dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim();

                        }
                        #endregion

                        #region 08
                        if (dtDisAssistMainOld.Rows[i]["ASSIST_CODE"].ToString().Trim() == "08")
                        {
                            chk81.Checked = true;

                            if (dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim() == "0")
                            {
                                OP_VALUE_8W.Checked = true;
                                OP_VALUE_8X.Text = dtDisAssistMainOld.Rows[i]["CHANGE_RATE"].ToString().Trim();
                                OP_VALUE_8Y.Checked = false;
                                OP_VALUE_8Z.Enabled = false;
                            }
                            else
                            {
                                OP_VALUE_8W.Checked = false;
                                OP_VALUE_8X.Text = "";
                                OP_VALUE_8Y.Checked = true;
                                OP_VALUE_8Z.Enabled = true;
                            }

                            hiddenOPValueStatus8.Value = dtDisAssistMainOld.Rows[i]["CHANGE_TYPE"].ToString().Trim();

                        }
                        #endregion

                    }
                }

                #endregion
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
예제 #16
0
    /// <summary>
    /// 根據傳入參數取得商品庫存 by PageMethod 
    /// </summary>
    /// <param name="v_RootNo"></param>
    /// <param name="v_Item"></param>
    /// <param name="v_Period"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    private void GetStockByPageMethod(string v_RootNo, string v_Item, string v_Period, string strUserID, string strPageTimeStamp)
    {
        #region
        try
        {
            if (v_Item.Trim() == "" || v_Period.Trim() == "")
            {
                throw new Exception("輸入之品號、期別不完整");
            }

            ArrayList ParameterList = new ArrayList();

            if (v_RootNo.Trim() == "")
            {
                #region 依照品號取得所屬[群分類]、[大分類]

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

                if (dt_Return != null && dt_Return.Rows.Count != 0)
                {
                    Session[string.Format("CRM041_s_PMA_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["PMA"].ToString();//大分類
                    Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類
                    v_RootNo = Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString();
                }
                bco_itm = null;
                dt_Return.Dispose();

                #endregion
            }

            if (Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] == null)
            {
                ParameterList.Clear();
                ParameterList.Add(v_RootNo);
                ParameterList.Add(v_Item);
                ParameterList.Add(v_Period);
                ParameterList.Add(strUserID);
                BCO_CRM.QueryCRMCommon BCO = new BCO_CRM.QueryCRMCommon(ConntionDB);
                Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = BCO.QueryCRMItemPeriodStock(ParameterList);
                BCO.CloseConnection();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        #endregion
    }
예제 #17
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
예제 #18
0
    /// <summary>
    /// 期別
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strStore"></param>
    /// <param name="strItem"></param>
    /// <param name="strPeriod"></param>
    /// <param name="strBarcode"></param>
    /// <param name="strPeriodBarcode"></param>
    /// <param name="strRtnDdl"></param>
    /// <param name="strID"></param>
    /// <param name="strCode"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    /// <returns></returns>
    private string GetValueByPageMethod_PERIOD(string strChan, string strStore, string strItem, string strPeriod, string strBarcode, string strPeriodBarcode, string strRtnDdl, string strID, string strCode, string strUserID, string strPageTimeStamp)
    {
        #region

        string strRtn = "", strTemp1 = "", strTemp2 = "", strTemp3 = "", strTemp4 = "";

        try
        {
            //期別或品號有異動時,重取庫存
            if (Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString() != strItem || Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString() != strPeriod)
            {
                Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = null;
            }

            //s_CHAN_NO
            //s_STORE
            //s_ITEM
            //s_PERIOD
            Session[string.Format("CRM041_s_CHAN_NO_{0}", strPageTimeStamp)] = strChan;//通路
            Session[string.Format("CRM041_s_STORE_{0}", strPageTimeStamp)] = strStore;//門市
            Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)] = strItem;//品號
            Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)] = strPeriod;//期別

            #region CHECK-1:檢查書店是否有未結案同品項訂單


            if (strID == string.Empty)
            {
                #region 從資料庫查詢資料
                ArrayList ParameterList = new ArrayList();

                ParameterList.Clear();
                ParameterList.Add(strChan);//通路
                ParameterList.Add(strStore);//門市
                ParameterList.Add(strItem);//品號
                ParameterList.Add(strPeriod);//期別
                ParameterList.Add(strUserID);
                ParameterList.Add(strCode);//訂單單號

                DataTable dt_Return_1 = new DataTable();
                BCO_CRM.RecordCRMOrder BCO1 = new BCO_CRM.RecordCRMOrder(ConntionDB);
                dt_Return_1 = BCO1.CheckOrderItemExist(ParameterList);
                BCO1.CloseConnection();
                System.Text.StringBuilder sb = new System.Text.StringBuilder();

                #endregion

                if (dt_Return_1.Rows.Count > 0)
                {
                    strTemp1 = string.Format("該門市已存在未結案之同品項訂單於訂單標號:[{0}],不可新增", dt_Return_1.Rows[0]["CRM_REQUEST_NO"].ToString());
                }
            }

            #endregion

            if (strTemp1 == "")
            {
                #region CHECK-2:檢查牌價是否已經正確建立

                ParameterList.Clear();
                ParameterList.Add(strStore);//門市
                ParameterList.Add(strItem);//品號
                ParameterList.Add(strPeriod);//期別
                ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd")); // 系統日
                ParameterList.Add(strUserID);
                BCO_ALO.ProcessALOCommon BCO2 = new BCO_ALO.ProcessALOCommon(ConntionDB);
                string sRes = BCO2.CheckStAcceptDisPrice(ParameterList);
                BCO2.CloseConnection();

                if (sRes != string.Empty)
                {
                    strTemp2 = string.Format("期別:[{0}],牌價未生效[{1}],不可新增", strPeriod, sRes);
                }

                #endregion

                if (strTemp2 == "")
                {
                    #region CHECK-3:設定二段碼、退書截止日與逾期客訂

                    string s_down_BARCODE = string.Empty;//一段碼
                    string s_down_PERIOD_BARCODE = string.Empty;//二段碼
                    string s_down_RTN_DDL = string.Empty;//退書截止日

                    s_down_BARCODE = strBarcode;
                    s_down_PERIOD_BARCODE = strPeriodBarcode;
                    s_down_RTN_DDL = strRtnDdl;

                    // 不管原來有沒有值,只要品號改變,都重新查詢
                    ParameterList.Clear();
                    ParameterList.Add(strChan);//通路
                    ParameterList.Add(strItem);//品號
                    ParameterList.Add(strPeriod);//期別
                    ParameterList.Add(strUserID);

                    DataTable dt_Return_2 = new DataTable();
                    BCO_CRM.QueryCRMCommon BCO3 = new BCO_CRM.QueryCRMCommon(ConntionDB);
                    dt_Return_2 = BCO3.QueryItemPeriodInfo(ParameterList);
                    BCO3.CloseConnection();

                    if (dt_Return_2.Rows.Count > 0)//有找到資料
                    {
                        s_down_BARCODE = dt_Return_2.Rows[0]["BARCODE"].ToString();
                        s_down_PERIOD_BARCODE = dt_Return_2.Rows[0]["PERIOD_BARCODE"].ToString();
                        s_down_RTN_DDL = DateTime.Parse(dt_Return_2.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd");
                    }
                    else//查無資料
                    {
                        strTemp3 = string.Format("查無[一段碼][二段碼][退書截止日],無法新增");
                    }

                    #endregion

                    if (strTemp3 == "")
                    {
                        #region CHECK-4:逾期客訂確認

                        TimeSpan time = new TimeSpan(11, 00, 00);
                        bool b_down_IS_OVERDUE = false;
                        //20140515 家容提出移除逾期判斷
                        //DateTime d_Now;
                        //DateTime d_RTN_DDL;

                        //d_Now = DateTime.Now;
                        //d_RTN_DDL = DateTime.Parse(s_down_RTN_DDL);

                        //if (d_Now.DayOfWeek == DayOfWeek.Saturday || d_Now.DayOfWeek == DayOfWeek.Sunday ||
                        //    (d_Now.DayOfWeek == DayOfWeek.Friday && d_Now.TimeOfDay.CompareTo(time) >= 0))
                        //{
                        //    if (d_RTN_DDL.AddDays(-5).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        //    {
                        //        b_down_IS_OVERDUE = true;
                        //        b_IS_OVERDUE = true;
                        //    }
                        //}
                        //else
                        //{
                        //    if (d_RTN_DDL.AddDays(-2).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        //    {
                        //        b_down_IS_OVERDUE = true;
                        //        b_IS_OVERDUE = true;
                        //    }
                        //}

                        //[@逾期客訂].檢查結果為True時,顯示Confirm訊息『商品已逾期,不可退貨,確定要新增?』
                        //使用者確認要新增時,可繼續編輯。
                        //使用者選擇不新增時,取消本筆明細新增。

                        if (b_down_IS_OVERDUE == true)
                        {

                            strTemp4 = string.Format("TRUE-{0}-{1}-{2}-{3}-{4}-{5}",
                                Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, s_down_BARCODE, s_down_PERIOD_BARCODE, s_down_RTN_DDL);
                        }
                        else
                        {
                            strTemp4 = string.Format("FALSE-{0}-{1}-{2}-{3}-{4}-{5}",
                                Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, s_down_BARCODE, s_down_PERIOD_BARCODE, s_down_RTN_DDL);
                        }

                        #endregion

                        if (strTemp4.IndexOf("FALSE") != -1)
                        {
                            #region 取得庫存資訊

                            GetStockByPageMethod(Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, strUserID, strPageTimeStamp);

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

        return strRtn = string.Format("{0};{1};{2};{3}", strTemp1, strTemp2, strTemp3, strTemp4);
        #endregion
    }
예제 #19
0
    /// <summary>
    /// 將變更後的內部變量this.CallBackValue返回給前台JavaScript方法ReceiveServerData(string Value)。

    /// </summary>
    /// <returns></returns>
    string ICallbackEventHandler.GetCallbackResult()
    {
        if (CallBackValue != string.Empty)
        {
            try
            {
                TextBox txt_CHAN_NO = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_CHAN_NO).FindControl("TextBoxCode");//通路
                TextBox txt_STORE = (TextBox)((ASP.stm_slp_slp_store_ascx)slp_STORE).FindControl("TextBoxCode");//門市

                TextBox txt_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_ITEM).FindControl("TextBoxCode");//品號
                TextBox txt_PERIOD = (TextBox)((ASP.itm_slp_slp_itemperiod_ascx)slp_PERIOD).FindControl("TextBoxCode");//期別

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                CallBackValue = CallBackValue.Trim();
                string[] s_Client_String = System.Text.RegularExpressions.Regex.Split(CallBackValue, "<partition>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                ArrayList ParameterList = new ArrayList();//20091117

                #region 離開欄位[@門市]

                if (s_Client_String[0] == "離開欄位[@門市]")
                {
                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//門市

                    ParameterList.Add(string.Empty);//通路
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return = new DataTable();
                    BCO.MaintainStore bco = new BCO.MaintainStore(ConntionDB);
                    dt_Return = bco.QUERY_STORE_BY_STOREANDCHAN(ParameterList);

                    #endregion

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("離開欄位[@門市]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("查無資料<partition>");
                        sb.Append(txt_STORE.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(txt_CHAN_NO.ClientID);
                    }
                    else
                    {
                        sb.Append("離開欄位[@門市]<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return.Rows[0]["CHAN_NO"].ToString() + "<partition_Detail>" + txt_CHAN_NO.ClientID);
                    }
                }

                #endregion

                #region 異動欄位[@二段碼]設定值後

                else if (s_Client_String[0] == "異動欄位[@二段碼]設定值後")
                {
                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_Client_String[2]);//一段碼
                    ParameterList.Add(s_Client_String[3]);//二段碼

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

                    DataTable dt_Return = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return = bco.QueryItemPeriodInfoByBarcode(ParameterList);

                    #endregion

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("異動欄位[@二段碼]設定值後<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("此一段碼/二段碼不存在對應商品期別資訊,請重新輸入<partition>");
                        sb.Append(this.txt_BARCODE.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(this.txt_PERIOD_BARCODE.ClientID + "<partition>");
                        sb.Append(txt_ITEM.ClientID + "<partition>");
                        sb.Append(txt_PERIOD.ClientID);
                    }
                    else
                    {
                        sb.Append("異動欄位[@二段碼]設定值後<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return.Rows[0]["ITEM"].ToString() + "<partition_Detail>" + txt_ITEM.ClientID + "<partition>");
                        sb.Append(dt_Return.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + txt_PERIOD.ClientID);
                    }

                }
                #endregion

                #region 異動欄位[@品號/品名]設定值後

                else if (s_Client_String[0] == "異動欄位[@品號/品名]設定值後")
                {
                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//品號
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return_1 = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return_1 = bco.GetMaxDeiveryPeriod(ParameterList);

                    #endregion

                    if (dt_Return_1.Rows[0]["PERIOD"].ToString() == string.Empty)
                    {
                        sb.Append("異動欄位[@品號/品名]設定值後<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("查無資料<partition>");
                        sb.Append(txt_ITEM.ClientID);//設定焦點的欄位

                    }
                    else
                    {
                        sb.Append("異動欄位[@品號/品名]設定值後<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return_1.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + txt_PERIOD.ClientID);
                    }
                }

                #endregion

                CallBackValue = sb.ToString();
            }
            catch (Exception ex)
            { CallBackValue = "發生例外錯誤<partition>" + ex.Message; }
        }

        return CallBackValue;
    }
예제 #20
0
    /// <summary>
    /// 二段碼
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strBarcode"></param>
    /// <param name="strPeriodBarcode"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    /// <returns></returns>
    private string GetValueByPageMethod_PERIODBARCODE(string strChan, string strBarcode, string strPeriodBarcode, string strUserID, string strPageTimeStamp)
    {
        #region
        string strRtn = "", strTemp1 = "", strTemp2 = "";

        try
        {
            #region 從資料庫查詢資料:群分類、品號、期別
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(strChan);//通路
            ParameterList.Add(strBarcode);//一段碼
            ParameterList.Add(strPeriodBarcode);//二段碼
            ParameterList.Add(strUserID);

            DataTable dt_Return = new DataTable();
            BCO_CRM.QueryCRMCommon BCO1 = new BCO_CRM.QueryCRMCommon(ConntionDB);
            dt_Return = BCO1.QueryItemPeriodInfoByBarcode(ParameterList);
            BCO1.CloseConnection();

            #endregion

            if (dt_Return.Rows.Count == 0)
            {
                strTemp1 = string.Format("此一段碼/二段碼不存在對應商品期別資訊,請重新輸入");
            }
            else
            {

                //期別或品號有異動時,重取庫存
                if (Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString() != dt_Return.Rows[0]["ITEM"].ToString() ||
                    Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString() != dt_Return.Rows[0]["PERIOD"].ToString())
                {
                    Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = null;
                }

                Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["ROOT_NO"].ToString();
                Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["ITEM"].ToString();
                Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["PERIOD"].ToString();


                strTemp2 = string.Format("{0}-{1}-{2}",
                            Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString(),
                            Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString(),
                            DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd"));

                GetStockByPageMethod(Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString(), Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString(), strUserID, strPageTimeStamp);
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
        return strRtn = string.Format("{0};{1}", strTemp1, strTemp2);
        #endregion
    }
예제 #21
0
    public static string GetChanByStore(string sStore)
    {
        try
        {
            BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

            #region 輸入變數
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(sStore);//門市
            ParameterList.Add(sUID);  //使用者

            #endregion

            DataTable Dt = bco.GetChanNoAndNameByStore(ParameterList);

            if (Dt.Rows.Count == 0) //無資料
            {
                return "查無資料";
            }
            else
            {
                return Dt.Rows[0]["CHAN_NO"].ToString() + "-" + Dt.Rows[0]["CHAN_NAME"].ToString();
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }

    }
예제 #22
0
    private void databind()
    {
        #region
        string SessionIDName = "CRM20" + PageTimeStamp.Value;

        ParameterList.Clear();
        ParameterList.Add("%" + txtItemName.Text.Trim() + "%");
        ParameterList.Add(SLP_Item.Text.Trim());
        ParameterList.Add(Session["UID"].ToString());
        ParameterList.Add(SLP_ItemPeriod1.Text.Trim());
        ParameterList.Add(txt_Barcode.Text.Trim());

        BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

        DataTable dt = bco.QueryItemAndStock(ParameterList);

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

        Session[SessionIDName] = dt;
        GridView1.DataSource = dt;
        GridView1.PageIndex = 0;
        GridView1.DataBind();
        #endregion
    }
    /// <summary>
    /// 取得商品儲區擷轉明細
    /// </summary>
    private DataTable Get_Data(string s_Page_Load)
    {
        #region 傳入參數

        ArrayList ParameterList = new ArrayList();//20091118

        if (s_Page_Load == "IS_PAGE_LOAD")
        {
            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(sTransDate, "date", false));
            ParameterList.Add(GetValueSetParameter(sStAcceptDate, "date", false));
            ParameterList.Add(GetValueSetParameter(sRootNo, "int", false));
            ParameterList.Add(GetValueSetParameter(sIsOverDue, "int", false));
            ParameterList.Add(GetValueSetParameter(sTransNoBegin, "string", false));
            ParameterList.Add(GetValueSetParameter(sTransNoEnd, "string", false));
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(GetValueSetParameter("9999", "int", false));

        }
        else if (s_Page_Load == "NOT_PAGE_LOAD")
        {
            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.slp_TRANS_DATE.Text, "date", false));
            ParameterList.Add(GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "date", false));
            ParameterList.Add(GetValueSetParameter(this.SLP_RootNo1.Text.Trim(), "int", false));
            ParameterList.Add(GetValueSetParameter(this.slp_IS_OVERDUE.SelectedValue, "int", false));
            ParameterList.Add(GetValueSetParameter(this.txt_TRANS_NO_B.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txt_TRANS_NO_E.Text, "string", false));
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(GetValueSetParameter(this.TextBoxRowCountLimit.Text.Trim(), "int", false));
        }

        #endregion

        #region 取得資料

        DataTable dt_Return = new DataTable();

        BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

        dt_Return = bco.QueryDisNo(ParameterList);

        #endregion

        #region 資料與GridView繫結

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

        string SessionIDName = "QueryDisNo_POP_" + this.PageTimeStamp.Value;
        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dt_Return;
        this.gv_TransDisNo.DataSource = dt_Return;
        this.gv_TransDisNo.PageSize = (this.TextBoxPagesize.Text == string.Empty) ? 10 : (int.Parse(this.TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(this.TextBoxPagesize.Text);
        this.gv_TransDisNo.PageIndex = 0;
        this.gv_TransDisNo.DataBind();
        #endregion

        return dt_Return;
    }
예제 #24
0
    /// <summary>
    /// DOWN BUTTON 更新鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_down_Update_Click(object sender, EventArgs e)
    {

        try
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            TextBox txt_down_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxCode");//品號
            TextBox txt_down_ITEM_NAME = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxName");//品名
            TextBox txt_down_REQUEST_QTY = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxCode");//訂貨量
            TextBox txt_down_REQUEST_QTY_NAME = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxName");//訂貨量名稱
            TextBox txt_down_RTN_DDL = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("TextBoxCode");//退書截止日
            CheckBox chk_down_IS_OVERDUE = (CheckBox)((ASP.wui_slp_slp_boolean_ascx)slp_down_IS_OVERDUE).FindControl("C1");//逾期客訂
            //string SessionIDName = "CRM041_dt_Detail" + PageTimeStamp.Value;
            //if (Session[SessionIDName] != null) dt_Detail = (DataTable)Session[SessionIDName];
            if (this.hid_PageStatus.Value == "INSERT" ||
                this.hid_PageStatus.Value == "EDIT")
            {
                s_PMA = string.Empty;
                s_ROOT_NO = string.Empty;
                string s_Is_PO = string.Empty;

                sb.Remove(0, sb.Length);
                DataTable dt_Return = new DataTable();
                ArrayList ParameterList = new ArrayList();//20091117

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

                ParameterList.Clear();
                BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", this.slp_down_ITEM.Text, "=", "and");

                BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
                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 判斷PO單號
                //確定PO單號存在
                GetChainPOSetting(this.slp_up_CHAN_NO.Text, this.slp_up_STORE.Text);
                DataView dvChainPOSetting = new DataView(dtChainPOSetting.Copy());
                dvChainPOSetting.RowFilter = "PMA = '" + s_PMA + "' and ROOT_NO = '" + s_ROOT_NO + "'";
                if (dvChainPOSetting.Count > 0)
                {
                    if (dvChainPOSetting[0]["IS_DIS_BYPO"].ToString() == "1")//代表是依PO分單
                    { s_Is_PO = "TRUE"; }
                    else if (dvChainPOSetting[0]["IS_DIS_BYPO"].ToString() == "0")//代表不是依PO分單
                    { s_Is_PO = "FALSE"; }
                    // 2009-08-12 cyhsu add
                    if (this.slp_up_CHAN_NO.Text == "CB" && s_ROOT_NO == "1")
                    {
                        //當通路=誠品, 群分類=雜誌時,不管通路設定檔設定為何,都先規定要輸入PO單號
                        s_Is_PO = "TRUE";
                    }
                }

                //s_Is_PO = TRUE 代表是依PO分單>>[PO單號]欄位一定要填
                //s_Is_PO = FALSE 代表不是依PO分單>>[PO單號]欄位一定不能填
                //s_Is_PO = NULL 代表是依PO分單>>[PO單號]欄位可填可不填

                if (s_Is_PO == "TRUE")
                {
                    if (this.txt_down_PO_SOURCE_NO.Text.ToString().Length == 0)
                    //if (this.txt_down_PO_SOURCE_NO.Text.Trim() == string.Empty)
                    { sb.Append("PO單號不可空白"); }
                }
                else if (s_Is_PO == "FALSE")
                {
                    if (this.txt_down_PO_SOURCE_NO.Text.Trim() != string.Empty)
                    { sb.Append("PO單號不可有值"); }
                }

                if (GetStringLen(txt_down_PO_SOURCE_NO.Text.Trim()) > 20)
                { sb.Append("PO單號欄位輸入資料過長"); }

                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + this.txt_down_PO_SOURCE_NO.ClientID + "'].focus();", true);
                    return;
                }

                #endregion

                #region 判斷一段碼、二段碼是否屬於該品號、期別
                ParameterList.Clear();

                ParameterList.Add(this.slp_down_ITEM.Text); // ITEM
                ParameterList.Add(this.txt_down_PERIOD.Text);      // PERIOD
                ParameterList.Add(this.txt_down_BARCODE.Text); // 一段碼
                ParameterList.Add(this.txt_down_PERIOD_BARCODE.Text);      // 二段碼
                ParameterList.Add(Session["UID"].ToString());

                BCO.QueryCRMCommon co_common = new BCO.QueryCRMCommon(ConntionDB);
                bool b_CheckRes;
                b_CheckRes = co_common.CheckItemPeriodBarcode(ParameterList);
                if (!b_CheckRes)
                {
                    sb.Remove(0, sb.Length);
                    sb.AppendFormat("一段碼[{2}]、二段碼[{3}]不屬於品號[{0}]、期別[{1}]!",
                                    this.slp_down_ITEM.Text,
                                    this.txt_down_PERIOD.Text,
                                    this.txt_down_BARCODE.Text,
                                    this.txt_down_PERIOD_BARCODE.Text);
                }

                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + this.txt_down_PO_SOURCE_NO.ClientID + "'].focus();", true);
                    return;
                }

                #endregion

                #region 檢查是否可新增
                bool bCheck = CheckOrderDetail(this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text);
                if (!bCheck && hid_ID.Value == string.Empty)
                {
                    sb.Remove(0, sb.Length);
                    sb.AppendFormat("品號[{0}]、期別[{1}]已存在,不可重複新增!", this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text);
                }
                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + txt_down_ITEM.ClientID + "'].focus();", true);
                    return;
                }
                string sCheck = CheckCanUpdate(s_CHAN_NO, s_STORE,
                                               this.slp_down_ITEM.Text,
                                               this.txt_down_PERIOD.Text,
                                               txt_down_RTN_DDL.Text,
                                               this.txt_up_CODE.Text);

                if (sCheck != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sCheck + "');document.all['" + txt_down_ITEM.ClientID + "'].focus();", true);
                    return;
                }

                #endregion


                // 為了解決頁面儲區空白的問題先暫時設定睡眠對應。
                for (int i = 0; i < 10; i++)
                {
                    if (this.txt_down_RECOMMAND_LOCATION.Text != String.Empty)
                    { break; }
                    System.Threading.Thread.Sleep(500);
                }

                #region 更新明細暫存資訊

                #region 新增狀態,若是第一筆資料,建立 TEMP TABLE

                if (this.hid_PageStatus.Value == "INSERT" && hid_ID.Value == string.Empty)
                {
                    if (dt_Detail == null)
                    {
                        DataTable dtTmp = new DataTable();
                        ParameterList.Clear();
                        ParameterList.Add(Session["UID"].ToString());

                        BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                        dtTmp = bco.QUERY_CRM041_DETL_SCHEMA(ParameterList);

                        DataColumn dcol1 = new DataColumn("BARCODE", System.Type.GetType("System.String"));//一段碼
                        DataColumn dcol2 = new DataColumn("PERIOD_BARCODE", System.Type.GetType("System.String"));//二段碼
                        DataColumn dcol3 = new DataColumn("ITEM_NAME", System.Type.GetType("System.String"));//品名
                        DataColumn dcol4 = new DataColumn("COLUMN_STATUS", System.Type.GetType("System.String"));//欄位狀態

                        dtTmp.Columns.Add(dcol1);
                        dtTmp.Columns.Add(dcol2);
                        dtTmp.Columns.Add(dcol3);
                        dtTmp.Columns.Add(dcol4);

                        dt_Detail = dtTmp.Copy();
                        dtTmp.Dispose();
                    }
                }

                #endregion

                if ((this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") &&
                    this.hid_ID.Value == string.Empty)
                {
                    DataRow dRow = dt_Detail.NewRow();

                    if (dt_Detail.Rows.Count == 0)
                    { dRow["ID"] = 0; }
                    else
                    {
                        DataView dv_Detail = new DataView(dt_Detail.Copy());
                        dv_Detail.Sort = "ID ASC";
                        dRow["ID"] = int.Parse(dv_Detail[0]["ID"].ToString()) + 1;
                    }

                    dRow["ROOT_NO"] = s_ROOT_NO;//群分類
                    dRow["PMA"] = s_PMA;//大分類
                    dRow["PO_SOURCE_NO"] = this.txt_down_PO_SOURCE_NO.Text.Trim();//PO單號
                    dRow["BARCODE"] = this.txt_down_BARCODE.Text.Trim();//一段碼
                    dRow["PERIOD_BARCODE"] = this.txt_down_PERIOD_BARCODE.Text.Trim();//二段碼
                    dRow["ITEM"] = this.slp_down_ITEM.Text.Trim();//品號
                    dRow["ITEM_NAME"] = this.slp_down_ITEM.Name.Trim();//品名
                    //dRow["ITEM_NAME"] = ((TextBox)this.slp_down_ITEM.Controls[1].FindControl("TextBoxName")).Text.Trim();//品名
                    dRow["PERIOD"] = this.txt_down_PERIOD.Text.Trim();//期別
                    dRow["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量
                    dRow["RTN_DDL"] = DateTime.ParseExact(this.slp_down_RTN_DDL.Text.Trim(), "yyyy/MM/dd", null);//退書截止日
                    b_IS_OVERDUE = CheckIsOverDue(this.slp_down_RTN_DDL.Text.Trim());
                    if (b_IS_OVERDUE == true)
                    { dRow["IS_OVERDUE"] = 1; }//逾期客訂有被勾選
                    else
                    { dRow["IS_OVERDUE"] = 0; }//逾期客訂沒有被勾選
                    // todo cyhsu: 找外雜 Locate_type 與 locate_no 沒有設定的原因
                    if ((s_SRC_LOCATE_TYPE == String.Empty) && (s_ROOT_NO == "1") &&
                       ((s_PMA == "13") || (s_PMA == "14") || (s_PMA == "15") || (s_PMA == "16")))
                    {
                        s_SRC_LOCATE_TYPE = "2";
                        this.txt_down_RECOMMAND_LOCATION.Text = "D";
                    }

                    dRow["SRC_LOCATE_TYPE"] = s_SRC_LOCATE_TYPE;//建議儲區
                    dRow["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區
                    dRow["PROC_DESC"] = 0;//處理狀態(0代表未擷轉)
                    dRow["STATUS"] = 25;//結案狀態(25代表未結案,75代表已結案)
                    dRow["DIS_ENABLE"] = int.Parse(this.hid_DIS_ENABLE.Value);//可配量

                    dt_Detail.Rows.Add(dRow);
                }
                else if ((this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") &&
                    this.hid_ID.Value != string.Empty)
                {
                    //2009-02-04 cyhsu change
                    DataTable dtTmp = dt_Detail.Copy();

                    //string s_FilterExpression = string.Empty;
                    //s_FilterExpression = "ID = " + this.hid_ID.Value;

                    //DataRow dRow = dt_Detail.Select(s_FilterExpression)[0];
                    //dRow["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量
                    //dRow["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區
                    int i_index = -1;

                    for (int i = 0; i < dtTmp.Rows.Count; i++)
                    {
                        if (dtTmp.Rows[i]["ID"].ToString() == this.hid_ID.Value)
                        {
                            i_index = i;
                            break;
                        }
                    }
                    if (i_index > -1)
                    {
                        dt_Detail.Rows[i_index]["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量
                        dt_Detail.Rows[i_index]["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區
                        dt_Detail.Rows[i_index]["PO_SOURCE_NO"] = this.txt_down_PO_SOURCE_NO.Text.Trim();//建議儲區;
                    }
                }

                this.gv_Detail.DataSource = dt_Detail;
                this.gv_Detail.PageSize = 10;
                this.gv_Detail.PageIndex = 0;
                this.gv_Detail.DataBind();
                Panel1.Height = gv_Detail.Rows.Count * 45 + 60;

                //Session[SessionIDName] = dt_Detail;

                #region 清空 hid_ID,hid_DIS_ENABLE

                //this.hid_ID.Value = string.Empty;是否不應清空?2009-06-04 cyhsu
                this.hid_DIS_ENABLE.Value = string.Empty;

                #endregion

                #region 清空靜態變數

                dtStock = null;//異動欄位[期別]
                s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                #endregion

                #region 設定畫面狀態


                sb.Remove(0, sb.Length);
                sb.Append("新增或編輯模式按下明細區[更新]鈕<partition>");
                sb.Append(dt_Detail.Rows.Count.ToString() + "<partition>");//dt_Detail筆數
                sb.Append(this.panel_Middle.ClientID + "<partition>");//panel_Middle
                sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區

                ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "but_down_Update_Click('" + sb.ToString() + "');", true);

                #endregion

                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
예제 #25
0
    private bool GetItemPeriodStock(string strItem, string strPeriod)
    {
        #region
        bool bResult = false;
        try
        {

            CRMModel.QueryCRMCommon BCO = new CRMModel.QueryCRMCommon(ConnectionDB);

            DataTable dtTemp = new DataTable();

            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            dtTemp.Clear();

            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);
            ParameterList.Add("2");
            ParameterList.Add(Session["UID"].ToString());
            dtTemp = BCO.QUERY_ITEM_PERIODSTOCK(ParameterList);

            i_ONHD_QTY = 0;
            i_RESERVE_QTY = 0;
            i_DIS_ENABLE = 0;

            if (dtTemp != null && dtTemp.Rows.Count != 0)
            {
                //2009-09-18 cyhsu add 因為庫存儲區可能有兩個以上所以要用彙總
                foreach (DataRow dr in dtTemp.Rows)
                {
                    i_ONHD_QTY += Int32.Parse(dr["ONHD_QTY"].ToString());//庫存數
                    i_RESERVE_QTY += Int32.Parse(dr["RESERVE_QTY"].ToString());//待出庫數
                }
                i_DIS_ENABLE = i_ONHD_QTY - i_RESERVE_QTY;//可出庫數
            }

            if (i_DIS_ENABLE < 1)
                bResult = false;
            else
                bResult = true;


        }
        catch (Exception ex)
        {
            throw ex;
        }

        return bResult;

        #endregion
    }
예제 #26
0
    /// <summary>
    /// 取得商品儲區擷轉明細
    /// </summary>
    private DataTable QueryData()
    {
        #region
        #region 傳入參數

        ArrayList ParameterList = new ArrayList();

        ParameterList.Clear();
        ParameterList.Add(GetValueSetParameter(slp_TRANS_DATE.Text, "date", false));
        ParameterList.Add(GetValueSetParameter(slp_ST_ACCEPT_DATE.Text, "date", false));
        ParameterList.Add(GetValueSetParameter(SLP_RootNo1.Text.Trim(), "int", false));
        ParameterList.Add(GetValueSetParameter(slp_IS_OVERDUE.SelectedValue, "int", false));
        ParameterList.Add(GetValueSetParameter(txt_TRANS_NO_B.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(txt_TRANS_NO_E.Text, "string", false));
        ParameterList.Add(Session["UID"].ToString());

        if (!IsPostBack)
        {
            ParameterList.Add(GetValueSetParameter("9999", "int", false));
        }
        else
        {
            ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text.Trim(), "int", false));
        }

        #endregion

        #region 取得資料

        DataTable dt_Return = new DataTable();

        BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

        try
        {
            dt_Return = bco.QUERY_NON_TRANSDATA(ParameterList);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion

        #region 資料與GridView繫結
        string SessionIDName = "CRM071A_" + PageTimeStamp.Value;

        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dt_Return;
        this.gv_TransErrData.DataSource = dt_Return;
        this.gv_TransErrData.PageSize = (this.TextBoxPagesize.Text == string.Empty) ? 10 : (int.Parse(this.TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(this.TextBoxPagesize.Text);
        this.gv_TransErrData.PageIndex = 0;
        this.gv_TransErrData.DataBind();

        #endregion

        return dt_Return;
        #endregion
    }
    /// <summary>
    /// 取得商品儲區擷轉明細
    /// </summary>
    private DataTable Get_Data(string s_Page_Load)
    {
        #region 傳入參數

        ArrayList ParameterList_Session = new ArrayList();
        ArrayList ParameterList = new ArrayList();//20091118
        if (s_Page_Load == "IS_PAGE_LOAD")
        {
            ParameterList_Session = (ArrayList)Session["POP_CRMTransError2_ParameterList"];
            if (ParameterList_Session != null)
            {
                this.slp_TRANS_DATE.Text = ((DateTime)ParameterList_Session[0]).ToString("yyyy/MM/dd");
                this.slp_ST_ACCEPT_DATE.Text = ((DateTime)ParameterList_Session[1]).ToString("yyyy/MM/dd");
                this.SLP_RootNo1.Text = ParameterList_Session[2].ToString();
                this.slp_IS_OVERDUE.SelectedValue = ParameterList_Session[3].ToString();
                this.txt_TRANS_NO_B.Text = ParameterList_Session[4].ToString();
                this.txt_TRANS_NO_E.Text = ParameterList_Session[5].ToString();
                ParameterList.Add(Session["UID"].ToString());
                ParameterList_Session.Add(GetValueSetParameter("9999", "int", false));
            }
        }
        else if (s_Page_Load == "NOT_PAGE_LOAD")
        {
            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.slp_TRANS_DATE.Text, "date", false));
            ParameterList.Add(GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "date", false));
            ParameterList.Add(GetValueSetParameter(this.SLP_RootNo1.Text.Trim(), "int", false));
            ParameterList.Add(GetValueSetParameter(this.slp_IS_OVERDUE.SelectedValue, "int", false));
            ParameterList.Add(GetValueSetParameter(this.txt_TRANS_NO_B.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txt_TRANS_NO_E.Text, "string", false));
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(GetValueSetParameter(this.TextBoxRowCountLimit.Text.Trim(), "int", false));
        }

        #endregion

        #region 取得資料

        DataTable dt_Return = new DataTable();

        BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

        try
        {
            if (s_Page_Load == "IS_PAGE_LOAD")
            { dt_Return = bco.QueryTransErrorData(ParameterList_Session); }
            else if (s_Page_Load == "NOT_PAGE_LOAD")
            { dt_Return = bco.QueryTransErrorData(ParameterList); }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        #endregion

        #region 資料與GridView繫結

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

        string SessionIDName = "CRM071_POP_" + PageTimeStamp.Value;

        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dt_Return;
        this.gv_TransErrData.DataSource = dt_Return;
        this.gv_TransErrData.PageSize = (this.TextBoxPagesize.Text == string.Empty) ? 10 : (int.Parse(this.TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(this.TextBoxPagesize.Text);
        this.gv_TransErrData.PageIndex = 0;
        this.gv_TransErrData.DataBind();

        #endregion

        return dt_Return;
    }