Beispiel #1
0
        public ValidationMsg Save(SysBranch model, int userid)
        {
            var vmMsg = new ValidationMsg();

            try
            {
                Sys_Branch tblSysBranch = SetToModelObject(model, userid);
                _context.Sys_Branch.Add(tblSysBranch);
                _context.SaveChanges();
                BranchID   = tblSysBranch.BranchID;
                vmMsg.Type = Enums.MessageType.Success;
                vmMsg.Msg  = "Saved Successfully.";
            }
            catch (Exception ex)
            {
                if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                {
                    vmMsg.Type = Enums.MessageType.Error;
                    vmMsg.Msg  = "Banch Code Already Exit..";
                }
                else
                {
                    vmMsg.Type = Enums.MessageType.Error;
                    vmMsg.Msg  = "Failed to Save.";
                }
            }
            return(vmMsg);
        }
Beispiel #2
0
        public Sys_Branch BranchModelConversion(SysBranch model, int bankId)
        {
            var entity = new Sys_Branch();

            entity.BranchID        = model.BranchID;
            entity.BankID          = bankId;
            entity.BankID          = model.BankID;// bankId;
            entity.BanchCode       = model.BanchCode;
            entity.BranchName      = model.BranchName;
            entity.Address1        = model.Address1;
            entity.Address2        = model.Address2;
            entity.Address3        = model.Address3;
            entity.LCLimit         = model.LCLimit;
            entity.LCOpened        = model.LCOpened;
            entity.LCBalance       = model.LCBalance;
            entity.LCMargin        = model.LCMargin;
            entity.LCMarginUsed    = model.LCMarginUsed;
            entity.LCMarginBalance = model.LCMarginBalance;
            entity.BranchSwiftCode = model.BranchSwiftCode;
            entity.LIMLimit        = model.LIMLimit;
            entity.LIMTaken        = model.LIMTaken;
            entity.LIMBalance      = model.LIMBalance;
            entity.IsActive        = model.IsActive == "Active";
            return(entity);
        }
Beispiel #3
0
        public ValidationMsg Delete(string bankID)
        {
            try
            {
                using (var tx = new TransactionScope())
                {
                    Sys_Bank delete = repository.BankRepository.GetByID(Convert.ToInt32(bankID));
                    if (delete != null)
                    {
                        var deleteBranch = repository.BranchRepository.Get().Where(ob => ob.BankID == delete.BankID).ToList();
                        foreach (var item in deleteBranch)
                        {
                            Sys_Branch deleteBranchItem = repository.BranchRepository.GetByID(Convert.ToInt32(item.BranchID));


                            repository.BranchRepository.Delete(deleteBranchItem);
                            save = repository.Save();
                        }
                        repository.BankRepository.Delete(delete);
                        save = repository.Save();
                    }

                    tx.Complete();

                    vmMsg.Type = Enums.MessageType.Delete;
                    vmMsg.Msg  = "Deleted Sucessfully";
                }
            }
            catch
            {
                vmMsg.Type = Enums.MessageType.Error;
                vmMsg.Msg  = "Failed to delete.";
            }
            return(vmMsg);
        }
Beispiel #4
0
        public Sys_Branch SetToModelObject(SysBranch model, int userid)
        {
            Sys_Branch entity = new Sys_Branch();

            entity.BranchID        = model.BranchID;
            entity.BanchCode       = model.BanchCode;
            entity.BranchName      = model.BranchName;
            entity.BankID          = model.BankID;
            entity.LCLimit         = model.LCLimit;
            entity.LCOpened        = model.LCOpened;
            entity.LCBalance       = model.LCBalance;
            entity.LCMargin        = model.LCMargin;
            entity.LCMarginUsed    = model.LCMarginUsed;
            entity.LCMarginBalance = model.LCMarginBalance;
            entity.BranchSwiftCode = model.BranchSwiftCode;
            entity.LIMLimit        = model.LIMLimit;
            entity.LIMTaken        = model.LIMTaken;
            entity.LIMBalance      = model.LIMBalance;
            entity.Address1        = model.Address1;
            entity.Address2        = model.Address2;
            entity.Address3        = model.Address3;
            entity.IsActive        = model.IsActive == "Active";
            entity.SetOn           = DateTime.Now;
            entity.SetBy           = userid;
            entity.IPAddress       = string.Empty;

            return(entity);
        }
