Exemple #1
0
 protected void verifysubmit_OnServerClick(object sender, EventArgs e)
 {
     try
     {
         //if (string.IsNullOrWhiteSpace(TextBoxNameCustAcctName.Value)) throw new Exception("Account Name field is required");
         CustomerAccounts customerAccounts =
             Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>()
             .SearchbyAccountNumber(TextBoxNameCustAcctNo.Value);
         if (customerAccounts.AccountNumber == TextBoxNameCustAcctNo.Value)
         {
             TextBoxNameCustAcctName.Value = customerAccounts.AccountName;
         }
         else if (customerAccounts.AccountNumber != TextBoxNameCustAcctNo.Value)
         {
             Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Invalid Account Number" +
                                                         "', function(){});</script>", false);
         }
     }
     catch (Exception ex)
     {
         string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
         if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
         {
             Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
         }
     }
 }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dxValidationProvider1.Validate())
            {
                sc = new Server2Client();
                CustomerAccount c = new CustomerAccount();

                string Remarks = txtRMKS.Text == "" ? "Credit Payment" : txtRMKS.Text;
                c.CustomerID  = Convert.ToInt32(lueCNM.EditValue);
                c.TransDate   = txtPDT.DateTime;
                c.Description = Remarks;
                c.Debit       = 0;
                c.Credit      = Convert.ToDouble(txtAMNT.Text);
                c.Balance     = Convert.ToDouble(txtNBAL.Text);

                ca = new CustomerAccounts();
                sc = ca.addTrans(c);

                if (sc.Message == null)
                {
                    XtraMessageBox.Show("Payment done successfully!");
                    lueCNM.EditValue = null;
                    txtCBAL.Text     = "0";
                    txtAMNT.Text     = "0";
                    txtNBAL.Text     = "0";
                    txtRMKS.Text     = "";
                }
                else
                {
                    XtraMessageBox.Show(sc.Message);
                }
            }
        }
        public void outgoingTransactionsTest()
        {
            ICustomerFactory cust     = new CustomerFactory(1, "Kudela", "Gabriel");
            IAccountFactory  account  = new AccountFactory(AccountTypes.Oszczednosciowe, 1, 1);
            CustomerAccounts Accounts = new CustomerAccounts(cust, account);

            Accounts.Accounts[0].deposit(50000m, 1);
            Accounts.Accounts[0].newOutgoingTransaction(500m, 1, 2);

            List <Transaction> transactions = Accounts.OutgoingTransactions();

            Assert.AreEqual(1, transactions.Count);
            Assert.AreEqual(500m, transactions[0].Amount);
            Assert.AreEqual((uint)1, transactions[0].ClientCard);
            Assert.AreEqual((uint)2, transactions[0].ForeignCard);

            Accounts.Accounts[0].newOutgoingTransaction(20001m, 1, 1);

            try
            {
                transactions = Accounts.OutgoingTransactions();
                Assert.Fail("no exception thrown");
            }
            catch (UnauthorizedAccessException e)
            {
                Assert.AreEqual("over 20000 transfer", e.Message);
            }
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerName,CustomerAddress,CustomerPhoneNumber,CustomerEmailAddress,CustomerDriversLicenseNumber,CustomerCreditCardNumber,CustomerAccountNumber,CustomerAccountCreationDate")] CustomerAccounts customerAccounts)
        {
            if (id != customerAccounts.CustomerAccountNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerAccounts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerAccountsExists(customerAccounts.CustomerAccountNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerAccounts));
        }
        public async Task GetCustomerAccountsbyPhoneNumber(string telephone)
        {
            try
            {
                CheckConnectivity();
                ShowReloadCustomerAccounts = false;
                CustomerAccountsErrorMsg   = "";
                CardLoading = true;

                List <CustomerAccount> customerAccounts = await GlobalStaticFields.Customer.GetAccountsbyPhoneNumber(telephone);

                if (customerAccounts?.Count > 0)
                {
                    CustomerAccounts.ReplaceRange(customerAccounts);
                    //await GlobalStaticFields.Customer.GetCards(false);
                }
            }
            catch (WebException e)
            {
                ShowReloadCustomerAccounts = true;
                CustomerAccountsErrorMsg   = "connection timed out";
            }
            catch (Exception ex)
            {
                ShowReloadCustomerAccounts = true;
                CustomerAccountsErrorMsg   = "An error occurred";
            }
            finally
            {
                IsAccountLoaded = true;
                CardLoading     = false;
            }
        }
        public void PutCustomerAccounts(int customeraccountsid, CustomerAccounts customerAccountstoUpdate)
        {
            //customerAccounts.UpdateData(customerAccountstoUpdate);
            ICustomerAccountsDb customerAccountsDb = new CustomerAccountsDb();

            customerAccountsDb.RetrieveById(customeraccountsid);
            customerAccountsDb.UpdateData(customerAccountstoUpdate);
        }
        public CustomerAccounts GetId(int id)
        {
            CustomerAccounts item = customerAccounts.RetrieveById(id);

            if (item == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(item);
        }
Exemple #8
0
        private void bCreditPayment_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmSelectCustomer frm = new frmSelectCustomer();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Server2Client    sc  = new Server2Client();
                CustomerAccounts ca  = new CustomerAccounts();
                Customers        cc  = new Customers();
                Customer         c   = new Customer();
                double           bal = 0;
                c = cc.getCustomer(frm.CustomerID);
                rptCreditPayment rpt = new rptCreditPayment();

                XRSummary tdr = new XRSummary();
                XRSummary tcr = new XRSummary();

                rpt.lbCNM.Text = c.CustomerName;
                rpt.lbADR.Text = c.Address;
                rpt.lbPHN.Text = c.Phone;
                rpt.lbEML.Text = c.Email;

                if (!frm.DateSelected)
                {
                    sc             = ca.getCustomerBalance(frm.CustomerID);
                    bal            = sc.Value;
                    sc             = ca.getTransactionDetails(frm.CustomerID);
                    rpt.DataSource = sc.dataTable;
                }
                else
                {
                    sc             = ca.getCustomerBalance(frm.CustomerID, frm.DateFrom, frm.DateTo);
                    bal            = sc.Value;
                    sc             = ca.AccountStatement(frm.CustomerID, frm.DateFrom, frm.DateTo);
                    rpt.DataSource = sc.dataTable;
                }
                rpt.lbTDT.DataBindings.Add("Text", null, "TransDate", "{0:dd-MM-yyyy}");
                rpt.lbRMK.DataBindings.Add("Text", null, "Description");
                rpt.lbTDR.DataBindings.Add("Text", null, "Debit", "{0:c}");
                rpt.lbTCR.DataBindings.Add("Text", null, "Credit", "{0:c}");
                rpt.lbBAL.DataBindings.Add("Text", null, "Balance", "{0:c}");
                rpt.lblTDR.DataBindings.Add("Text", null, "Debit", "{0:C2}");
                rpt.lblTCR.DataBindings.Add("Text", null, "Credit", "{0:C2}");
                rpt.lblTBL.Text    = bal.ToString("c2");
                tdr.FormatString   = "{0:C2}";
                tcr.FormatString   = "{0:C2}";
                tdr.Running        = SummaryRunning.Report;
                tcr.Running        = SummaryRunning.Report;
                rpt.lblTCR.Summary = tdr;
                rpt.lblTDR.Summary = tcr;

                dv.PrintingSystem = rpt.PrintingSystem;
                rpt.CreateDocument(true);
            }
        }
 public bool CustomerSavingsAccountBalanceConfirmed(CustomerAccounts customerAccounts, SavingsConfig savingsConfig, string accountType, double amount)
 {
     if (accountType == "Withdrawal" && (customerAccounts.Balance < amount + savingsConfig.minimumBalance))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #10
0
        public async Task <IActionResult> Create([Bind("CustomerName,CustomerAddress,CustomerPhoneNumber,CustomerEmailAddress,CustomerDriversLicenseNumber,CustomerCreditCardNumber,CustomerAccountNumber,CustomerAccountCreationDate")] CustomerAccounts customerAccounts)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerAccounts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerAccounts));
        }
 public bool CustomerCurrentAccountBalanceConfirmed(CustomerAccounts customerAccounts, CurrentConfig currentConfig, string accountType, double amount)
 {
     if (accountType == "Withdrawal" && (customerAccounts.Balance < amount + currentConfig.minimumBalance + customerAccounts.CoTCharge))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #12
0
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            //if(string.IsNullOrWhiteSpace(DropDownAccountType.SelectedValue)) throw new Exception("Select An Account type");

            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameAcctNames.Value))
                {
                    throw new Exception("Account Name field is required");
                }
                if (!string.IsNullOrWhiteSpace(TextBoxId.Value))
                {
                    CustomerAccounts customerAccounts = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>().RetrieveById(int.Parse(TextBoxId.Value));
                    customerAccounts.AccountName = TextBoxNameAcctNames.Value;

                    customerAccounts.Branch = new Branch();
                    string customerBranchId = DropDownBranchNames.SelectedValue;
                    customerAccounts.Branch.Id         = int.Parse(customerBranchId);
                    customerAccounts.Branch.BranchName = Convert.ToString(customerAccounts.Branch.Id);

                    customerAccounts.AccountType =
                        (AccountType)Enum.Parse(typeof(AccountType), DropDownAccountTypes.SelectedValue);



                    customerAccounts.DateUpdated = DateTime.Now;
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>().UpdateData(customerAccounts);
                }

                TextBoxNameAcctNames.Value = String.Empty;


                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Customer Account Saved Successfully" + "', function(){location = '/ManageCustomerAcct/ViewAllCustomerAcct.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                if (DropDownBranchNames.SelectedValue == "0")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Branch Not Selected. Please Select a Branch " + "', function(){});</script>", false);
                }
                //if (DropDownAccountTypes.SelectedValue == "0")
                //{
                //    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Account Type Not Selected. Please Select a Account Type " + "', function(){});</script>", false);
                //}
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
Exemple #13
0
        public double GetCustomerAccountWithdrawal(int customerAccountsid, double amount)
        {
            ICustomerAccountsDb customerAccountsDb = new CustomerAccountsDb();
            CustomerAccounts    customerAccounts   = customerAccountsDb.RetrieveById(customerAccountsid);

            if (customerAccounts.Balance >= amount)
            {
                customerAccounts.Balance = customerAccounts.Balance - amount;
            }
            return(customerAccounts.Balance);
        }
        public void addAccountTest()
        {
            ICustomerFactory cust = new CustomerFactory(1, "Kudela", "Gabriel");
            var account           = new AccountFactory(AccountTypes.Oszczednosciowe, 1, 1);

            account.CreateAccount();
            CustomerAccounts Accounts = new CustomerAccounts(cust, account);
            int before = Accounts.Accounts.Count;

            Accounts.addAccount(AccountTypes.Kredytowe);
            Assert.AreEqual(before + 1, Accounts.Accounts.Count);
        }
