Пример #1
0
        /// <summary>
        /// Excel匯入資料檢查-數值欄位
        /// </summary>
        /// <param name="dr">資料列</param>
        /// <param name="aryColumns">要被檢查的欄位</param>
        /// <param name="strErrMsgDataFormat">錯誤訊息</param>
        /// <returns></returns>
        protected bool CheckInputValueIsInt32(DataRow dr, Int32[] aryColumns, out string strErrMsgDataFormat)
        {
            #region

            bool bResult;
            strErrMsgDataFormat = "";
            string strValue = "";
            Int32 iResult;
            Int32 iColumn, iErrCounts = 0; ;
            strErrMsgDataFormat = "";
            for (Int32 i = 0; i <= aryColumns.GetUpperBound(0); i++)
            {
                iColumn = aryColumns[i];

                if (iColumn == 5)//數量或設定類別
                {
                    strValue = dr[iColumn].ToString().Trim();
                    bResult = Int32.TryParse(strValue, out iResult);

                    if (!bResult)
                    {
                        strErrMsgDataFormat += string.Format("{0}欄位非數值,", strAryColumnName[iColumn]);
                        iErrCounts++;
                    }
                    else
                    {
                        if (iResult < 0 || (strValue.IndexOf("-") != -1))
                        {
                            strErrMsgDataFormat += string.Format("{0}欄位非正數值,", strAryColumnName[iColumn]);
                            iErrCounts++;
                        }
                    }

                    //多檢查數量長度

                    if (dr[iColumn].ToString().Trim().Length > iAryColumnLength[iColumn])
                    {
                        strErrMsgDataFormat += string.Format("{0}欄位長度不應超過{1}", strAryColumnName[iColumn], iAryColumnLength[iColumn]);
                        iErrCounts++;
                    }

                }
            }

            if (strErrMsgDataFormat.Trim().Length > 0)
            {
                if (strErrMsgDataFormat.Substring(strErrMsgDataFormat.Length - 1, 1) == ",")
                {
                    strErrMsgDataFormat = strErrMsgDataFormat.Substring(0, strErrMsgDataFormat.Length - 1);
                }
            }

            if (iErrCounts != 0)
            {
                bResult = false;
            }
            else
            {
                bResult = true;
            }

            return bResult;
            #endregion
        }
Пример #2
0
        /// <summary>
        /// Excel匯入資料檢查-必填欄位
        /// </summary>
        /// <param name="dr">資料列</param>
        /// <param name="aryColumns">要被檢查的欄位</param>
        /// <param name="strErrMsgDataFormat">錯誤訊息</param>
        /// <returns></returns>
        protected bool CheckRequiredField(DataRow dr, Int32[] aryColumns, out string strErrMsgDataFormat)
        {
            #region
            bool bResult;
            Int32 iColumn, iErrCounts = 0;
            strErrMsgDataFormat = "";

            for (Int32 i = 0; i <= aryColumns.GetUpperBound(0); i++)
            {
                iColumn = aryColumns[i];
                if (dr[iColumn].ToString().Trim() == "")
                {
                    strErrMsgDataFormat += string.Format("{0}欄位必填,", strAryColumnName[iColumn]);
                    iErrCounts++;
                }
            }


            if (strErrMsgDataFormat.Trim().Length > 0)
            {
                if (strErrMsgDataFormat.Substring(strErrMsgDataFormat.Length - 1, 1) == ",")
                {
                    strErrMsgDataFormat = strErrMsgDataFormat.Substring(0, strErrMsgDataFormat.Length - 1);
                }
            }

            if (iErrCounts != 0)
            {
                bResult = false;
            }
            else
            {
                bResult = true;
            }

            return bResult;

            #endregion
        }