Beispiel #5
0
        public ValidationMsg Save(SysBank model, int _userid, string pageUrl)//, string pageUrl
        {
            vmMsg = new ValidationMsg();

            try
            {
                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.BankCode = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);//DalCommon.GetPreDefineValue("1", "00045");
                        if (model.BankCode != null)
                        {
                            Sys_Bank tblBank = SetToBankModelObject(model, _userid);//, _userid
                            _context.Sys_Bank.Add(tblBank);
                            _context.SaveChanges();

                            if (model.Branches.Count > 0)
                            {
                                foreach (var branch in model.Branches)
                                {
                                    branch.BankID = tblBank.BankID;
                                    Sys_Branch tblBranch = SetToBranchModelObject(branch, _userid);
                                    _context.Sys_Branch.Add(tblBranch);
                                    _context.SaveChanges();
                                }
                            }
                            _context.SaveChanges();

                            tx.Complete();
                            //BankID = tblBank.BankID;

                            vmMsg.Type = Enums.MessageType.Success;
                            vmMsg.Msg  = "Saved Successfully.";
                        }
                    }
                }
            }


            catch (DbEntityValidationException e)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var eve in e.EntityValidationErrors)
                {
                    sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                eve.Entry.Entity.GetType().Name,
                                                eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                    ve.PropertyName,
                                                    ve.ErrorMessage));
                    }
                }
                throw new DbEntityValidationException(sb.ToString(), e);
            }
            return(vmMsg);
        }
Beispiel #6
0
        public Sys_Branch SetToBranchModelObject(SysBranch model, int _userid)
        {
            Sys_Branch entity = new Sys_Branch();

            entity.BranchID   = model.BranchID;
            entity.BankID     = model.BankID;
            entity.BanchCode  = model.BanchCode;
            entity.BranchName = model.BranchName;
            entity.Address1   = model.Address1;
            entity.Address2   = model.Address2;
            entity.Address3   = model.Address3;
            entity.LCBalance  = model.LCBalance;
            entity.IsActive   = model.IsActive == "Active";
            return(entity);
        }
Beispiel #7
0
        public ValidationMsg Update(SysBank model, int userid)
        {
            var vmMsg = new ValidationMsg();

            try
            {
                //const string chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";
                //var random = new Random();
                //var result = new string(
                //    Enumerable.Repeat(chars, 8)
                //              .Select(s => s[random.Next(s.Length)])
                //              .ToArray());
                var sysBank = _context.Sys_Bank.FirstOrDefault(s => s.BankID == model.BankID);
                if (sysBank != null)
                {
                    sysBank.BankCode      = model.BankCode;
                    sysBank.BankName      = model.BankName;
                    sysBank.BankSwiftCode = model.BankSwiftCode;
                    sysBank.BankBINNo     = model.BankBINNo;
                    sysBank.BankType      = model.BankType;
                    sysBank.IsActive      = model.IsActive == "Active";
                    sysBank.ModifiedOn    = DateTime.Now;
                    sysBank.ModifiedBy    = userid;
                }

                #region Branches

                if (model.Branches != null)
                {
                    foreach (var branch in model.Branches)
                    {
                        if (branch.BranchID == 0)
                        {
                            branch.BankID = model.BankID;
                            Sys_Branch tblEXPCIPIItemColor = BranchModelConversion(branch, userid);
                            _context.Sys_Branch.Add(tblEXPCIPIItemColor);
                        }
                        else
                        {
                            Sys_Branch CurEntity = BranchModelConversion(branch, userid);
                            var        OrgEntity = _context.Sys_Branch.First(m => m.BranchID == branch.BranchID);

                            //OrgEntity.BranchID = CurEntity.BranchID;
                            //OrgEntity.BankID = CurEntity.BankID;
                            OrgEntity.BanchCode       = CurEntity.BanchCode;
                            OrgEntity.BranchName      = CurEntity.BranchName;
                            OrgEntity.Address1        = CurEntity.Address1;
                            OrgEntity.Address2        = CurEntity.Address2;
                            OrgEntity.Address3        = CurEntity.Address3;
                            OrgEntity.LCLimit         = CurEntity.LCLimit;
                            OrgEntity.LCOpened        = CurEntity.LCOpened;
                            OrgEntity.LCBalance       = CurEntity.LCBalance;
                            OrgEntity.LCMargin        = CurEntity.LCMargin;
                            OrgEntity.LCMarginUsed    = CurEntity.LCMarginUsed;
                            OrgEntity.LCMarginBalance = CurEntity.LCMarginBalance;
                            OrgEntity.BranchSwiftCode = CurEntity.BranchSwiftCode;
                            OrgEntity.LIMLimit        = CurEntity.LIMLimit;
                            OrgEntity.LIMTaken        = CurEntity.LIMTaken;
                            OrgEntity.LIMBalance      = CurEntity.LIMBalance;
                            OrgEntity.IsActive        = CurEntity.IsActive;// == "Active";
                            OrgEntity.ModifiedBy      = userid;
                            OrgEntity.ModifiedOn      = DateTime.Now;
                        }
                    }
                }

                #endregion

                //if (model.Branches != null)
                //{
                //    foreach (var branch in model.Branches)
                //    {
                //        var entity = _context.Sys_Branch.FirstOrDefault(s => s.BranchID == branch.BranchID);
                //        if (entity != null)
                //        {
                //            entity.BranchID = branch.BranchID;
                //            entity.BankID = branch.BankID;
                //            entity.BanchCode = branch.BanchCode;
                //            entity.BranchName = branch.BranchName;
                //            entity.Address1 = branch.Address1;
                //            entity.Address2 = branch.Address2;
                //            entity.Address3 = branch.Address3;
                //            entity.LCLimit = branch.LCLimit;
                //            entity.LCOpened = branch.LCOpened;
                //            entity.LCBalance = branch.LCBalance;
                //            entity.LCMargin = branch.LCMargin;
                //            entity.LCMarginUsed = branch.LCMarginUsed;
                //            entity.LCMarginBalance = branch.LCMarginBalance;
                //            entity.BranchSwiftCode = branch.BranchSwiftCode;
                //            entity.LIMLimit = branch.LIMLimit;
                //            entity.LIMTaken = branch.LIMTaken;
                //            entity.LIMBalance = branch.LIMBalance;
                //            entity.IsActive = branch.IsActive == "Active";
                //        }
                //        _context.SaveChanges();
                //    }
                //}
                _context.SaveChanges();

                vmMsg.ReturnId = sysBank.BankID;
                vmMsg.Type     = Enums.MessageType.Update;
                vmMsg.Msg      = "Updated Successfully.";
            }
            catch (Exception ex)
            {
                if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                {
                    vmMsg.Type = Enums.MessageType.Error;
                    vmMsg.Msg  = "Bank Code Already Exit.";
                }
                else
                {
                    vmMsg.Type = Enums.MessageType.Error;
                    vmMsg.Msg  = "Failed to Update.";
                }
            }
            return(vmMsg);
        }