Exemple #15
0
        public void UpdateCustomerAccounts(string REQUESTURI, CustomerAccounts customerAccounts)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(LocalhostAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = client.PutAsJsonAsync(
                    REQUESTURI,
                    customerAccounts).Result;
            }
        }
Exemple #16
0
        public bool GetCustomerCurrentAccountBalanceConfirmed(int customerAccountsid, double amount)
        {
            ICurrentConfigDb      currentConfigDb    = new CurrentConfigDb();
            IList <CurrentConfig> currentConfig      = currentConfigDb.RetrieveAll();
            ICustomerAccountsDb   customerAccountsDb = new CustomerAccountsDb();
            CustomerAccounts      customerAccounts   = customerAccountsDb.RetrieveById(customerAccountsid);

            if ((customerAccounts.Balance < amount + currentConfig[0].minimumBalance + customerAccounts.CoTCharge))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #17
0
        public bool GetCustomerSavingsAccountBalanceConfirmed(int customerAccountsid, double amount)
        {
            ISavingsConfigDb      savingsConfigDb    = new SavingsConfigDb();
            IList <SavingsConfig> savingsConfig      = savingsConfigDb.RetrieveAll();
            ICustomerAccountsDb   customerAccountsDb = new CustomerAccountsDb();
            CustomerAccounts      customerAccounts   = customerAccountsDb.RetrieveById(customerAccountsid);

            if ((customerAccounts.Balance < amount + savingsConfig[0].minimumBalance))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #18
0
        private void lueCNM_EditValueChanged(object sender, EventArgs e)
        {
            if (lueCNM.EditValue != null)
            {
                int              CID = Convert.ToInt32(lueCNM.EditValue);
                Server2Client    sc  = new Server2Client();
                CustomerAccounts ca  = new CustomerAccounts();


                sc = ca.getCustomerBalance(CID);
                CustomerBalance = sc.Value;

                Customers cust = new Customers();
                cc = cust.getCustomer(CID);
            }
        }
        public double CustomerAccountTransaction(CustomerAccounts customerAccounts, string accountType, double amount)
        {
            if (accountType == "Deposit")
            {
                customerAccounts.Balance = customerAccounts.Balance + amount;
            }

            else if (accountType == "Withdrawal" && customerAccounts.Balance >= amount)
            {
                customerAccounts.Balance = customerAccounts.Balance - amount;
            }
            //else if (accountType == "Withdrawal" && customerAccounts.Balance < amount)
            //{
            //    throw new Exception("Account Balance is insufficient");
            //}
            return(customerAccounts.Balance);
        }
Exemple #20
0
 public void DeleteBankAccount(int accountNumber)
 {
     if (!CustomerAccounts.ContainsKey(accountNumber))
     {
         Console.WriteLine("Kunden har inget konto med angivet kontonummer.");
         return;
     }
     if (GetBalanceFromAccount(accountNumber) == 0m)
     {
         Console.WriteLine($"Kontot med kontonummer #{accountNumber} är borttaget från kund {CustomerId}.");
         CustomerAccounts.Remove(accountNumber);
     }
     else
     {
         Console.WriteLine("För att ta bort ett konto måste saldot vara 0.");
     }
 }
        //To open closed customer account
        public ActionResult openAcct(int id)
        {
            var info = _content.closedAcct.SingleOrDefault(m => m.id == id); //To load closed customer account from the database.

            if (info == null)                                                //Vreify the account is actually closed
            {
                return(HttpNotFound());
            }
            else
            {
                if (info.customerAccountType == "Phoenix Loan Account")                                                                                                                                    //To check if its a loan account
                {
                    var checkForLoan = _content.customAccts.SingleOrDefault(m => m.CustomerID == info.CustomerID && m.accountName == info.accountName && m.customerAccountType == "Phoenix Loan Account"); //To check if its a loan account
                    if (checkForLoan != null)                                                                                                                                                              //To verify the custimer doesn't have another loan account before opening up the closed loan account
                    {
                        TempData["Error"] = "Customer Already has an open loan account, pls delete one";                                                                                                   //To display an error message to the user
                        return(RedirectToAction("viewClosed", "Customers"));
                    }
                }
                //To open up customer closed account
                CustomerAccounts info1 = new CustomerAccounts();
                info1.customerAccountNumber = info.customerAccountNumber;
                info1.customerAccountType   = info.customerAccountType;
                info1.accountName           = info.accountName;
                info1.accountBalance        = info.accountBalance;
                info1.balanceStatus         = info.balanceStatus;
                info1.branchCreated         = info.branchCreated;
                info1.dateCreated           = info.dateCreated;
                info1.interestRate          = info.interestRate;
                info1.lien             = info.lien;
                info1.cot              = info.cot;
                info1.CustomerID       = info.CustomerID;
                info1.linkAcctType     = info.linkAcctType;
                info1.linkedAcctNumber = info.linkedAcctNumber;
                info1.months           = info.months;
                info1.loanStatus       = info.loanStatus;


                _content.customAccts.Add(info1);
                _content.closedAcct.Remove(info);
            }
            _content.SaveChanges();                              //To save channges to the database.

            TempData["Success"] = "Account Opened Successfully"; //To display success message to the user
            return(RedirectToAction("viewClosed", "Customers"));
        }
Exemple #22
0
        private void lueCNM_EditValueChanged(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(lueCNM.EditValue);

            sc = new Server2Client();
            ca = new CustomerAccounts();
            sc = ca.getCustomerBalance(id);

            if (sc.Message != null)
            {
                txtCBAL.Text    = sc.Message;
                txtCBAL.Enabled = false;
            }
            else
            {
                txtCBAL.Text = sc.Value.ToString();
            }
        }
        public async Task GetCustomerAccountsbyPhoneNumber(string telephone)
        {
            try
            {
                CheckConnectivity();
                //CardLoading = true;

                List <CustomerAccount> customerAccounts = await GlobalStaticFields.Customer.GetAccountsbyPhoneNumber(telephone);

                if (customerAccounts?.Count > 0)
                {
                    if (GlobalStaticFields.Customer.Email.ToLower().Contains("olayinkayusufm"))
                    {
                        customerAccounts.Add(new CustomerAccount
                        {
                            nuban        = "0064828616",
                            CustomerId   = "124358",
                            currency     = "405",
                            currencyCode = "USD",
                            balance      = "1500",
                            accountType  = "domiciliary",
                        });
                    }
                    List <CustomerAccount> acc = new List <CustomerAccount>();
                    foreach (var item in customerAccounts?.Where(c => c.currency != "566"))
                    {
                        CustomerAccounts.Add(item.AccountBalanceAccountType);
                    }
                    //await GlobalStaticFields.Customer.GetCards(false);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsAccountLoaded = true;
                // CardLoading = false;
            }
        }
Exemple #24
0
        public frmCreditPayment(int CustomerID)
        {
            InitializeComponent();

            txtPDT.DateTime = DateTime.Now.Date;
            sc  = new Server2Client();
            cus = new Customers();
            ca  = new CustomerAccounts();
            sc  = cus.getCustomers();

            lueCNM.Properties.DataSource    = sc.dataTable;
            lueCNM.Properties.DisplayMember = "CustomerName";
            lueCNM.Properties.ValueMember   = "ID";

            lueCNM.EditValue = CustomerID;
            sc = ca.getCustomerBalance(CustomerID);

            txtCBAL.Text = sc.Value.ToString();

            txtAMNT.Text = "0";
            txtNBAL.Text = "0";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var branch =
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IBranchDb>().RetrieveAll();
                DropDownBranchName.DataSource = branch;
                DropDownBranchName.DataBind();

                DropDownAccountType.DataSource = Enum.GetNames(typeof(AccountType));
                DropDownAccountType.DataBind();
                if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    CustomerAccounts customerAccounts = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>().RetrieveById(id);
                    var customer =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerDb>().RetrieveById(id);

                    TextBoxNameAcctName.Value = customer.LastName + " " + customer.FirstName + " " + customer.OtherNames;
                    TextBoxId.Value           = customer.Id.ToString();
                }
            }
        }
Exemple #26
0
        public CustomerAccounts GetCustomerAccountsByCategory(string Accountnumber)
        {
            CustomerAccounts customerAccounts = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(LocalhostAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                // HTTP GET
                HttpResponseMessage response = client.GetAsync("api/Customeraccounts/GetByAccountNumber/?accountnumber=" + Accountnumber).Result;
                if (response.IsSuccessStatusCode)
                {
                    customerAccounts = response.Content.ReadAsAsync <CustomerAccounts>().Result;
                    return(customerAccounts);
                }
                else
                {
                    string message = response.ReasonPhrase;
                }
            }
            return(customerAccounts);
        }
Exemple #27
0
        private void btnSell_Click(object sender, EventArgs e)
        {
            if (grv.RowCount <= 0)
            {
                XtraMessageBox.Show("Please add some product to sell");
                return;
            }

            Sale s = new Sale();

            s.InvoiceNo  = txtINV.Text;
            s.SaleDate   = dtpSDT.DateTime;
            s.CustomerID = Convert.ToInt32(lueCNM.EditValue);
            s.Amount     = Convert.ToDouble(txtAMT.EditValue);
            s.Discount   = Convert.ToDouble(txtDSC.EditValue);
            s.Payment    = Convert.ToDouble(txtPAM.EditValue);
            s.Balance    = Convert.ToDouble(txtBAL.EditValue);

            Server2Client sc  = new Server2Client();
            Sales         sls = new Sales();

            sc = sls.AddSale(s);
            if (sc.Message != null)
            {
                XtraMessageBox.Show(sc.Message);
                return;
            }

            CustomerAccounts cas = new CustomerAccounts();
            CustomerAccount  ca  = new CustomerAccount();
            Customer         c   = new Customer();

            cas            = new CustomerAccounts();
            ca.CustomerID  = Convert.ToInt32(lueCNM.EditValue);
            ca.TransDate   = s.SaleDate;
            ca.Description = s.InvoiceNo;
            if (s.Balance == 0)
            {
                ca.Debit  = s.Payment;
                ca.Credit = s.Payment;
            }
            else
            {
                ca.Debit  = s.Amount - s.Discount;
                ca.Credit = s.Payment;
            }
            ca.Balance = CustomerBalance + s.Balance;
            sc         = cas.addTrans(ca);


            if (sc.Message != null)
            {
                XtraMessageBox.Show(sc.Message);
                return;
            }

            for (int i = 0; i <= grv.RowCount - 1; i++)
            {
                Products   prd = new Products();
                SaleDetail sd  = new SaleDetail();
                sd.InvoiceNo    = txtINV.Text;
                sd.ProductID    = Convert.ToInt32(grv.GetRowCellValue(i, colPID));
                sd.Quantity     = Convert.ToInt32(grv.GetRowCellValue(i, colQTY));
                sd.BuyingValue  = Convert.ToDouble(grv.GetRowCellValue(i, colBVL));
                sd.SellingValue = Convert.ToDouble(grv.GetRowCellValue(i, colSVL));
                sd.Amount       = sd.Quantity * sd.SellingValue;

                sc = new Server2Client();
                sc = sls.AddSaleDetails(sd);
                sc = prd.updateQuantity(sd.ProductID, sd.Quantity, "-");
            }

            if (XtraMessageBox.Show("Do you want to print receipt?", "Print Receipt", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                rptCashMemo rpt = new rptCashMemo()
                {
                    DataSource = dt
                };
                rpt.lblCNM.Text = cc.CustomerName;
                rpt.lblADR.Text = cc.Address;
                rpt.lblPHN.Text = cc.Phone;

                rpt.lblINV.Text = txtINV.Text;
                rpt.lblSDT.Text = dtpSDT.DateTime.ToShortDateString();

                rpt.lblPNM.DataBindings.Add("Text", null, "ProductName");
                rpt.lbSNO.DataBindings.Add("Text", null, "BarCode");
                rpt.lblQTY.DataBindings.Add("Text", null, "Quantity");
                rpt.lblPRC.DataBindings.Add("Text", null, "SellingValue", "{0:c}");
                rpt.lblAMT.DataBindings.Add("Text", null, "Amount", "{0:c}");
                rpt.lblDSC.Text = "(-) " + s.Discount.ToString("c2");
                rpt.lblTTL.Text = s.Payment.ToString("c2");
                rpt.lblAMW.Text = "Rupees " + Utils.NumbersToWords(Convert.ToInt32(s.Payment)) + " only";

                rpt.ShowPreviewDialog();
            }
            grd.DataSource = null;
            InitInvoiceNo();
            lueCAT.EditValue             = null;
            luePNM.EditValue             = null;
            lueCAT.Properties.DataSource = null;
            luePNM.Properties.DataSource = null;
            InitCategories();
            InitProducts();
            Reset();
        }
 public double CreditCustomerAccounts(CustomerAccounts customerAccounts, double amount)
 {
     customerAccounts.Balance = customerAccounts.Balance + amount;
     return(customerAccounts.Balance);
 }
        public async Task GetCustomerAccountsbyPhoneNumber(string telephone)
        {
            try
            {
                CheckConnectivity();
                //CardLoading = true;

                List <CustomerAccount> customerAccounts = await GlobalStaticFields.Customer.GetAccountsbyPhoneNumber(telephone);

                List <ProfileListAccount> profileListAccounts = new List <ProfileListAccount>();

                if (customerAccounts?.Count > 0)
                {
                    CustomerAccounts.ReplaceRange(customerAccounts);

                    if (CustomerAccounts?.Count > 0)
                    {
                        foreach (var item in CustomerAccounts)
                        {
                            var profileAcc = new ProfileListAccount
                            {
                                nuban               = item.nuban,
                                AccountType         = item.accountType,
                                BalanceWithCurrency = $"{Utilities.GetCurrency(item.currencyCode)}{item.balance}"
                            };

                            profileListAccounts.Add(profileAcc);
                        }

                        profileListAccount.ReplaceRange(profileListAccounts);
                    }
                    //await GlobalStaticFields.Customer.GetCards(false);
                }

                //var apirequest = new ApiRequest();

                //dynamic accts = new JObject();
                //accts.phone = telephone;
                //var request = await apirequest.Post<dynamic>(accts, "", URLConstants.SwitchApiLiveBaseUrl, "Switch/GetAllOtherAcctDetailsByNumber", "BankAccountsViewModel");

                //if (request.IsSuccessStatusCode)
                //{
                //    var response = await request.Content.ReadAsStringAsync();
                //    List<CustomerAccount> content = JsonConvert.DeserializeObject<List<CustomerAccount>>(response);
                //    if (content?.Count > 0)
                //        CustomerAccounts.ReplaceRange(content);

                //}
                //else
                //{
                //    var response = await request.Content.ReadAsStringAsync();
                //}
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsAccountLoaded = true;
                // CardLoading = false;
            }
        }
 public double DebitCustomerAccounts(CustomerAccounts customerAccounts, double amount)
 {
     customerAccounts.Balance = customerAccounts.Balance - amount;
     return(customerAccounts.Balance);
 }