コード例 #1
0
        /// <summary>
        /// 個建運賃テーブルによる計算
        /// </summary>
        /// <param name="result"></param>
        /// <param name="p請求支払区分"></param>
        /// <param name="p得意先ID"></param>
        /// <param name="p着地ID"></param>
        /// <param name="p重量"></param>
        /// <param name="p数量"></param>
        public void GetUnitCostMatrix(DLY01010_TANKA result, int p請求支払区分, int p得意先ID, int p着地ID, decimal p重量, decimal p数量)
        {
            using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
            {
                context.Connection.Open();
                int tcode = (from k in context.M01_TOK
                             where k.得意先ID == p得意先ID &&
                             k.削除日付 == null
                             select k.得意先KEY).FirstOrDefault();

                if (p請求支払区分 == 0)
                {
                    p重量 *= 1000;
                    var tankadata = (from r in context.M02_TTAN4
                                     where r.得意先KEY == tcode &&
                                     r.重量 >= p重量 &&
                                     r.数 >= p数量 &&
                                     (r.着地ID == p着地ID || r.着地ID == 0) &&
                                     r.削除日付 == null
                                     orderby r.重量, r.数, r.着地ID descending
                                     select r).FirstOrDefault();

                    if (tankadata != null)
                    {
                        result.Tanka   = tankadata.建金額 == 0 ? tankadata.建単価 : 0;
                        result.Kingaku = (tankadata.建単価 * (decimal)p数量) + tankadata.建金額;
                    }
                    else
                    {
                        result.Tanka   = 0;
                        result.Kingaku = 0;
                    }
                }
                else
                {
                    p重量 *= 1000;
                    var tankadata = (from r in context.M03_YTAN4
                                     where r.支払先KEY == tcode &&
                                     r.重量 >= p重量 &&
                                     r.数 >= p数量 &&
                                     (r.着地ID == p着地ID || r.着地ID == 0) &&
                                     r.削除日付 == null
                                     orderby r.重量, r.数, r.着地ID descending
                                     select r).FirstOrDefault();

                    if (tankadata != null)
                    {
                        result.Tanka   = tankadata.建金額 == 0 ? tankadata.建単価 : 0;
                        result.Kingaku = (tankadata.建単価 * (decimal)p数量) + tankadata.建金額;
                    }
                    else
                    {
                        result.Tanka   = 0;
                        result.Kingaku = 0;
                    }
                }
            }

            return;
        }
コード例 #2
0
        /// <summary>
        /// 車種と地区による運賃計算
        /// </summary>
        /// <param name="result"></param>
        /// <param name="p請求支払区分"></param>
        /// <param name="p得意先ID"></param>
        /// <param name="p発地ID"></param>
        /// <param name="p着地ID"></param>
        /// <param name="p車種ID"></param>
        public void GetUnitCostCar(DLY01010_TANKA result, int p請求支払区分, int p得意先ID, int p発地ID, int p着地ID, int p車種ID, decimal p重量, decimal p数量)
        {
            using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
            {
                context.Connection.Open();
                int tcode = (from k in context.M01_TOK
                             where k.得意先ID == p得意先ID &&
                             k.削除日付 == null
                             select k.得意先KEY).FirstOrDefault();

                if (p請求支払区分 == 0)
                {
                    var tankadata = (from r in context.M02_TTAN2
                                     where r.得意先KEY == tcode &&
                                     r.車種ID == p車種ID &&
                                     (r.発地ID == p発地ID || r.発地ID == 0) &&
                                     (r.着地ID == p着地ID || r.着地ID == 0) &&
                                     r.削除日付 == null
                                     orderby r.発地ID descending, r.着地ID descending
                                     select r).FirstOrDefault();

                    if (tankadata != null)
                    {
                        result.Tanka   = tankadata.売上単価;
                        result.Kingaku = p重量 * p数量 * result.Tanka;
                    }
                    else
                    {
                        result.Tanka   = 0;
                        result.Kingaku = 0;
                    }
                }
                else
                {
                    var tankadata = (from r in context.M03_YTAN2
                                     where r.支払先KEY == tcode &&
                                     r.車種ID == p車種ID &&
                                     (r.発地ID == p発地ID || r.発地ID == 0) &&
                                     (r.着地ID == p着地ID || r.着地ID == 0) &&
                                     r.削除日付 == null
                                     orderby r.発地ID descending, r.着地ID descending
                                     select r).FirstOrDefault();

                    if (tankadata != null)
                    {
                        result.Tanka   = tankadata.支払単価;
                        result.Kingaku = p重量 * p数量 * result.Tanka;
                    }
                    else
                    {
                        result.Tanka   = 0;
                        result.Kingaku = 0;
                    }
                }
            }

            return;
        }
