public IHttpActionResult GenerateSupplementoryCharges(CustomerRate Rate)
        {
            FrayteManifestName result = new FrayteManifestName();

            result = new CustomerRepository().DownloadSupplemantoryChargePdf(Rate);
            return(Ok(result));
        }
        public ActionResult Edit(int id)
        {
            ViewBag.CustRate        = db.CustomerRateTypes.ToList();
            ViewBag.ProductType     = db.ProductTypes.ToList();
            ViewBag.ForwardingAgent = db.ForwardingAgentMasters.ToList();
            ViewBag.Zones           = db.ZoneCharts.ToList();

            CustRateVM   vm = new CustRateVM();
            CustomerRate r  = db.CustomerRates.Find(id);

            if (r != null)
            {
                vm.BaseRate           = r.BaseRate;
                vm.BaseWt             = r.BaseWeight;
                vm.ContractRateID     = r.CustomerRateID;
                vm.ContractRateTypeID = r.CustomerRateTypeID;
                vm.ProductTypeID      = r.CourierServiceID;
                vm.ZoneChartID        = r.ZoneChartID;
                vm.CountryID          = r.CountryID.Value;
                vm.FAgentID           = r.FAgentID.Value;
                vm.CustomerRateID     = r.CustomerRateID;
                vm.AdditionalCharges  = r.AdditionalCharges.Value;
                vm.withtax            = r.WithTax.Value;
                vm.withouttax         = r.WithoutTax.Value;
            }
            else
            {
                return(HttpNotFound());
            }


            return(View(vm));
        }
Example #3
0
        /// <summary>
        /// Set customer information
        /// </summary>
        /// <param name="customer">See <see cref="Customer"/></param>
        /// <param name="customerRate">See <see cref="CustomerRate"/></param>
        internal void SetCustomerInformation(Customer customer, CustomerRate customerRate)
        {
            this.FakeRinging = customer.FakeRinging;

            this.CustomerHasRate        = customerRate.Id.HasValue;
            this.CustomerRateId         = customerRate.Id;
            this.CustomerRatePerMin     = customerRate.RatePerMin;
            this.CustomerRateCurrency   = customerRate.Currency;
            this.CustomerRateNormalized = customerRate.RateNormalized;
        }
        public ActionResult Create(CustRateVM v)
        {
            try
            {
                CustomerRate r = new CustomerRate();
                r.CustomerRateTypeID = v.ContractRateTypeID;
                r.CourierServiceID   = v.ProductTypeID;
                r.ZoneChartID        = v.ZoneChartID;
                r.FAgentID           = v.FAgentID;
                r.BaseWeight         = v.BaseWt;
                r.WithTax            = v.withtax;
                r.WithoutTax         = v.withouttax;
                r.AdditionalCharges  = v.AdditionalCharges;

                r.BaseRate = v.BaseRate;

                db.CustomerRates.Add(r);
                db.SaveChanges();


                if (v.CustRateDetails != null)
                {
                    foreach (var item in v.CustRateDetails)
                    {
                        CustomerRateDet a = new CustomerRateDet();

                        a.CustomerRateID       = r.CustomerRateID;
                        a.AdditionalWeightFrom = item.AddWtFrom;
                        a.AdditionalWeightTo   = item.AddWtTo;
                        a.IncrementalWeight    = item.IncrWt;
                        a.AdditionalRate       = item.AddRate;

                        db.CustomerRateDets.Add(a);
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
            }

            ViewBag.CustRate        = db.CustomerRateTypes.ToList();
            ViewBag.ProductType     = db.ProductTypes.ToList();
            ViewBag.ForwardingAgent = db.ForwardingAgentMasters.ToList();
            ViewBag.Zones           = db.ZoneCharts.ToList();
            return(View());
        }
        public IHttpActionResult SendCustomerRateCardAsEmail(CustomerRate Customer)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                var filepath = new CustomerBaseRateReport().CustomerBaseRate(Customer);
                result = new ShipmentEmailRepository().EmailCustomerRateCard(Customer, filepath.FileName, filepath.FilePath);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }
            return(Ok(result));
        }
