public string AgentBulkPaymentBankDeposit(AgentBulkPaymentBankDeposit model) { try { string status = string.Empty; using (SqlConnection connection = DataAccess.CreateConnection()) { SqlCommand command = DataAccess.CreateCommand(connection); DataAccess.CreateStoredprocedure(command, "InsertBulkPaymentAgentBankDeposit_SP"); DataAccess.AddInParameter(command, "@Amount", SqlDbType.Float, model.Amount); DataAccess.AddInParameter(command, "@Notes", SqlDbType.VarChar, model.Notes); DataAccess.AddInParameter(command, "@LedgerDate", SqlDbType.VarChar, model.LedgerDate); DataAccess.AddInParameter(command, "@UserId", SqlDbType.VarChar, model.UserId); DataAccess.AddInParameter(command, "@AgentId", SqlDbType.Int, model.AgentId); DataAccess.AddInParameter(command, "@BankAccountId", SqlDbType.Int, model.BankAccountId); DataAccess.AddInParameter(command, "@BankDate", SqlDbType.VarChar, model.BankDate); SqlDataReader reader = DataAccess.ExecuteReader(command); if (reader != null) { while (reader.Read()) { status = reader["IndentityVals"] is DBNull ? string.Empty : Convert.ToString(reader["IndentityVals"]); } } reader.Close(); return(status); } } catch (Exception ex) { return(string.Empty); } }
public ActionResult BulkPayment(FormCollection form) { try { string IndetityVals = string.Empty; int AgentId = (string.IsNullOrEmpty(form["AgentId"])) ? 0 : Convert.ToInt32(form["AgentId"]); if (AgentId > 0) { int InvoiceCount = (string.IsNullOrEmpty(form["InvoiceCount"])) ? 0 : Convert.ToInt32(form["InvoiceCount"]); int PaymentMethod = (string.IsNullOrEmpty(form["PaymentMethod"])) ? 0 : Convert.ToInt32(form["PaymentMethod"]); #region Agent Bulk Payment - Payment Method * Cash if (PaymentMethod == 1 && InvoiceCount > 0) { AgentBulkPaymentCashVoucher Obj = new AgentBulkPaymentCashVoucher(); Obj.AgentId = AgentId; Obj.Amount = (string.IsNullOrEmpty(form["Amount"])) ? 0 : Convert.ToDouble(form["Amount"]); Obj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); Obj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); Obj.UserId = User.Identity.GetUserId(); IndetityVals = new AgentDA().AgentBulkPaymentCashVoucher(Obj); string[] SplitVals = IndetityVals.Split(','); if (SplitVals.Length == 2 && Convert.ToInt32(SplitVals[0]) > 0) { for (int i = 1; i <= InvoiceCount; i++) { BulkPaymentAgentCashInvPaymentInvLog lObj = new BulkPaymentAgentCashInvPaymentInvLog(); lObj.AgentId = AgentId; lObj.AgentLedgerId = Convert.ToInt32(SplitVals[1]); lObj.Amount = (string.IsNullOrEmpty(form["PaidAmount" + i])) ? 0 : Convert.ToDouble(form["PaidAmount" + i]); lObj.GeneralLedgerId = Convert.ToInt32(SplitVals[0]); lObj.InvoiceId = (string.IsNullOrEmpty(form["InvoiceId" + i])) ? 0 : Convert.ToInt32(form["InvoiceId" + i]); lObj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); lObj.UserID = User.Identity.GetUserId(); lObj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); lObj.BankAccountLedgerId = 0; if (lObj.Amount > 0) { new AgentDA().BulkPaymentAgentCashVoucherInvoicePaymentInvoiceLog(lObj); } } } } #endregion #region Agent Bulk Payment - Payment Method * Cheque else if (PaymentMethod == 2) { AgentBulkPaymentChequeVoucher Obj = new AgentBulkPaymentChequeVoucher(); Obj.AccountNo = (string.IsNullOrEmpty(form["chkAccountNo"])) ? string.Empty : Convert.ToString(form["chkAccountNo"]); Obj.AgentId = (string.IsNullOrEmpty(form["AgentId"])) ? 0 : Convert.ToInt32(form["AgentId"]); Obj.Amount = (string.IsNullOrEmpty(form["Amount"])) ? 0 : Convert.ToDouble(form["Amount"]); Obj.BankNames = (string.IsNullOrEmpty(form["chkBankId"])) ? 0 : Convert.ToInt32(form["chkBankId"]); Obj.ChequeNo = (string.IsNullOrEmpty(form["chkChequeNo"])) ? string.Empty : Convert.ToString(form["chkChequeNo"]); Obj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); Obj.Remarks = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); Obj.SortCode = (string.IsNullOrEmpty(form["chkSortCode"])) ? string.Empty : Convert.ToString(form["chkSortCode"]); Obj.UserId = User.Identity.GetUserId(); Obj.BulkPayment = true; new AgentDA().AgentBulkPaymentChequeVoucher(Obj); } #endregion #region Agent Bulk Payment - Payment Method * Credit Card else if (PaymentMethod == 3 && InvoiceCount > 0) { AgentBulkPaymentCreditCard Obj = new AgentBulkPaymentCreditCard(); Obj.AgentId = (string.IsNullOrEmpty(form["AgentId"])) ? 0 : Convert.ToInt32(form["AgentId"]); Obj.Amount = (string.IsNullOrEmpty(form["Amount"])) ? 0 : Convert.ToDouble(form["Amount"]); Obj.BankAccountId = (string.IsNullOrEmpty(form["BankAccountIdCC"])) ? 0 : Convert.ToInt32(form["BankAccountIdCC"]); Obj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); Obj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); Obj.UserId = User.Identity.GetUserId(); Obj.CardNo = (string.IsNullOrEmpty(form["CreditCardNo"])) ? string.Empty : Convert.ToString(form["CreditCardNo"]); Obj.CardHolder = (string.IsNullOrEmpty(form["CardHolderName"])) ? string.Empty : Convert.ToString(form["CardHolderName"]); Obj.ExtraAmount = (string.IsNullOrEmpty(form["ExtraAmount"])) ? string.Empty : Convert.ToString(form["ExtraAmount"]); Obj.BankDate = (string.IsNullOrEmpty(form["BankDate"])) ? string.Empty : Convert.ToString(form["BankDate"]); IndetityVals = new AgentDA().AgentBulkPaymentCreditCard(Obj); string[] SplitVals = IndetityVals.Split(','); if (SplitVals.Length == 3 && Convert.ToInt32(SplitVals[0]) > 0) { for (int i = 1; i <= InvoiceCount; i++) { BulkPaymentAgentCashInvPaymentInvLog lObj = new BulkPaymentAgentCashInvPaymentInvLog(); lObj.AgentId = AgentId; lObj.AgentLedgerId = Convert.ToInt32(SplitVals[1]); lObj.Amount = (string.IsNullOrEmpty(form["PaidAmount" + i])) ? 0 : Convert.ToDouble(form["PaidAmount" + i]); lObj.GeneralLedgerId = Convert.ToInt32(SplitVals[0]); lObj.InvoiceId = (string.IsNullOrEmpty(form["InvoiceId" + i])) ? 0 : Convert.ToInt32(form["InvoiceId" + i]); lObj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); lObj.UserID = User.Identity.GetUserId(); lObj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); lObj.BankAccountLedgerId = Convert.ToInt32(SplitVals[2]); if (lObj.Amount > 0) { new AgentDA().BulkPaymentAgentCashVoucherInvoicePaymentInvoiceLog(lObj); } } } } #endregion #region Agent Bulk Payment - Payment Method * Debit Card else if (PaymentMethod == 4 && InvoiceCount > 0) { AgentBulkPaymentDebitCard Obj = new AgentBulkPaymentDebitCard(); Obj.AgentId = (string.IsNullOrEmpty(form["AgentId"])) ? 0 : Convert.ToInt32(form["AgentId"]); Obj.Amount = (string.IsNullOrEmpty(form["Amount"])) ? 0 : Convert.ToDouble(form["Amount"]); Obj.BankAccountId = (string.IsNullOrEmpty(form["BankAccountIdDC"])) ? 0 : Convert.ToInt32(form["BankAccountIdDC"]); Obj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); Obj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); Obj.UserId = User.Identity.GetUserId(); Obj.CardNo = (string.IsNullOrEmpty(form["CreditCardNo"])) ? string.Empty : Convert.ToString(form["CreditCardNo"]); Obj.CardHolder = (string.IsNullOrEmpty(form["CardHolderName"])) ? string.Empty : Convert.ToString(form["CardHolderName"]); Obj.ExtraAmount = (string.IsNullOrEmpty(form["ExtraAmount"])) ? string.Empty : Convert.ToString(form["ExtraAmount"]); Obj.BankDate = (string.IsNullOrEmpty(form["BankDate"])) ? string.Empty : Convert.ToString(form["BankDate"]); IndetityVals = new AgentDA().AgentBulkPaymentDebitCard(Obj); string[] SplitVals = IndetityVals.Split(','); if (SplitVals.Length == 3 && Convert.ToInt32(SplitVals[0]) > 0) { for (int i = 1; i <= InvoiceCount; i++) { BulkPaymentAgentCashInvPaymentInvLog lObj = new BulkPaymentAgentCashInvPaymentInvLog(); lObj.AgentId = AgentId; lObj.AgentLedgerId = Convert.ToInt32(SplitVals[1]); lObj.Amount = (string.IsNullOrEmpty(form["PaidAmount" + i])) ? 0 : Convert.ToDouble(form["PaidAmount" + i]); lObj.GeneralLedgerId = Convert.ToInt32(SplitVals[0]); lObj.InvoiceId = (string.IsNullOrEmpty(form["InvoiceId" + i])) ? 0 : Convert.ToInt32(form["InvoiceId" + i]); lObj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); lObj.UserID = User.Identity.GetUserId(); lObj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); lObj.BankAccountLedgerId = Convert.ToInt32(SplitVals[2]); if (lObj.Amount > 0) { new AgentDA().BulkPaymentAgentCashVoucherInvoicePaymentInvoiceLog(lObj); } } } } #endregion #region Agent Bulk Payment - Payment Method * Bank Deposit else if (PaymentMethod == 5 && InvoiceCount > 0) { AgentBulkPaymentBankDeposit Obj = new AgentBulkPaymentBankDeposit(); Obj.Amount = (string.IsNullOrEmpty(form["Amount"])) ? 0 : Convert.ToDouble(form["Amount"]); Obj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); Obj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); Obj.UserId = User.Identity.GetUserId(); Obj.AgentId = (string.IsNullOrEmpty(form["AgentId"])) ? 0 : Convert.ToInt32(form["AgentId"]); Obj.BankAccountId = (string.IsNullOrEmpty(form["BankAccountIdBP"])) ? 0 : Convert.ToInt32(form["BankAccountIdBP"]); Obj.BankDate = (string.IsNullOrEmpty(form["BankDateBankDeposit"])) ? string.Empty : Convert.ToString(form["BankDateBankDeposit"]); IndetityVals = new AgentDA().AgentBulkPaymentBankDeposit(Obj); string[] SplitVals = IndetityVals.Split(','); if (SplitVals.Length == 3 && Convert.ToInt32(SplitVals[0]) > 0) { for (int i = 1; i <= InvoiceCount; i++) { BulkPaymentAgentCashInvPaymentInvLog lObj = new BulkPaymentAgentCashInvPaymentInvLog(); lObj.AgentId = AgentId; lObj.AgentLedgerId = Convert.ToInt32(SplitVals[1]); lObj.Amount = (string.IsNullOrEmpty(form["PaidAmount" + i])) ? 0 : Convert.ToDouble(form["PaidAmount" + i]); lObj.GeneralLedgerId = Convert.ToInt32(SplitVals[0]); lObj.InvoiceId = (string.IsNullOrEmpty(form["InvoiceId" + i])) ? 0 : Convert.ToInt32(form["InvoiceId" + i]); lObj.Notes = (string.IsNullOrEmpty(form["Notes"])) ? String.Format("{0} - Agent Bulk Payment", string.Empty) : String.Format("{0} - Agent Bulk Payment", Convert.ToString(form["Notes"])); lObj.UserID = User.Identity.GetUserId(); lObj.LedgerDate = (string.IsNullOrEmpty(form["LedgerDate"])) ? string.Empty : Convert.ToString(form["LedgerDate"]); lObj.BankAccountLedgerId = Convert.ToInt32(SplitVals[2]); if (lObj.Amount > 0) { new AgentDA().BulkPaymentAgentCashVoucherInvoicePaymentInvoiceLog(lObj); } } } } #endregion } return(RedirectToAction("BulkPayment", "Agent")); } catch (Exception ex) { return(RedirectToAction("BulkPayment", "Agent")); } }