Beispiel #1
0
        public IActionResult ApproveConfirm(Int64?id)
        {
            SettlementRuleViewModel viewModel = new SettlementRuleViewModel();

            using (var transaction = _unitOfWork.MTDBContext.Database.BeginTransaction())
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        SettlementRule _SettlementRule = _unitOfWork.SettlementRuleRepo.GetById(id);
                        if (_SettlementRule != null)
                        {
                            _SettlementRule.IsApprove   = true; //_SettlementRule.IsActive ? false : true;
                            _SettlementRule.UpdatedBy   = 1;
                            _SettlementRule.UpdatedDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                            _unitOfWork.SettlementRuleRepo.Edit(_SettlementRule);
                            _unitOfWork.Save();
                            transaction.Commit();
                            viewModel.MessageText = Notification.Show("Record updated successfully", "Success", type: ToastType.Success);
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        viewModel.MessageText = Notification.Show("Record failed to update", "Failed", type: ToastType.Error);
                    }
                }
            }
            return(View("RuleListApprove", viewModel));
        }
Beispiel #2
0
        public IActionResult DeleteConfirm(Int64?Id)
        {
            SettlementRuleViewModel viewModel = new SettlementRuleViewModel();

            using (var transaction = _unitOfWork.MTDBContext.Database.BeginTransaction())
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        SettlementRule _SettlementRule = _unitOfWork.SettlementRuleRepo.GetById(Id);
                        if (_SettlementRule != null)
                        {
                            _SettlementRule.IsDeleted   = true;
                            _SettlementRule.UpdatedBy   = 1;
                            _SettlementRule.UpdatedDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                            _unitOfWork.SettlementRuleRepo.Edit(_SettlementRule);
                            _unitOfWork.Save();
                            transaction.Commit();
                            viewModel.MessageText = Notification.Show(CustomMessage.DeleteMessage("Settlement Rule"), "Success", type: ToastType.Success);
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        viewModel.MessageText = Notification.Show(CustomMessage.UpdateErrorMessage("Settlement Rule"), "Failed", type: ToastType.Error);
                    }
                }
            }
            return(View("RuleList", viewModel));
        }
Beispiel #3
0
        public IActionResult Approve(Int64 Id)
        {
            SettlementRuleViewModel viewModel       = new SettlementRuleViewModel();
            SettlementRule          _SettlementRule = _unitOfWork.SettlementRuleRepo.GetById(Id);

            if (_SettlementRule != null)
            {
                viewModel = ModelAdapter.ModelMap(viewModel, _SettlementRule);
            }
            return(View(viewModel));
        }
        public static SettlementRule GetSettlementRule(HttpSessionStateBase session)
        {
            SettlementRule myMsc = Get <SettlementRule>(session, SessionKey.SetRule);

            if (myMsc == null)
            {
                myMsc = new SettlementRule();
                Set(session, SessionKey.SetRule, myMsc);
            }
            return(myMsc);
        }
Beispiel #5
0
        public IActionResult SettlementRuleCreate(SettlementRule rule)
        {
            SettlementRuleViewModel viewModel = new SettlementRuleViewModel();

            using (var transaction = _unitOfWork.MTDBContext.Database.BeginTransaction())
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        if (rule.Frequency <= 0)
                        {
                            viewModel.MessageText = Notification.Show("Frequency must be grater than 0", "Info", type: ToastType.Info);
                            viewModel             = InitializeData(viewModel);
                            return(View(viewModel));
                        }
                        int ruleCount = 0;
                        ruleCount             = _unitOfWork.SettlementRuleRepo.GetRuleCount();
                        ruleCount             = ruleCount == 0 ? 1 : ruleCount + 1;
                        rule.SettlementRuleId = "SET-" + ruleCount.ToString().PadLeft(5, '0');
                        rule.Commission       = rule.CommissionEnable ? rule.Commission : null;
                        rule.VATPercentage    = rule.VATEnable ? rule.VATPercentage : null;
                        rule.IsActive         = false;
                        rule.IsApprove        = false;
                        rule.IsDeleted        = false;
                        rule.EntryBy          = 1;
                        rule.EntryDate        = Convert.ToDateTime(DateTime.Now);
                        rule.UpdatedBy        = 1;
                        rule.UpdatedDate      = Convert.ToDateTime(DateTime.Now);
                        _unitOfWork.SettlementRuleRepo.Add(rule);
                        _unitOfWork.Save();
                        transaction.Commit();
                        viewModel.MessageText = Notification.Show(CustomMessage.SaveMessage("Settlement Rule"), "Success", type: ToastType.Success);
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        viewModel.MessageText = Notification.Show(CustomMessage.SaveErrorMessage("Settlement Rule"), "Error", type: ToastType.Error);
                    }
                }
                if (!ModelState.IsValid)
                {
                    viewModel.MessageText = Notification.Show("Form data is not valid", "Error", type: ToastType.Error);
                }

                viewModel = InitializeData(viewModel);
                return(View(viewModel));
            }
        }