Example #6
0
        public ResultAndError <CustomerRate> Add(CustomerRate c)
        {
            ResultAndError <CustomerRate> result = new ResultAndError <CustomerRate>();

            try
            {
                db.CustomerRates.Add(c);
                db.SaveChanges();
                return(result.AddResult(c));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #7
0
        public bool DeleteMulti(IEnumerable <string> CustomerRates)
        {
            List <CustomerRate> oCustomerRates = new List <CustomerRate>();

            foreach (string CustomerRateNo in CustomerRates)
            {
                CustomerRate oCustomerRate = Get(CustomerRateNo);
                if (oCustomerRate != null)
                {
                    oCustomerRates.Add(oCustomerRate);
                }
            }
            db.CustomerRates.RemoveRange(oCustomerRates);
            db.SaveChanges();
            return(true);
        }
Example #8
0
 public bool UpdateMulti(IEnumerable <CustomerRate> oCustomerRates, bool insertIfNoExists = false)
 {
     foreach (CustomerRate CustomerRate in oCustomerRates)
     {
         CustomerRate old = Get(CustomerRate.ItemNo);
         if (old == null && insertIfNoExists)
         {
             Add(CustomerRate);
         }
         else
         {
             db.Entry(old).CurrentValues.SetValues(CustomerRate);
         }
     }
     db.SaveChanges();
     return(true);
 }
 public CustomerRate_View(CustomerRate c)
 {
     ItemNo             = c.ItemNo;
     Product            = c.Product;
     Customer           = c.Customer;
     StartingDate       = c.StartingDate;
     EndingDate         = c.EndingDate;
     UnitPrice          = c.UnitPrice;
     SalesType          = c.SalesType;
     MinimumQuantity    = c.MinimumQuantity;
     UnitMeasureProduct = c.UnitMeasureProduct;
     UnitMeasureCode    = c.UnitMeasureCode;
     SalesCode          = c.SalesCode;
     SalesCenters       = c.SalesCenters;
     ServiciosTotales   = CalcServiciosTotales(c.SalesCenters);
     VentasTotales      = Convert.ToDecimal((ServiciosTotales * c.UnitPrice).Value.ToString("N2"));
 }
Example #10
0
        public IHttpActionResult GenerateCustomerBaseRateCard(CustomerRate Rate)
        {
            FrayteManifestName result = new FrayteManifestName();

            if (Rate.FileType == FrayteCustomerBaseRateFileType.Excel)
            {
                result = new CustomerBaseRateReport().CustomerBaseRate(Rate);
            }
            else if (Rate.FileType == FrayteCustomerBaseRateFileType.Pdf)
            {
                result = new CustomerBaseRateReport().CustomerBaseRate(Rate);
            }
            else if (Rate.SendingOption == FrayteCustomerBaseRateFileType.Summery)
            {
                result = new CustomerBaseRateReport().CustomerBaseRateSummery(Rate);
            }
            return(Ok(result));
        }
        public ActionResult Edit(CustRateVM v)
        {
            CustomerRate r = new CustomerRate();

            r.CustomerRateID     = v.CustomerRateID;
            r.CustomerRateTypeID = v.ContractRateTypeID;
            r.CourierServiceID   = v.ProductTypeID;
            r.ZoneChartID        = v.ZoneChartID;
            r.FAgentID           = v.FAgentID;
            r.BaseWeight         = v.BaseWt;
            r.WithTax            = v.withtax;
            r.WithoutTax         = v.withouttax;
            r.AdditionalCharges  = v.AdditionalCharges;

            r.BaseRate = v.BaseRate;

            db.Entry(r).State = EntityState.Modified;
            db.SaveChanges();

            var data = (from c in db.CustomerRateDets where c.CustomerRateID == v.CustomerRateID select c).ToList();

            foreach (var item in data)
            {
                db.CustomerRateDets.Remove(item);
                db.SaveChanges();
            }

            foreach (var item in v.CustRateDetails)
            {
                CustomerRateDet a = new CustomerRateDet();

                a.CustomerRateID       = r.CustomerRateID;
                a.AdditionalWeightFrom = item.AddWtFrom;
                a.AdditionalWeightTo   = item.AddWtTo;
                a.IncrementalWeight    = item.IncrWt;
                a.AdditionalRate       = item.AddRate;

                db.CustomerRateDets.Add(a);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Example #12
0
        public ResultAndError <bool> Delete(string id)
        {
            ResultAndError <bool> result = new ResultAndError <bool>();

            try
            {
                CustomerRate CustomerRate = Get(id);
                if (CustomerRate == null)
                {
                    return(result.AddError("No se encontro la tarifa con el id " + id));
                }
                db.CustomerRates.Remove(CustomerRate);
                db.SaveChanges();
                return(result.AddResult(true));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #13
0
        public ResultAndError <CustomerRate> Update(CustomerRate cr, bool insertIfNoExists = false)
        {
            ResultAndError <CustomerRate> result = new ResultAndError <CustomerRate>();

            try
            {
                CustomerRate old = Get(cr.ItemNo);
                if (old == null && insertIfNoExists)
                {
                    return(Add(cr));
                }
                db.Entry(old).CurrentValues.SetValues(cr);
                db.SaveChanges();
                return(result.AddResult(cr));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #14
0
        internal static void SendExcelRateCardMail(List <FryateUserSettingDetail> _customerlogistics, int UserId, string UserName, int OperationZoneId)
        {
            try
            {
                int           n = 0;
                CustomerRate  rate;
                List <string> filepath = new List <string>();
                List <string> filename = new List <string>();
                foreach (var Obj in _customerlogistics)
                {
                    rate                   = new CustomerRate();
                    rate.UserId            = UserId;
                    rate.CustomerName      = UserName;
                    rate.LogisticServiceId = Obj.LogisticService.LogisticServiceId;
                    rate.LogisticType      = Obj.LogisticService.LogisticType;
                    rate.RateType          = Obj.LogisticService.RateType;
                    rate.FileType          = FrayteCustomerBaseRateFileType.Excel;
                    FrayteManifestName file = new CustomerBaseRateReport().CustomerBaseRate(rate);

                    filepath.Add(file.FilePath);
                    filename.Add(file.FileName);
                    n++;
                }

                //Sened Mail
                if (filepath.Count > 0)
                {
                    FrayteResult result = new ShipmentEmailRepository().EmailCustomerRateCard(UserId, filename, filepath, OperationZoneId);
                    Logger       _log   = Get_Log();
                    _log.Info("(" + n + ") " + filepath.Count + "\n");
                    _log.Error(result.Status.ToString() + "\n" + result.Errors);
                }
            }
            catch (Exception ex)
            {
                Logger _log = Get_Log();
                _log.Info("Error sending customer rate card excel " + ex.Message);
                _log.Error(ex);
            }
        }
        public ActionResult DeleteConfirmed(int id = 0)
        {
            CustomerRate a = db.CustomerRates.Find(id);

            if (a == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.CustomerRates.Remove(a);
                db.SaveChanges();

                List <CustomerRateDet> lst = (from c in db.CustomerRateDets where c.CustomerRateID == id select c).ToList();

                foreach (var item in lst)
                {
                    db.CustomerRateDets.Remove(item);
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
        }
Example #16
0
 public IActionResult UpdCustomerRate([FromBody] CustomerRate customerRate, bool insertIfNoExists = false)
 {
     return(Ok(cBS.Update(customerRate, insertIfNoExists)));
 }
Example #17
0
        public void F_LoadExcel()
        {
            //引用//ReferenceCode/ExcelColumn.cs的類別
            CustomerRate GetExcelDefine = new CustomerRate();

            //導入匯入table
            GetExcelDefine.RateDT();
            //上傳路徑
            String    savePath = Server.MapPath(@"~\ExcelUpLoad\Finance\CustomerRate");
            string    str頁簽名稱 = "", str三巡時間年 = "", str三巡時間月 = "", str三巡時間巡 = "";
            DataTable D_table = new DataTable("Excel");

            //建立Excel欄位
            D_table = GetExcelDefine.CustomerRateDataTable.Copy();
            DataTable D_errortable = new DataTable("Error");
            //實際顯示欄位
            int Excel欄位數 = D_table.Columns.Count - 2;
            int iyear    = 0;

            if (文件上傳FU.HasFile)
            {
                string fileName = 文件上傳FU.FileName;
                Session["FileName"] = fileName;
                savePath            = savePath + fileName;
                文件上傳FU.SaveAs(savePath);

                bool bCheckTime = true, bCheckDB = true;

                #region ErrorTable
                //                    D_errortable.Columns.Add("SheetName");
                D_errortable.Columns.Add("Error");
                //D_errortable.Columns.Add("Error");
                #endregion


                if (fileName.Substring(fileName.Length - 4, 4).ToUpper() == "XLSX")
                {
                    XSSFWorkbook workbook = new XSSFWorkbook(文件上傳FU.FileContent);  //==只能讀取 System.IO.Stream

                    for (int x = 0; x < workbook.NumberOfSheets; x++)
                    {
                        XSSFSheet u_sheet   = (XSSFSheet)workbook.GetSheetAt(x); //-- 0表示:第一個 worksheet工作表
                        XSSFRow   headerRow = (XSSFRow)u_sheet.GetRow(3);        //-- Excel 表頭列
                        //抓第一行資料
                        IRow DateRow = (IRow)u_sheet.GetRow(0);                  //-- v.1.2.4版修改
                        //Session["Date"] = SearchTB.Text;
                        str頁簽名稱 = u_sheet.SheetName.ToString();
                        //str三巡時間 = DateRow.GetCell(3).ToString();
                        if ("三巡外匯表" == str頁簽名稱)
                        {
                            try
                            {
                                if (string.IsNullOrEmpty(DateRow.Cells[5].ToString()))
                                {
                                    bCheckTime = false;
                                }
                                str三巡時間年 = DateRow.Cells[5].ToString();
                                if (string.IsNullOrEmpty(DateRow.Cells[7].ToString()))
                                {
                                    bCheckTime = false;
                                }
                                str三巡時間月 = DateRow.Cells[7].ToString();
                                if (string.IsNullOrEmpty(DateRow.Cells[9].ToString()))
                                {
                                    bCheckTime = false;
                                }
                                str三巡時間巡 = DateRow.Cells[9].ToString();
                                int.TryParse(str三巡時間年, out iyear);
                                if (iyear > 0)
                                {
                                    iyear    = iyear + 1911;
                                    str三巡時間年 = iyear.ToString();
                                }
                                else
                                {
                                    bCheckTime = false;
                                }
                                if (bCheckTime)
                                {
                                    bCheckDB = F_CheckData(str三巡時間巡, str三巡時間年 + str三巡時間月);
                                }
                            }
                            catch (Exception)
                            {
                                //日期確認失敗
                                bCheckTime = false;
                            }
                            //執行程式
                            if (bCheckTime && bCheckDB)
                            {
                                //i=1第二列開始
                                for (int i = 1; i <= u_sheet.LastRowNum; i++)   //-- 每一列做迴圈
                                {
                                    //--不包含 Excel表頭列的 "其他資料列"
                                    IRow row = (IRow)u_sheet.GetRow(i);
                                    F_資料確認(D_table, D_errortable, str頁簽名稱, row);
                                }
                            }
                            else if (!bCheckTime)
                            {
                                F_ErrorShow("三巡日期錯誤");
                            }
                        }
                        //-- 釋放 NPOI的資源
                        u_sheet = null;
                    }
                    //-- 釋放 NPOI的資源
                    workbook = null;
                }
                else
                {
                    HSSFWorkbook workbook = new HSSFWorkbook(文件上傳FU.FileContent);  //==只能讀取 System.IO.Stream
                    for (int x = 0; x < workbook.NumberOfSheets; x++)
                    {
                        HSSFSheet u_sheet   = (HSSFSheet)workbook.GetSheetAt(x); //-- 0表示:第一個 worksheet工作表
                        HSSFRow   headerRow = (HSSFRow)u_sheet.GetRow(3);        //-- Excel 表頭列
                        IRow      DateRow   = (IRow)u_sheet.GetRow(2);           //-- v.1.2.4版修改
                        str頁簽名稱 = u_sheet.SheetName.ToString();

                        if ("三巡外匯表" == str頁簽名稱)
                        {
                            try
                            {
                                if (string.IsNullOrEmpty(DateRow.Cells[5].ToString()))
                                {
                                    bCheckTime = false;
                                }
                                //str三巡時間年 = DateRow.Cells[5].ToString();
                                if (string.IsNullOrEmpty(DateRow.Cells[7].ToString()))
                                {
                                    bCheckTime = false;
                                }
                                str三巡時間月 = DateRow.Cells[7].ToString();
                                if (string.IsNullOrEmpty(DateRow.Cells[9].ToString()))
                                {
                                    bCheckTime = false;
                                }
                                str三巡時間巡 = DateRow.Cells[9].ToString();
                                int.TryParse(str三巡時間年, out iyear);
                                if (iyear > 0)
                                {
                                    iyear    = iyear + 1911;
                                    str三巡時間年 = iyear.ToString();
                                }
                                else
                                {
                                    bCheckTime = false;
                                }
                                if (bCheckTime)
                                {
                                    bCheckTime = F_CheckData(str三巡時間巡, str三巡時間年 + str三巡時間月);
                                }
                            }
                            catch (Exception)
                            {
                                //日期確認失敗
                                bCheckTime = false;
                            }
                            //執行程式
                            if (bCheckTime)
                            {
                                //i=1第二列開始
                                for (int i = 1; i <= u_sheet.LastRowNum; i++)   //-- 每一列做迴圈
                                {
                                    //--不包含 Excel表頭列的 "其他資料列"
                                    IRow row = (IRow)u_sheet.GetRow(i);
                                    F_資料確認(D_table, D_errortable, str頁簽名稱, row);
                                }
                            }
                            else
                            {
                                F_ErrorShow("三巡日期錯誤");
                            }
                        }
                        //-- 釋放 NPOI的資源
                        u_sheet = null;
                    }
                    //-- 釋放 NPOI的資源
                    workbook = null;
                }
            }
            else
            {
                F_Show(false);
                F_ErrorShow("????  ...... 請先挑選檔案之後,再來上傳");
            }   // FileUpload使用的第一個 if判別式

            if (D_table.Rows.Count > 0)
            {
                Session["Excel"]    = D_table;
                Session["三巡時間年"]    = iyear.ToString();
                Session["三巡時間月"]    = str三巡時間月;
                Session["str三巡時間巡"] = str三巡時間巡;
                YearLB.Text         = iyear.ToString();
                MonthLB.Text        = str三巡時間月;
                switch (str三巡時間巡)
                {
                case "1":
                    巡LB.Text = "上巡";
                    break;

                case "2":
                    巡LB.Text = "中巡";
                    break;

                default:
                    巡LB.Text = "下巡";
                    break;
                }
                F_Show(true);
                DataGV.DataSource = D_table;
                DataGV.DataBind();
            }
            else
            {
                Session["Excel"] = null;
            }

            if (D_errortable.Rows.Count > 0)
            {
                Session["ExcelError"] = D_errortable;
            }
            else
            {
                Session["ExcelError"] = null;
                ErrorGV.DataSource    = null;
                ErrorGV.DataBind();
            }
        }