public ActionResult Step2(CompanyBranchModel userCompany2) { int userId = (int)Session["userId"]; //int userId = 68; BranchAccess ba = new BranchAccess(); userCompany2.MainBranch.StateId = userCompany2.StateId; userCompany2.MainBranch.BranchCode = ba.createBranchCode(userCompany.Company.CompanyCode); userCompany.MainBranch = userCompany2.MainBranch; int reslt = ba.insertFirstBranchDetails(userCompany, userId); if (reslt > 0) { StepAccess sa = new StepAccess(); if (sa.updateStepNumberByUserId(userId, 3)) { bool reslt2 = ba.updateUserBranchId(userCompany2, userId); if (reslt2) { return(RedirectToAction("Step3")); } } } else { ViewBag.ErrorMsg = "Failed to create first branch"; } return(View()); }
/// <summary> /// CreatedBy: Piyumi /// CreatedDate: 2016/1/17 /// Insert branch details /// </summary> /// <param name="branch object"></param> /// <param name="id"></param> /// <returns>true/false</returns> //public int insertBranchDetails(Branch branch, int id) //{ // branch.BranchCode = createBranchCode(getCompanyCodeByUserId(id)); // branch.BranchCompany = getCompanyIdByUserId(id); // branch.BranchCreatedDate = DateTime.Now; // return this.insertBranch(branch, id); //} /// <summary> /// CreatedBy: Piyumi /// CreatedDate: 2016/1/26 /// Insert branch details /// </summary> /// <param name="branch object"></param> /// <param name="userCompany3"></param> /// <param name="id"></param> /// <returns>true/false</returns> public int insertFirstBranchDetails(CompanyBranchModel userCompany3, int id) { string companyCode = userCompany3.Company.CompanyCode; //userCompany3.MainBranch.BranchCode = createBranchCode(companyCode); userCompany3.MainBranch.BranchCompany = getCompanyIdByCompanyCode(companyCode); userCompany3.MainBranch.BranchCreatedDate = DateTime.Now; return(this.insertBranch(userCompany3.MainBranch, id, companyCode)); }
/// <summary> /// CreatedBy:Piyumi /// CreatedDate:2016/1/27 /// Insert non registered branch /// </summary> /// <param name="nonRegBranch"></param> /// <param name="userId"></param> /// <returns></returns> public int insertNonRegBranchDetails(CompanyBranchModel nonRegBranch, int userId, string companyCode) { nonRegBranch.MainBranch.BranchCreatedDate = DateTime.Now; DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); paramertList.Add(new object[] { "@user_id", userId }); paramertList.Add(new object[] { "@company_code", companyCode }); if (!string.IsNullOrEmpty(nonRegBranch.MainBranch.BranchCode)) { paramertList.Add(new object[] { "@branch_code", nonRegBranch.MainBranch.BranchCode.Trim() }); } else { paramertList.Add(new object[] { "@branch_code", nonRegBranch.MainBranch.BranchCode }); } if (!string.IsNullOrEmpty(nonRegBranch.MainBranch.BranchName)) { paramertList.Add(new object[] { "@branch_name", nonRegBranch.MainBranch.BranchName.Trim() }); } paramertList.Add(new object[] { "@branch_address_1", nonRegBranch.MainBranch.BranchAddress1.Trim() }); paramertList.Add(new object[] { "@branch_address_2", nonRegBranch.MainBranch.BranchAddress2 ?? "" }); paramertList.Add(new object[] { "@state_id", nonRegBranch.MainBranch.StateId }); paramertList.Add(new object[] { "@city", nonRegBranch.MainBranch.BranchCity ?? "" }); if ((nonRegBranch.MainBranch.Extention != null) && (nonRegBranch.MainBranch.Extention.ToString() != "")) { nonRegBranch.MainBranch.BranchZip = nonRegBranch.MainBranch.ZipPre + "-" + nonRegBranch.MainBranch.Extention; } else { nonRegBranch.MainBranch.BranchZip = nonRegBranch.MainBranch.ZipPre; } paramertList.Add(new object[] { "@zip", nonRegBranch.MainBranch.BranchZip.Trim() }); paramertList.Add(new object[] { "@email", nonRegBranch.MainBranch.BranchEmail ?? "" }); paramertList.Add(new object[] { "@phone_num_1", nonRegBranch.MainBranch.BranchPhoneNum1.Trim() }); paramertList.Add(new object[] { "@phone_num_2", nonRegBranch.MainBranch.BranchPhoneNum2 ?? "" }); paramertList.Add(new object[] { "@phone_num_3", nonRegBranch.MainBranch.BranchPhoneNum3 ?? "" }); paramertList.Add(new object[] { "@fax", nonRegBranch.MainBranch.BranchFax ?? "" }); paramertList.Add(new object[] { "@created_date", DateTime.Now }); paramertList.Add(new object[] { "@company_id", nonRegBranch.MainBranch.BranchCompany }); paramertList.Add(new object[] { "@branch_id", nonRegBranch.MainBranch.BranchCreatedBy }); try { return(dataHandler.ExecuteSQLReturn("spInsertNonRegisteredBranch", paramertList)); } catch (Exception ex) { throw ex; } }
/// <summary> /// CreatedBy:piyumi /// CreatedDate:2016/1/27 /// update branch id when first branch is created /// /// /// UpdatedBy : nadeeka /// UpdatedDate: 2016/03/03 /// removed existing connection open method and set parameter's to object list and pass stored procedure name to /// call DataHandler class to update given branch details /// /// </summary> /// <param name=""></param> /// <returns></returns> public bool updateUserBranchId(CompanyBranchModel nonRegBranch, int userId) { DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); paramertList.Add(new object[] { "@user_id", userId }); paramertList.Add(new object[] { "@branch_code", nonRegBranch.MainBranch.BranchCode }); try { return(dataHandler.ExecuteSQL("spUpdateBranchId", paramertList) ? true : false); } catch (Exception ex) { throw ex; } }
public ActionResult Step2() { Session["userId"] = 229; //Session["userId"] = 4; //int userId = 68; if ((Session["userId"] != null) && (Session["userId"].ToString() != "")) //if(userId>0) { int userId = (int)Session["userId"]; StepAccess cs = new StepAccess(); int reslt = Convert.ToInt32(Session["companyStep"]); if (reslt == 2) { if ((TempData["Company"] != null) && (TempData["Company"].ToString() != "")) { userCompany = new CompanyBranchModel(); userCompany = (CompanyBranchModel)TempData["Company"]; CompanyType = (userCompany.Company.TypeId == 1) ? "Lender" : "Dealer"; userCompany.MainBranch = new Branch(); if (userCompany.Company.Extension == null) { userCompany.Company.Extension = ""; } } //Get states to list CompanyAccess ca = new CompanyAccess(); List <State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); return(View(userCompany)); } else { return(RedirectToAction("UserLogin", "Login")); } } else { return(RedirectToAction("UserLogin", "Login")); } }
public ActionResult Step1(Company company, int?edit) { if (Session["userId"] == null || Session["userId"].ToString() == "") { return(RedirectToAction("UserLogin", "Login")); } string type; if (edit != 1) { GeneratesCode gc = new GeneratesCode(); _comCode = company.CompanyCode = gc.GenerateCompanyCode(company.CompanyName); type = "INSERT"; } else { company.CompanyCode = _comCode; type = "UPDATE"; } // company.Zip = company.ZipPre; if (company.Extension != null) { company.Zip += "-" + company.Extension; } company.CreatedBy = company.FirstSuperAdminId = Convert.ToInt32(Session["userId"]); company.CompanyStatus = true; CompanyAccess ca = new CompanyAccess(); //check this record is new one or exitsting one //string type = (edit == 1) ? "UPDATE" : "INSERT"; int companyId = ca.InsertCompany(company, type); if (companyId > 0) { ViewBag.SuccessMsg = "Company Successfully setup."; CompanyType = (company.TypeId == 1) ? "Lender" : "Dealer"; //If succeed update step table to step2 StepAccess sa = new StepAccess(); sa.updateStepNumberByUserId(company.FirstSuperAdminId, 2); //Send company detail to step 2 CompanyBranchModel comBranch = new CompanyBranchModel(); comBranch.Company = company; TempData["Company"] = comBranch; return(RedirectToAction("Step2")); } ViewBag.ErrorMsg = "Failed to Setup company."; // Get company types to list List <CompanyType> ctList = ca.GetAllCompanyType(); ViewBag.TypeId = new SelectList(ctList, "TypeId", "TypeName"); //Get states to list List <State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); return(View()); }