public ActionResult InsertCustomer(CreateCustomerAccounts2por meth) { if (ModelState.IsValid) { DataAccessLayer.DBManager obj = new DataAccessLayer.DBManager(); int check = obj.checkCustomer(meth.CustomerID, "ByCustomerID"); if (check > 0) { CreateCustomerAccounts2porDbData ab = new CreateCustomerAccounts2porDbData(); int result = ab.insertdata(meth); if (result == 0) { return(RedirectToAction("Exception")); } ViewData["Result"] = result; TempData["AlertMessage"] = "Account is created successfully with " + result + " AccountID"; ModelState.Clear(); return(View()); } else { TempData["AlertMessage"] = "Requested customer ID is not present in system."; return(View()); } } else { return(View()); } }
/// <summary> /// Sql operation to crete a new account for an existing customer. /// </summary> /// <param name="meth"></param> /// <returns></returns> public int insertdata(CreateCustomerAccounts2por meth) { try { DateTime date = DateTime.Now; // string connectionstring = "Data Source=intvmsql01;Initial Catalog =db02test01; User Id=pj02test01; password=tcstvm"; string connectionstring = "data source=.;" + "database=Binoy;" + "Integrated Security=true"; SqlConnection connection = new SqlConnection(connectionstring); connection.Open(); SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Insert_Create_Customer_Account_s2por"; command.Connection = connection; command.Parameters.AddWithValue("@CustomerID", meth.CustomerID); command.Parameters.AddWithValue("@AccountType", meth.AccountType); command.Parameters.AddWithValue("@DepositeAmount", meth.DepositAmount); command.Parameters.AddWithValue("@date", date); command.Parameters.AddWithValue("@AccountID", 0); command.Parameters.AddWithValue("@count", 0); command.Parameters.AddWithValue("@temp_type", ""); command.Parameters["@AccountID"].Direction = ParameterDirection.Output; int pp = command.ExecuteNonQuery(); connection.Close(); if (pp > 0) { int x = Convert.ToInt32(command.Parameters["@AccountID"].Value); return(x); } else { return(1); } } catch (Exception e) { return(0); } }