Beispiel #6
0
        public IActionResult GetTerminalVATInfo(SettlementRule rule)
        {
            SettlementRuleViewModel viewModel = new SettlementRuleViewModel();
            MctVATSetup             vat       = _unitOfWork.MctVATSetupRepo.GetTerminalVATInfo(rule.TerminalId);

            if (vat != null)
            {
                viewModel.VATPercentage = vat.Percentage;
            }
            else
            {
                viewModel.VATPercentage = 0;
            }

            return(Json(new { data = viewModel }));
        }
Beispiel #7
0
        public IActionResult GetTerminalCommissionInfo(SettlementRule rule)
        {
            SettlementRuleViewModel viewModel  = new SettlementRuleViewModel();
            MctCommissionSetup      commission = _unitOfWork.MctCommissionSetupRepo.GetTerminalCommissionInfo(rule.TerminalId);

            if (commission != null)
            {
                viewModel.Commission = commission.CommissionAmount;
            }
            else
            {
                viewModel.Commission = 0;
            }

            return(Json(new { data = viewModel }));
        }
Beispiel #8
0
        public IActionResult Edit(Int64 Id, SettlementRuleViewModel rule)
        {
            SettlementRuleViewModel viewModel = new SettlementRuleViewModel();

            using (var transaction = _unitOfWork.MTDBContext.Database.BeginTransaction())
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        if (rule.Frequency <= 0)
                        {
                            viewModel.MessageText = Notification.Show("Frequency must be grater than 0", "Info", type: ToastType.Info);
                            viewModel             = InitializeData(viewModel);
                            return(View(viewModel));
                        }
                        SettlementRule oldRule = _unitOfWork.SettlementRuleRepo.GetById(Id);
                        oldRule.MerchantId       = rule.MerchantId;
                        oldRule.TerminalId       = rule.TerminalId;
                        oldRule.Description      = rule.Description;
                        oldRule.SettlementType   = rule.SettlementType;
                        oldRule.Frequency        = rule.Frequency;
                        oldRule.CommissionEnable = rule.CommissionEnable;
                        oldRule.Commission       = rule.CommissionEnable ? rule.Commission : null;
                        oldRule.VATEnable        = rule.VATEnable;
                        oldRule.VATPercentage    = rule.VATEnable ? rule.VATPercentage : null;
                        oldRule.UpdatedBy        = 1;
                        oldRule.UpdatedDate      = Convert.ToDateTime(DateTime.Now);
                        _unitOfWork.SettlementRuleRepo.Edit(oldRule);
                        _unitOfWork.Save();
                        transaction.Commit();
                        viewModel.MessageText = Notification.Show(CustomMessage.UpdateMessage("Settlement Rule"), "Success", type: ToastType.Success);
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        viewModel.MessageText = Notification.Show(CustomMessage.UpdateErrorMessage("Settlement Rule"), "Failed", type: ToastType.Error);
                    }
                }
            }
            viewModel = InitializeData(viewModel);
            return(View(viewModel));
        }