Пример #3
0
 public override Icon RenderIcon(Int32[] aValue, Boolean sleeping)
 {
     RenderCount++;
     if (sleeping) { return bmpToIcon(RenderSleeping()); }
     isSleeping = false;
     Bitmap tempBitmap = (Bitmap)BackgroundImage.Clone();
     if (aValue != null)
     {
         switch (aValue.GetUpperBound(0))
         {
             case 0:
                 Render1Bar(aValue, tempBitmap);
                 break;
             case 1:
                 Render2Bars(aValue, tempBitmap);
                 break;
             case 2:
                 Render3Bars(aValue, tempBitmap);
                 break;
             case 3:
                 Render4Bars(aValue, tempBitmap);
                 break;
             default:
                 Render5Bars(aValue, tempBitmap);
                 break;
         }
     }
     return bmpToIcon(tempBitmap);
 }
Пример #4
0
        /// <summary>
        /// 檢查原因代碼是否存在
        /// </summary>
        /// <param name="strReason"></param>
        /// <param name="strErrMsg"></param>
        /// <returns></returns>
        protected bool CheckReasonIsExisted(DataRow dr, Int32[] aryColumns, out string strErrMsgDataFormat)
        {
            #region
            bool bResult;
            Int32 iColumn, iErrCounts = 0; ;
            strErrMsgDataFormat = "";
            string strErrMsg = "";
            PIC.VDS2G.BSM.ALO.QueryALOCommon BCO = new PIC.VDS2G.BSM.ALO.QueryALOCommon(ConnectionDB);
            System.Collections.ArrayList ParameterList = new System.Collections.ArrayList();

            for (Int32 i = 0; i <= aryColumns.GetUpperBound(0); i++)
            {
                iColumn = aryColumns[i];

                if (iColumn == 6)//原因代碼
                {
                    ParameterList.Clear();
                    ParameterList.Add(dr[iColumn].ToString().Trim());

                    if (!BCO.CheckReasonIsExisted(ParameterList, out strErrMsg))
                    {
                        strErrMsgDataFormat += string.Format("{0}欄位:{1}不存在,", strAryColumnName[iColumn], dr[iColumn].ToString().Trim());
                        iErrCounts++;
                    }
                }
            }

            if (iErrCounts != 0)
            {
                bResult = false;
            }
            else
            {
                bResult = true;
            }

            return bResult;

            #endregion
        }