Beispiel #8
0
        public ValidationMsg Update(SysBank model, int _userid)
        {
            vmMsg = new ValidationMsg();
            try
            {
                #region Update

                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        #region Crust Leather Transfer

                        Sys_Bank bank           = SetToBankModelObject(model, _userid);
                        var      OriginalEntity = _context.Sys_Bank.First(m => m.BankID == model.BankID);


                        OriginalEntity.BankCode     = bank.BankCode;
                        OriginalEntity.BankName     = bank.BankName;
                        OriginalEntity.BankCategory = bank.BankCategory;
                        OriginalEntity.BankType     = bank.BankType;
                        OriginalEntity.IsActive     = bank.IsActive;
                        OriginalEntity.ModifiedOn   = DateTime.Now;
                        OriginalEntity.ModifiedBy   = _userid;
                        _context.SaveChanges();
                        #endregion

                        #region Save NEW Data & Update Existing Crust Leather Transfer Data

                        if (model.Branches != null)
                        {
                            foreach (SysBranch branch in model.Branches)
                            {
                                branch.BankID = model.BankID;


                                if (branch.BranchID == 0)
                                {
                                    branch.BankID = bank.BankID;
                                    Sys_Branch tblBranch = SetToBranchModelObject(branch, _userid);
                                    _context.Sys_Branch.Add(tblBranch);



                                    //INV_CLTransferTo tblQCSelection = SetToCLTransferToModelObject(objCLTransferToItem, userid);
                                    //_context.INV_CLTransferTo.Add(tblQCSelection);
                                }
                                else
                                {
                                    Sys_Branch branchEntity            = SetToBranchModelObject(branch, _userid);
                                    var        OriginalIssueItemEntity = _context.Sys_Branch.First(m => m.BranchID == branch.BranchID);

                                    OriginalIssueItemEntity.BranchID   = branchEntity.BranchID;
                                    OriginalIssueItemEntity.BankID     = branchEntity.BankID;
                                    OriginalIssueItemEntity.BanchCode  = branchEntity.BanchCode;
                                    OriginalIssueItemEntity.BranchName = branchEntity.BranchName;
                                    OriginalIssueItemEntity.Address1   = branchEntity.Address1;
                                    OriginalIssueItemEntity.Address2   = branchEntity.Address2;
                                    OriginalIssueItemEntity.Address3   = branchEntity.Address3;
                                    OriginalIssueItemEntity.LCBalance  = branchEntity.LCBalance;
                                    // OriginalIssueItemEntity.IsActive = branchEntity.IsActive == "Active";
                                    OriginalIssueItemEntity.SetOn = branchEntity.SetOn;
                                    OriginalIssueItemEntity.SetBy = branchEntity.SetBy;


                                    OriginalIssueItemEntity.ModifiedBy = _userid;
                                    OriginalIssueItemEntity.ModifiedOn = DateTime.Now;
                                    OriginalIssueItemEntity.IPAddress  = GetIPAddress.LocalIPAddress();
                                    OriginalIssueItemEntity.SetOn      = DateTime.Now;
                                    OriginalIssueItemEntity.SetBy      = _userid;
                                }
                            }
                        }
                        #endregion

                        _context.SaveChanges();
                        tx.Complete();
                        BankID = model.BankID;
                        //CLTransferNo = model.CLTransferNo;
                        vmMsg.Type = Enums.MessageType.Update;
                        vmMsg.Msg  = "Updated Successfully.";
                    }
                }

                #endregion
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
                vmMsg.Type = Enums.MessageType.Error;
                vmMsg.Msg  = "Failed to Update.";
            }
            return(vmMsg);
        }