コード例 #3
0
        /// <summary>
        /// 距離と重量による運賃計算
        /// </summary>
        /// <param name="result"></param>
        /// <param name="p請求支払区分"></param>
        /// <param name="p得意先ID"></param>
        /// <param name="p重量"></param>
        /// <param name="p走行KM"></param>
        public void GetUnitCostTariff(DLY01010_TANKA result, int p請求支払区分, int p得意先ID, decimal p重量, int p走行KM)
        {
            using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
            {
                p重量 *= 1000;
                decimal?kingaku = null;
                context.Connection.Open();


                if (p請求支払区分 == 0)
                {
                    int tcode = (from k in context.M01_TOK
                                 where k.得意先ID == p得意先ID &&
                                 k.削除日付 == null
                                 select k.T路線計算年度).FirstOrDefault();

                    kingaku = (from r in context.M50_RTBL
                               where r.タリフコード == tcode &&
                               r.距離 >= p走行KM &&
                               r.重量 >= p重量 &&
                               r.削除日付 == null
                               orderby r.距離, r.重量
                               select r.運賃).FirstOrDefault();
                }
                if (p請求支払区分 == 1)
                {
                    int tcode = (from k in context.M01_TOK
                                 where k.得意先ID == p得意先ID &&
                                 k.削除日付 == null
                                 select k.S路線計算年度).FirstOrDefault();

                    kingaku = (from r in context.M50_RTBL
                               where r.タリフコード == tcode &&
                               r.距離 >= p走行KM &&
                               r.重量 >= p重量 &&
                               r.削除日付 == null
                               orderby r.距離, r.重量
                               select r.運賃).FirstOrDefault();
                }


                if (kingaku != null)
                {
                    result.Kingaku = (decimal)kingaku;
                }
                else
                {
                    result.Kingaku = 0;
                }
            }

            return;
        }
コード例 #4
0
        public List <DLY01010_TANKA> GetUnitCost(int p計算区分, int p請求支払区分, int p得意先ID, int p発地ID, int p着地ID, int p商品ID, int p車種ID, int p走行KM, decimal p重量, decimal p数量)
        {
            /*
             * コード	表示名
             *  0	手入力
             *  1	数量計算
             *  2	重量計算
             *  3	運賃タリフ
             *  4	地区単価
             *  5	車種運賃
             *  6	個建単価
             */
            DLY01010_TANKA result = new DLY01010_TANKA();

            result.Kubun   = p請求支払区分;
            result.Tanka   = -1;
            result.Kingaku = -1;
            switch (p計算区分)
            {
            case 3:
                GetUnitCostTariff(result, p請求支払区分, p得意先ID, p重量, p走行KM);
                break;

            case 4:
                GetUnitCostArea(result, p請求支払区分, p得意先ID, p発地ID, p着地ID, p商品ID, p重量, p数量);
                break;

            case 5:
                GetUnitCostCar(result, p請求支払区分, p得意先ID, p発地ID, p着地ID, p車種ID, p重量, p数量);
                break;

            case 6:
                GetUnitCostMatrix(result, p請求支払区分, p得意先ID, p着地ID, p重量, p数量);
                break;
            }

            return(new List <DLY01010_TANKA>()
            {
                result
            });
        }