public ActionResult UserPaymentAccount(UserPaymentAccount objmodels) { if (Request.Form["AccountsID"] != null || Request.Form["AccountsID"] != "") { objmodels.AccountsID = Request.Form["AccountsID"]; objmodels.AccountName = Request.Form["AccountName"]; objmodels.UserID = Request.Form["UserID"]; objmodels.FullName = Request.Form["FullName"]; objmodels.CurrentDate = Request.Form["CurrentDate"]; objmodels.Narration = Request.Form["Narration"]; objmodels.PaidAmount = Request.Form["PaidAmount"]; //objmodels.BalanceAmount = Request.Form["BalanceAmount"]; objmodels.ReferenceCode = Request.Form["ReferenceCode"]; objmodels.DrAmount = Request.Form["DrAmount"]; objmodels.CrAmount = Request.Form["CrAmount"]; objmodels.Balance = Request.Form["Balance"]; } else { objmodels.AccountsID = Request.Form["AccountsID1"]; objmodels.AccountName = Request.Form["AccountName1"]; objmodels.UserID = Request.Form["UserID1"]; objmodels.FullName = Request.Form["FullName1"]; objmodels.CurrentDate = ""; objmodels.Narration = ""; objmodels.PaidAmount = Request.Form["PaidAmount1"]; //objmodels.BalanceAmount = Request.Form["BalanceAmount1"]; objmodels.ReferenceCode = ""; objmodels.DrAmount = Request.Form["DrAmount1"]; objmodels.CrAmount = Request.Form["CrAmount1"]; objmodels.Balance = Request.Form["Balance1"]; } try { if (objbl.Save(objmodels)) { ModelState.Clear(); TempData["msg"] = "UserPaymentAccount Save Successfully"; } else { TempData["msg"] = "UserPaymentAccount Not Save"; } return(RedirectToAction("UserPaymentAccount", "UserPaymentAccount")); } catch (Exception ex) { return(RedirectToAction("UserPaymentAccount", "UserPaymentAccount")); } }
public bool Save(UserPaymentAccount obj) { Connect(); string[] AccID = obj.AccountsID.Split(','); // AccountsID = AccountsID.Where(name => !string.IsNullOrEmpty(name)).ToArray(); string[] AccName = obj.AccountName.Split(','); // AccountName = AccountName.Where(name => !string.IsNullOrEmpty(name)).ToArray(); string[] UsID = obj.UserID.Split(','); // UserID = UserID.Where(name => !string.IsNullOrEmpty(name)).ToArray(); string[] FName = obj.FullName.Split(','); // FullName = FullName.Where(name => !string.IsNullOrEmpty(name)).ToArray(); for (int k = 0; k < FName.Length; k++) { SqlCommand cmd = new SqlCommand("IUUserPayementAccount", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@HospitalID", HospitalID); cmd.Parameters.AddWithValue("@LocationID", LocationID); if (obj.UserPaymentAccountID == "0" || obj.UserPaymentAccountID == null || obj.UserPaymentAccountID == "") { cmd.Parameters.AddWithValue("@UserPaymentAccountID", 0); cmd.Parameters["@UserPaymentAccountID"].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@Mode", "Add"); } else { cmd.Parameters.AddWithValue("@UserPaymentAccountID", obj.UserPaymentAccountID); cmd.Parameters.AddWithValue("@Mode", "Edit"); } if (obj.ReferenceCode == null || obj.ReferenceCode == "") { cmd.Parameters.AddWithValue("@ReferenceCode", string.Empty); } else { cmd.Parameters.AddWithValue("@ReferenceCode", obj.ReferenceCode); } if (obj.AccountsID == null || obj.AccountsID == "") { cmd.Parameters.AddWithValue("@MasterAccountsID", 0); } else { cmd.Parameters.AddWithValue("@MasterAccountsID", AccID[k]); } if (obj.AccountName == null || obj.AccountName == "") { cmd.Parameters.AddWithValue("@MasterAccountName", 0); } else { cmd.Parameters.AddWithValue("@MasterAccountName", AccName[k]); } if (obj.UserID == null || obj.UserID == "") { cmd.Parameters.AddWithValue("@UserID", 0); } else { cmd.Parameters.AddWithValue("@UserID", UsID[k]); } if (obj.FullName == null || obj.FullName == "") { cmd.Parameters.AddWithValue("@UserName", 0); } else { cmd.Parameters.AddWithValue("@UserName", FName[k]); } if (obj.CurrentDate == null || obj.CurrentDate == "") { cmd.Parameters.AddWithValue("@CurrentDate", DateTime.Now.ToString("yyyy-MM-dd")); } else { cmd.Parameters.AddWithValue("@CurrentDate", obj.CurrentDate); } if (obj.Narration == null || obj.Narration == "") { cmd.Parameters.AddWithValue("@Narration", ""); } else { cmd.Parameters.AddWithValue("@Narration", obj.Narration); } if (obj.PaidAmount == null || obj.PaidAmount == "") { cmd.Parameters.AddWithValue("@PaidAmount", 0); } else { cmd.Parameters.AddWithValue("@PaidAmount", obj.PaidAmount); } if (obj.BalanceAmount == null || obj.BalanceAmount == "") { cmd.Parameters.AddWithValue("@BalanceAmount", 0); } else { cmd.Parameters.AddWithValue("@BalanceAmount", obj.BalanceAmount); } cmd.Parameters.AddWithValue("@CreationID", UserID); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); } return(true); }