Beispiel #9
0
        public ValidationMsg SaveLCM_LimInfo(LCM_LimInfo dataSet, string url, int _userId)
        {
            try
            {
                LCM_LimInfo obLcLimInfo = new LCM_LimInfo();
                Sys_Branch  branch      = new Sys_Branch();

                obLcLimInfo.LCID       = dataSet.LCID;
                obLcLimInfo.LCNo       = dataSet.LCNo;
                obLcLimInfo.LimID      = dataSet.LimID;
                obLcLimInfo.LimNo      = dataSet.LimNo;
                obLcLimInfo.LimDate    = dataSet.LimDate;
                obLcLimInfo.LimLimit   = dataSet.LimLimit == null ? 0 : (decimal)dataSet.LimLimit;
                obLcLimInfo.LimBalance = dataSet.LimBalance == null ? 0 : (decimal)dataSet.LimBalance;



                obLcLimInfo.LimBankID            = dataSet.LimBankID;
                obLcLimInfo.LimBranchID          = dataSet.LimBranchID;
                obLcLimInfo.LoanAmount           = dataSet.LoanAmount == null ? 0 : (decimal)dataSet.LoanAmount;
                obLcLimInfo.InterestPersent      = dataSet.InterestPersent == null ? 0 : (decimal)dataSet.InterestPersent;
                obLcLimInfo.InterestAmount       = dataSet.InterestAmount == null ? 0 : (decimal)dataSet.InterestAmount;
                obLcLimInfo.AmountToBePaid       = dataSet.AmountToBePaid == null ? 0 : (decimal)dataSet.AmountToBePaid;
                obLcLimInfo.AdjustmentTime       = dataSet.AdjustmentTime;
                obLcLimInfo.OtherCharges         = dataSet.OtherCharges == null ? 0 : (decimal)dataSet.OtherCharges;
                obLcLimInfo.AcceptanceCommission = dataSet.AcceptanceCommission == null ? 0 : (decimal)dataSet.AcceptanceCommission;
                obLcLimInfo.HandlingCharge       = dataSet.HandlingCharge == null ? 0 : (decimal)dataSet.HandlingCharge;
                obLcLimInfo.TotalAmountToBePaid  = dataSet.TotalAmountToBePaid == null ? 0 : (decimal)dataSet.TotalAmountToBePaid;
                obLcLimInfo.PaidAmount           = dataSet.PaidAmount == null ? 0 : (decimal)dataSet.PaidAmount;
                obLcLimInfo.LimCurrency          = (byte)dataSet.LimCurrency;

                obLcLimInfo.ExchangeCurrency = (byte)(dataSet.ExchangeCurrency);
                obLcLimInfo.ExchangeRate     = dataSet.ExchangeRate == null ? 0 : (decimal)dataSet.ExchangeRate;   //dataSet.ExchangeRate;
                obLcLimInfo.ExchangeValue    = dataSet.ExchangeValue == null ? 0 : (decimal)dataSet.ExchangeValue; //dataSet.ExchangeValue;
                obLcLimInfo.RecordStatus     = "NCF";

                obLcLimInfo.LCMarginTransfer     = dataSet.LCMarginTransfer == null ? 0 : (decimal)dataSet.LCMarginTransfer;
                obLcLimInfo.LimMarginTrans       = dataSet.LimMarginTrans == null ? 0 : (decimal)dataSet.LimMarginTrans;
                obLcLimInfo.LimMarginTransPercnt = dataSet.LimMarginTransPercnt == null ? 0 : (decimal)dataSet.LimMarginTransPercnt;
                obLcLimInfo.InterestCalcDate     = dataSet.InterestCalcDate;
                obLcLimInfo.CalcInterestAmt      = dataSet.CalcInterestAmt == null ? 0 : (decimal)dataSet.CalcInterestAmt;
                obLcLimInfo.ExciseDuty           = dataSet.ExciseDuty == null ? 0 : (decimal)dataSet.ExciseDuty;
                obLcLimInfo.TransCash            = dataSet.TransCash == null ? 0 : (decimal)dataSet.TransCash;
                obLcLimInfo.CalcAmtToPaid        = dataSet.CalcAmtToPaid == null ? 0 : (decimal)dataSet.CalcAmtToPaid;
                obLcLimInfo.LimAdjustDr          = dataSet.LimAdjustDr == null ? 0 : (decimal)dataSet.LimAdjustDr;
                obLcLimInfo.LimAdjustCr          = dataSet.LimAdjustCr == null ? 0 : (decimal)dataSet.LimAdjustCr;
                obLcLimInfo.TotalCalcAmtToPaid   = dataSet.TotalCalcAmtToPaid == null ? 0 : (decimal)dataSet.TotalCalcAmtToPaid;

                obLcLimInfo.Remarks = dataSet.Remarks;

                obLcLimInfo.SetOn     = DateTime.Now;
                obLcLimInfo.SetBy     = _userId;
                obLcLimInfo.IPAddress = GetIPAddress.LocalIPAddress();
                obEntity.LCM_LimInfo.Add(obLcLimInfo);
                int flag = obEntity.SaveChanges();
                if (flag == 1)
                {
                    //_vmMsg.ReturnId = repository.LimInfoRepository.Get().Last().LimID;
                    //_vmMsg.ReturnCode = dataSet.LimNo; //repository.LimInfoRepository.GetByID(_vmMsg.ReturnId).LimNo;
                    _vmMsg.Type = Enums.MessageType.Success;
                    _vmMsg.Msg  = "Saved Successfully.";
                }
                else
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Saved Faild.";
                }
            }
            catch (DbEntityValidationException e)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var eve in e.EntityValidationErrors)
                {
                    sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                eve.Entry.Entity.GetType().Name,
                                                eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                    ve.PropertyName,
                                                    ve.ErrorMessage));
                    }
                }
                throw new DbEntityValidationException(sb.ToString(), e);
            }
            return(_vmMsg);
        }