Beispiel #9
0
        public IActionResult Edit(Int64?id)
        {
            SettlementRuleViewModel viewModel = new SettlementRuleViewModel();

            if (id != null)
            {
                SettlementRule _rule = _unitOfWork.SettlementRuleRepo.GetById(id);
                if (_rule != null)
                {
                    viewModel = ModelAdapter.ModelMap(viewModel, _rule);
                }
                else
                {
                    viewModel.MessageText = Notification.Show("Rule not found", "Error", type: ToastType.Error);
                    return(RedirectToAction(nameof(RuleList)));
                }
            }
            viewModel = InitializeData(viewModel);
            return(View(viewModel));
        }
Beispiel #10
0
        public IActionResult GetDataApproved(SettlementRule rule)
        {
            var draw                = HttpContext.Request.Form["draw"].FirstOrDefault();
            var start               = Request.Form["start"].FirstOrDefault();
            var length              = Request.Form["length"].FirstOrDefault();
            var sortColumn          = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault();
            var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault() == "asc" ? "ascending" : "descending";
            var searchValue         = Request.Form["search[value]"].FirstOrDefault();

            int pageSize = length != null?Convert.ToInt32(length) : 0;

            int skip = start != null?Convert.ToInt32(start) : 0;

            int recordsTotal = 0;

            recordsTotal = (from t in _unitOfWork.SettlementRuleRepo.GetAll()
                            select t).Where(w => w.IsApprove == false).Count();

            var data = (from t in _unitOfWork.SettlementRuleRepo.GetSettlementRuleData()
                        select t).Where(w => w.IsApprove == false).Skip(skip).Take(pageSize);

            ////Sorting   .Skip(skip).Take(pageSize)
            if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDirection)))
            {
                data = data.AsQueryable().OrderBy(sortColumn + " " + sortColumnDirection);
            }
            //Search
            if (!string.IsNullOrEmpty(searchValue))
            {
                data = data.Where(t => (t.MerchantName != null && t.MerchantName.ToLower().Contains(searchValue.ToLower())) ||
                                  (t.TerminalName != null && t.TerminalName.ToLower().Contains(searchValue.ToLower())) ||
                                  (t.SettlementRuleId != null && t.SettlementRuleId.ToLower().Contains(searchValue.ToLower())) ||
                                  (t.SettlementType != null && t.SettlementType.ToLower().Contains(searchValue.ToLower())) ||
                                  (t.Frequency.Equals(searchValue.ToLower())) ||
                                  (t.Commission != null && t.Commission.Equals(searchValue.ToLower())) ||
                                  (t.VATPercentage != null && t.VATPercentage.Equals(searchValue.ToLower()))
                                  );
            }
            //var data = merchantData.Skip(skip).Take(pageSize);
            return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }));
        }
Beispiel #11
0
 public IActionResult RuleListApprove(SettlementRule rule)
 {
     return(View());
 }
 public void Edit(SettlementRule SettlementRule)
 {
     this._dBContext.Attach(SettlementRule);
     this._dBContext.Entry(SettlementRule).State = EntityState.Modified;
 }
 public void Add(SettlementRule SettlementRule)
 {
     this._dBContext.Add(SettlementRule);
 }
Beispiel #14
0
        /// <summary>
        /// 新增发票
        /// </summary>
        /// <param name="data"></param>
        /// <param name="listDetail"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long InsertCustomerTransportChargesSettlement(CustomerTransportChargesSettlement data, List <CustomerTransportChargesSettlementDetail> listDetail, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            SettlementRule rule = new SettlementRule();

            return(rule.InsertCustomerTransportChargesSettlement(data, listDetail, nOpStaffId, strOpStaffName, out strErrText));
        }
Beispiel #15
0
        /// <summary>
        /// 删除承运单位结算记录数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool DeleteCarrierTransportChargesSettlement(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            SettlementRule rule = new SettlementRule();

            return(rule.DeleteCarrierTransportChargesSettlement(nId, nOpStaffId, strOpStaffName, out strErrText));
        }