Пример #5
0
        /// <summary>
        /// 依配本方式('101','103','104')取得預設參照資訊
        /// dtParam(配本參數方式)、dtDisItem(配本商品)、V_DIS_TYPE、V_ITEM、V_PERIOD、I_ITEM_REFER_COUNT
        /// </summary>
        /// <param name="dtParam">配本參數方式</param>
        /// <param name="B1_PERIOD">前一期銷售實績</param>
        /// <param name="B2_PERIOD">前二期銷售實績</param>
        /// <param name="B3_PERIOD">前三期銷售實績</param>
        /// <param name="B4_PERIOD">前四期銷售實績</param>
        /// <param name="B5_PERIOD">前五期銷售實績</param>
        /// <param name="B6_PERIOD">前六期銷售實績</param>
        /// <param name="V_DIS_TYPE">配本方式</param>
        /// <param name="V_ITEM">品號</param>
        /// <param name="V_PERIOD">期別</param>
        /// <param name="I_ITEM_REFER_COUNT">設定品項參照數</param>        
        /// <returns>dtDisItemRefer</returns>
        public DataTable QueryDisItemReferByDisType(DataTable dtParam,
                                                    string B1_PERIOD,
                                                    string B2_PERIOD,
                                                    string B3_PERIOD,
                                                    string B4_PERIOD,
                                                    string B5_PERIOD,
                                                    string B6_PERIOD,
                                                    string V_DIS_TYPE,
                                                    string V_ITEM,
                                                    string V_PERIOD,
                                                    Int32 I_ITEM_REFER_COUNT
                                                    )
        {
            #region

            #region Variables
            Int32 iSelect_Period;               //往前取前幾期       
            Int32 iSelect_P_From;             //往前取前幾期From   
            Int32 iSelect_P_To;               //往前取前幾期To    
            string vOrderBy = "";             //排序方式 
            string vPeriod_S = "";            //期別起
            string vPeriod_E = "";            //期別迄
            string vITEM_NAME = "";

            DataTable dtItemSales = null;

            MaintainDisItemRefer BCODIR = new MaintainDisItemRefer(ConnectionDB);
            DataTable dtDisItemRefer = BCODIR.GetDisItemReferSchema();

            ArrayList Paramslist = new ArrayList();

            DataRow nRow = null;
            Int32 iStAcceptQty = 0;
            Int32 iBackwardQty = 0;
            Int32 iFoundCount = 0;
            Int32 iPeriod_S = 0;             //期別起
            Int32 iPeriod_E = 0;             //期別迄
            Int32 iPERIOD = 0;
            Int32 iRowCnt = 0;
            Int32[] i32AryPeriod = null;

            string sB1_Period = "";          //前1期期別
            string sB2_Period = "";          //前2期期別
            string sB3_Period = "";          //前3期期別
            string sB4_Period = "";          //前4期期別
            string sB5_Period = "";          //前5期期別
            string sB6_Period = "";          //前6期期別

            Int32 iB1_Period = 0;            //前1期期別
            Int32 iB2_Period = 0;            //前2期期別
            Int32 iB3_Period = 0;            //前3期期別
            Int32 iB4_Period = 0;            //前4期期別
            Int32 iB5_Period = 0;            //前5期期別
            Int32 iB6_Period = 0;            //前6期期別

            int SubQty = 0;
            Decimal REAL_SALESRATE = 0;
            Decimal REAL_SALESRATE_Sum = 0;
            #endregion

            try
            {
                #region
                //4.1) 判斷配本方式
                if (!(V_DIS_TYPE == "101" || V_DIS_TYPE == "103" || V_DIS_TYPE == "104"))
                {
                    //停止處理流程,離開此涵式 //不視為Exception;
                    return dtDisItemRefer;
                }

                //4.2) 取得基本資料與配本參數
                MaintainDisParameter BCO1 = new MaintainDisParameter(ConnectionDB);
                QueryALOCommon BCO2 = new QueryALOCommon(ConnectionDB);
                ITMModel.MaintainSKU BCO3 = new ITMModel.MaintainSKU(ConnectionDB);

                Paramslist.Clear();
                Paramslist.Add(V_ITEM);
                DataTable dt = BCO3.QuerySKUByCode(Paramslist);
                if (dt != null && dt.Rows.Count > 0)
                {
                    vITEM_NAME = dt.Rows[0]["ITEM_NAME"].ToString();
                }



                //a) 取得配本參數資料
                if (dtParam == null || dtParam.Rows.Count == 0)
                {
                    //重取配本方式參數
                    Paramslist.Clear();
                    Paramslist.Add(V_DIS_TYPE);
                    Paramslist.Add(1);
                    dtParam = BCO1.QuerySwitch(QueryType.CODE, Paramslist);
                }

                if (dtParam == null || dtParam.Rows.Count == 0)
                {
                    //顯示錯誤訊息『無此配本方式:V_DIS_TYPE』於訊息區;
                    throw new Exception(string.Format("無此配本方式:{0}", V_DIS_TYPE));
                }

                //b) 取得配本參數資料
                Int32.TryParse(dtParam.Rows[0]["SELECT_PERIOD"].ToString().Trim(), out iSelect_Period);       //往前取前幾期
                Int32.TryParse(dtParam.Rows[0]["SELECT_P_FROM"].ToString().Trim(), out iSelect_P_From);   //往前取前幾期From
                Int32.TryParse(dtParam.Rows[0]["SELECT_P_TO"].ToString().Trim(), out iSelect_P_To);       //往前取前幾期To


                //b) 取得配本商品資料
                //DataRow[] ItemRow = dtDisItem.Select("ITEM='" + V_ITEM + "' and PERIOD='" + V_PERIOD + "' ");

                //取得品項數
                if (I_ITEM_REFER_COUNT == 0)
                {
                    I_ITEM_REFER_COUNT = BCO2.GetDisItemReferCount(dtParam);
                }

                if (I_ITEM_REFER_COUNT == 0)
                {
                    //顯示錯誤訊息『參照品項數=0』於訊息區;
                    throw new Exception("參照品項數=0");
                }

                //c) 取得排序方式
                vOrderBy = "";

                if (dtParam.Rows[0]["SORT_KEY1"].ToString() != "")
                {
                    vOrderBy += dtParam.Rows[0]["SORT_KEY1"].ToString() + ",";
                }

                if (dtParam.Rows[0]["SORT_KEY2"].ToString() != "")
                {
                    vOrderBy += dtParam.Rows[0]["SORT_KEY2"].ToString() + ",";
                }

                if (dtParam.Rows[0]["SORT_KEY3"].ToString() != "")
                {
                    vOrderBy += dtParam.Rows[0]["SORT_KEY3"].ToString() + ",";
                }

                //# 去掉最後一個逗號 ","
                if (vOrderBy.Trim().Length > 0)
                {
                    if (vOrderBy.Substring(vOrderBy.Length - 1, 1) == ",")
                    {
                        vOrderBy = vOrderBy.Substring(0, vOrderBy.Length - 1);
                    }
                }

                //4.3) 依照配本方式設定設定不同計算期別
                switch (V_DIS_TYPE)
                {
                    case "101"://a) V_DIS_TYPE = 101 (前期比例)時
                        #region 前期比例
                        switch (iSelect_Period)
                        {
                            case 1:
                                vPeriod_S = B1_PERIOD;
                                break;
                            case 2:
                                vPeriod_S = B2_PERIOD;
                                break;
                            case 3:
                                vPeriod_S = B3_PERIOD;
                                break;
                            case 4:
                                vPeriod_S = B4_PERIOD;
                                break;
                            case 5:
                                vPeriod_S = B5_PERIOD;
                                break;
                            case 6:
                                vPeriod_S = B6_PERIOD;
                                break;
                            default:
                                throw new Exception("期別起無資料!");
                                break;
                        }
                        vPeriod_E = vPeriod_S;
                        #endregion
                        break;
                    case "103"://b) V_DIS_TYPE = 103 (實績加重) 或 104 (移行指數)時
                    case "104":
                        #region 移行指數
                        switch (iSelect_P_From)
                        {
                            case 1:
                                vPeriod_E = B1_PERIOD;
                                break;
                            case 2:
                                vPeriod_E = B2_PERIOD;
                                break;
                            case 3:
                                vPeriod_E = B3_PERIOD;
                                break;
                            case 4:
                                vPeriod_E = B4_PERIOD;
                                break;
                            case 5:
                                vPeriod_E = B5_PERIOD;
                                break;
                            case 6:
                                vPeriod_E = B6_PERIOD;
                                break;
                            default:
                                throw new Exception("往前取前幾期From無資料!");
                                break;
                        }
                        switch (iSelect_P_To)
                        {
                            case 1:
                                vPeriod_S = B1_PERIOD;
                                break;
                            case 2:
                                vPeriod_S = B2_PERIOD;
                                break;
                            case 3:
                                vPeriod_S = B3_PERIOD;
                                break;
                            case 4:
                                vPeriod_S = B4_PERIOD;
                                break;
                            case 5:
                                vPeriod_S = B5_PERIOD;
                                break;
                            case 6:
                                vPeriod_S = B6_PERIOD;
                                break;
                            default:
                                throw new Exception("往前取前幾期To無資料!");
                        }
                        #endregion
                        break;
                }

                //c) 取得前幾期銷售實績 
                Paramslist.Clear();
                Paramslist.Add(V_ITEM == "" ? null : V_ITEM);
                Paramslist.Add(vPeriod_S == "" ? null : vPeriod_S);
                Paramslist.Add(vPeriod_E == "" ? null : vPeriod_E);
                Paramslist.Add(vOrderBy == "" ? null : vOrderBy);

                dtItemSales = BCO2.QueryP6_PeriodSalesInfo(Paramslist);

                //4.4) 依照不同配本方式,取得新增參照商品資料
                Int32.TryParse(vPeriod_S, out iPeriod_S);
                Int32.TryParse(vPeriod_E, out iPeriod_E);

                sB1_Period = B1_PERIOD;
                sB2_Period = B2_PERIOD;
                sB3_Period = B3_PERIOD;
                sB4_Period = B4_PERIOD;
                sB5_Period = B5_PERIOD;
                sB6_Period = B6_PERIOD;

                Int32.TryParse(sB1_Period, out iB1_Period);
                Int32.TryParse(sB2_Period, out iB2_Period);
                Int32.TryParse(sB3_Period, out iB3_Period);
                Int32.TryParse(sB4_Period, out iB4_Period);
                Int32.TryParse(sB5_Period, out iB5_Period);
                Int32.TryParse(sB6_Period, out iB6_Period);

                #endregion

                switch (V_DIS_TYPE)
                {
                    case "101"://a) V_DIS_TYPE = 101 (前期比例)時 (vPeriod_S=vPeriod_E=前一期:P_B1)
                        #region
                        if (sB1_Period == "" || sB1_Period == null)
                        {
                            //* 前一期資料不存在時,設定訊息『新品無前期發行資訊』於訊息區。
                            throw new Exception("新品無前期發行資訊");
                        }

                        if (dtItemSales.Rows.Count == 0)
                        {
                            //* 前一期資料不存在銷售實績時,設定訊息『無前期實銷資訊』於訊息區。
                            throw new Exception("無前期實銷資訊,請使用其他配本方式");
                        }

                        Int32.TryParse(dtItemSales.Rows[0]["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty);
                        Int32.TryParse(dtItemSales.Rows[0]["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty);

                        nRow = dtDisItemRefer.NewRow();
                        nRow["ITEM"] = V_ITEM;                                                                               //--品號
                        nRow["ITEM_NAME"] = vITEM_NAME;                                                                      //--品名     
                        nRow["PERIOD"] = sB1_Period;                                                                         //--期別
                        nRow["RITEM"] = V_ITEM;                                                                              //--參照品號
                        nRow["RITEM_NAME"] = vITEM_NAME;                                                                     //--參照品名     
                        nRow["RPERIOD"] = vPeriod_S;                                                                         //--參照期別  
                        nRow["ST_ACCEPT_QTY"] = iStAcceptQty;                                                                //--進貨
                        nRow["BACKWARD_QTY"] = iBackwardQty;                                                                 //--退貨
                        nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty;                                                    //--實績                        
                        SubQty = iStAcceptQty - iBackwardQty;
                        if (iStAcceptQty == 0)
                        {
                            //REAL_SALESRATE = 0;
                            throw new Exception("前一期別無銷售實績,不可作為參照品項!!");
                        }
                        else
                        {
                            REAL_SALESRATE = Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100;
                        }
                        nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率
                        nRow["REFER_RATE"] = 100;                                                                            //--參照比率%  
                        dtDisItemRefer.Rows.Add(nRow);
                        break;
                        #endregion
                    case "103"://b) V_DIS_TYPE = 103 (實績加重) 時
                        #region

                        //# 由配本商品資料 ItemRow 中取前1期~前6期 (B1_PERIOD~B6_PERIOD)作計算基準

                        if (sB1_Period == "" && sB2_Period == "" && sB3_Period == "" && sB4_Period == "" && sB5_Period == "" && sB6_Period == "")
                        {
                            //顯示訊息『新品請使用其他配本方式』於訊息區,離開涵式處理流程。
                            throw new Exception("新品請使用其他配本方式");
                        }

                        //# 比較前1期~前6期 與 計算期別起迄(vPeriod_S~vPeriod_E),
                        //  將符合起迄的期別,記錄相符筆數

                        i32AryPeriod = new Int32[] { iB1_Period, iB2_Period, iB3_Period, iB4_Period, iB5_Period, iB6_Period };

                        for (Int32 i = 0; i <= i32AryPeriod.GetUpperBound(0); i++)
                        {
                            //if (iPeriod_S <= i32AryPeriod[i] && i32AryPeriod[i] <= iPeriod_E)
                            if ((i32AryPeriod[i]) >= iPeriod_S &&
                                 (i32AryPeriod[i] > 0 && i32AryPeriod[i] <= iPeriod_E))
                            {
                                iFoundCount++;
                            }
                        }


                        if (iFoundCount == 0)//--查無任何一筆相符資料
                        {
                            //顯示錯誤訊息『存在前六期別銷售資料,但查無可參照期別,請確認配本方式設定是否異常。』
                            throw new Exception("存在前六期別銷售資料,但查無可參照期別,請確認配本方式設定是否異常。");
                        }
                        else if (iFoundCount != iSelect_Period)// (往前選幾期)) --可用之參照期別品項數與參數檔設定不相符
                        {

                            //# 選出前一期別銷售實績
                            sB1_Period = B1_PERIOD;

                            //# 新增前一期資料作為參照商品,以例外比例作為參照比率%

                            QueryALOCommon BCOCommon = new QueryALOCommon(ConnectionDB);

                            Paramslist.Clear();
                            Paramslist.Add(V_ITEM);
                            Paramslist.Add(V_PERIOD);
                            DataTable dtTemp = BCOCommon.QueryItemPeriodSalesInfo(Paramslist);

                            if (dtTemp != null && dtTemp.Rows.Count > 0)
                            {
                                Int32.TryParse(dtTemp.Rows[0]["ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty);
                                Int32.TryParse(dtTemp.Rows[0]["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty);

                            }

                            nRow = dtDisItemRefer.NewRow();
                            nRow["ITEM"] = V_ITEM;                                                                               //--品號
                            nRow["ITEM_NAME"] = vITEM_NAME;                                                                      //--品名     
                            nRow["PERIOD"] = sB1_Period;                                                                         //--期別
                            nRow["RITEM"] = V_ITEM;                                                                              //--參照品號
                            nRow["RITEM_NAME"] = vITEM_NAME;                                                                     //--參照品名     
                            nRow["RPERIOD"] = B1_PERIOD;                                                                         //--參照期別=B1 
                            nRow["ST_ACCEPT_QTY"] = iStAcceptQty;                                                                //--進貨
                            nRow["BACKWARD_QTY"] = iBackwardQty;                                                                 //--退貨
                            nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty;                                                    //--實績
                            SubQty = iStAcceptQty - iBackwardQty;
                            if (iStAcceptQty > 0)
                            {
                                REAL_SALESRATE = Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100;
                            }
                            else
                            {
                                REAL_SALESRATE = 0;
                            }
                            nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率
                            nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_OTHER"];                                                 //--參照比率%,使用例外比率;                                                                           //--參照比率%  
                            dtDisItemRefer.Rows.Add(nRow);
                        }
                        else if (iFoundCount == iSelect_Period)//--可用之參照期別品項數與參數檔設定相符時
                        {
                            // --因為要考慮排序,所以使用dtItemSales的排序方式,進行資料新增與判斷。 
                            //依照 dtItemSales 的排序

                            iRowCnt = 0;
                            REAL_SALESRATE_Sum = 0;
                            foreach (DataRow dRow in dtItemSales.Rows)
                            {

                                Int32.TryParse(dRow["PERIOD"].ToString().Trim(), out iPERIOD);

                                if (iPeriod_S <= iPERIOD && iPERIOD <= iPeriod_E)
                                {
                                    iRowCnt++;
                                    if (iRowCnt > iSelect_Period)
                                    {
                                        break;
                                    }

                                    //# 新增一筆資料作為參照商品, 依新增iRowCont 取得參照比率
                                    Int32.TryParse(dRow["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty);
                                    Int32.TryParse(dRow["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty);

                                    nRow = dtDisItemRefer.NewRow();
                                    nRow["ITEM"] = V_ITEM;                                                                               //--品號
                                    nRow["ITEM_NAME"] = vITEM_NAME;                                                                      //--品名     
                                    nRow["PERIOD"] = sB1_Period;                                                                         //--期別
                                    nRow["RITEM"] = V_ITEM;                                                                              //--參照品號
                                    nRow["RITEM_NAME"] = vITEM_NAME;                                                                     //--參照品名     
                                    nRow["RPERIOD"] = dRow["PERIOD"];                                                                    //--參照期別  
                                    nRow["ST_ACCEPT_QTY"] = iStAcceptQty;                                                                //--進貨
                                    nRow["BACKWARD_QTY"] = iBackwardQty;                                                                 //--退貨
                                    nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty;                                                    //--實績
                                    SubQty = iStAcceptQty - iBackwardQty;
                                    REAL_SALESRATE = (iStAcceptQty == 0) ? 0 : Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100;
                                    REAL_SALESRATE_Sum += REAL_SALESRATE;// 實銷率合計
                                    nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率
                                    nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_RATE" + iRowCnt.ToString()];                             //--參照比率%,依照排序順序取得參照比率  
                                    dtDisItemRefer.Rows.Add(nRow);
                                }

                            }//end for
                            // 新增判斷 所有參照品項的銷售實績均為0時,需alert訊息
                            if (REAL_SALESRATE_Sum < 1)
                            {
                                throw new Exception("參照品項均無銷售實績,請調整參照品項");
                            }
                        }

                        break;
                        #endregion
                    case "104"://c) V_DIS_TYPE = 104 (移行指數) 時
                        #region

                        //# 由配本商品資料 ItemRow 中取前1期~前6期 (B1_PERIOD~B6_PERIOD)作計算基準

                        if (sB1_Period == "" && sB2_Period == "" && sB3_Period == "" && sB4_Period == "" && sB5_Period == "" && sB6_Period == "")
                        {
                            //顯示訊息『新品請使用其他配本方式』於訊息區,離開涵式處理流程。
                            throw new Exception("新品請使用其他配本方式");
                        }


                        //# 比較前1期~前6期 與 計算期別起迄(vPeriod_S~vPeriod_E),
                        //  將符合起迄的期別,記錄相符筆數

                        i32AryPeriod = new Int32[] { iB1_Period, iB2_Period, iB3_Period, iB4_Period, iB5_Period, iB6_Period };

                        for (Int32 i = 0; i <= i32AryPeriod.GetUpperBound(0); i++)
                        {
                            if (iPeriod_S <= i32AryPeriod[i] && i32AryPeriod[i] <= iPeriod_E)
                            {
                                iFoundCount++;
                            }
                        }

                        if (iFoundCount == 0 || iFoundCount != iSelect_Period)
                        {
                            //顯示錯誤訊息『銷售期別不足,請使用其他配本方式。』
                            throw new Exception("銷售期別不足,請使用其他配本方式。");

                        }
                        else if (iFoundCount == iSelect_Period)
                        {

                            //--因為要考慮排序,所以使用dtItemSales的排序方式,進行資料新增與判斷。 
                            //  依照 dtItemSales 的排序

                            iRowCnt = 0;
                            REAL_SALESRATE_Sum = 0;
                            foreach (DataRow dRow in dtItemSales.Rows)
                            {
                                Int32.TryParse(dRow["PERIOD"].ToString().Trim(), out iPERIOD);

                                if (iPeriod_S <= iPERIOD && iPERIOD <= iPeriod_E)
                                {
                                    iRowCnt++;
                                    if (iRowCnt > iSelect_Period)
                                    {
                                        break;
                                    }

                                    //# 新增一筆資料作為參照商品, 依新增iRowCont 取得參照比率
                                    Int32.TryParse(dRow["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty);
                                    Int32.TryParse(dRow["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty);

                                    nRow = dtDisItemRefer.NewRow();
                                    nRow["ITEM"] = V_ITEM;                                                                               //--品號
                                    nRow["ITEM_NAME"] = vITEM_NAME;                                                                      //--品名     
                                    nRow["PERIOD"] = dRow["PERIOD"];                                                                     //--期別
                                    nRow["RITEM"] = V_ITEM;                                                                              //--參照品號
                                    nRow["RITEM_NAME"] = vITEM_NAME;                                                                     //--參照品名     
                                    nRow["RPERIOD"] = dRow["PERIOD"];                                                                    //--參照期別  
                                    nRow["ST_ACCEPT_QTY"] = iStAcceptQty;                                                                //--進貨
                                    nRow["BACKWARD_QTY"] = iBackwardQty;                                                                 //--退貨
                                    nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty;                                                    //--實績
                                    SubQty = iStAcceptQty - iBackwardQty;
                                    REAL_SALESRATE = (iStAcceptQty == 0) ? 0 : Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100;
                                    REAL_SALESRATE_Sum += REAL_SALESRATE;// 實銷率合計
                                    nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率
                                    nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_RATE" + iRowCnt.ToString()];                             //--參照比率%,依照排序順序取得參照比率  
                                    dtDisItemRefer.Rows.Add(nRow);
                                }
                            }
                        }

                        // 新增判斷 所有參照品項的銷售實績均為0時,需alert訊息
                        if (REAL_SALESRATE_Sum < 1)
                        {
                            throw new Exception("參照品項均無銷售實績,請調整參照品項");
                        }

                        #region 取得去年同期資訊 2009-07-16 cyhsu add

                        string sErrMsg = "";
                        Paramslist.Clear();
                        Paramslist.Add(V_ITEM);
                        Paramslist.Add(V_PERIOD);

                        DataTable dtLY_Sales = QueryLastYear_PeriodSalesInfo(Paramslist);
                        if (dtLY_Sales != null && dtLY_Sales.Rows.Count > 0)
                        {
                            #region 逐筆新增配本參照資料
                            foreach (DataRow dRow in dtLY_Sales.Rows)
                            {
                                //# 新增一筆資料作為參照商品, 依新增iRowCont 取得參照比率
                                Int32.TryParse(dRow["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty);
                                Int32.TryParse(dRow["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty);

                                nRow = dtDisItemRefer.NewRow();
                                nRow["ITEM"] = V_ITEM;                                                                               //--品號
                                nRow["ITEM_NAME"] = vITEM_NAME;                                                                      //--品名     
                                nRow["PERIOD"] = dRow["PERIOD"];                                                                     //--期別
                                nRow["RITEM"] = V_ITEM;                                                                              //--參照品號
                                nRow["RITEM_NAME"] = vITEM_NAME;                                                                     //--參照品名     
                                nRow["RPERIOD"] = dRow["PERIOD"];                                                                    //--參照期別  
                                nRow["ST_ACCEPT_QTY"] = iStAcceptQty;                                                                //--進貨
                                nRow["BACKWARD_QTY"] = iBackwardQty;                                                                 //--退貨
                                nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty;                                                    //--實績
                                SubQty = iStAcceptQty - iBackwardQty;
                                REAL_SALESRATE = (iStAcceptQty == 0) ? 0 : Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100;
                                nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率
                                nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_RATE" + iRowCnt.ToString()];                             //--參照比率%,依照排序順序取得參照比率  
                                dtDisItemRefer.Rows.Add(nRow);
                            }
                            #endregion
                        }
                        dtLY_Sales.Dispose();
                        #endregion

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



            return dtDisItemRefer;
            #endregion
        }
Пример #6
0
		/// <summary>
		/// Copies this list into another KeyboardrActionList
		/// </summary>
		/// <param name="array">Target list</param>
		/// <param name="start">Start index</param>
		public void CopyTo(T[] array, int start)
		{
			if (m_count > array.GetUpperBound(0) + 1 - start)
				throw new ArgumentException("Destination array was not long enough.");

			// for (int i=0; i < m_count; ++i) array[start+i] = m_array[i];
			Array.Copy(m_array, 0, array, start, m_count);
		}
Пример #7
0
        //Do we need to redraw this icon.
        public virtual Boolean NeedRedraw(Int32[] aValues, Boolean sleeping)
        {
            if (Globals.AlwaysRedrawIcons) { return true; }
            if (AlwaysRedraw) { return true; }
            if (aValues == null) { return true; }
            if (sleeping) { return true; }
            if (isSleeping) { return true; }

            for (Int32 i = 0; i <= aValues.GetUpperBound(0); i++)
            {
                if (!(i > MaxValues  - 1))
                {
                    if (aValues[i] != LastValue[i]) { return true; }
                }
            }
            return false;
        }