Beispiel #10
0
        public ValidationMsg ConfirmLimInformation(int userid, string limID, string branchID)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                using (var tx = new TransactionScope())
                {
                    if (limID != "")
                    {
                        LCM_LimInfo obLimInfo = repository.LimInfoRepository.GetByID(Convert.ToInt32(limID));
                        if (obLimInfo.RecordStatus == "NCF")
                        {
                            obLimInfo.RecordStatus = "CNF";
                            obLimInfo.SetBy        = userid;
                            obLimInfo.SetOn        = DateTime.Now;
                            repository.LimInfoRepository.Update(obLimInfo);

                            Sys_Branch obBranch = repository.BranchRepository.GetByID(Convert.ToInt32(branchID));
                            obBranch.LIMBalance = obLimInfo.LimLimit - obLimInfo.LoanAmount;
                            repository.BranchRepository.Update(obBranch);

                            int flag = repository.Save();
                            if (flag == 1)
                            {
                                _vmMsg.Type = Enums.MessageType.Success;
                                _vmMsg.Msg  = "Confirmed Faild. ";
                            }
                            else
                            {
                                _vmMsg.Type = Enums.MessageType.Error;
                                _vmMsg.Msg  = "Confirmed Successfully.";
                            }
                        }
                        else
                        {
                            _vmMsg.Type = Enums.MessageType.Error;
                            _vmMsg.Msg  = "Data has Already Confirmed.";
                        }
                    }

                    else
                    {
                        _vmMsg.Type = Enums.MessageType.Error;
                        _vmMsg.Msg  = "Data Save First.";
                    }

                    tx.Complete();
                }
            }
            catch (DbEntityValidationException e)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var eve in e.EntityValidationErrors)
                {
                    sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                eve.Entry.Entity.GetType().Name,
                                                eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                    ve.PropertyName,
                                                    ve.ErrorMessage));
                    }
                }
                throw new DbEntityValidationException(sb.ToString(), e);
            }
            return(_vmMsg);
        }