/// <summary> /// CreatedBy: Kanishka /// CreatedDate:2016/1/18 /// insert first branch details /// </summary> /// <returns></returns> public ActionResult CreateBranchFirstBranch() { var type = (string)Session["type"]; if (type == "CompanyEmployee") { ViewBag.Type = "CompanyEmployee"; _type = "CompanyEmployee"; if (TempData["UserCompany"] == null) { return(RedirectToAction("EmployeeLogin", "Login")); } CompanyAccess ca = new CompanyAccess(); //Get states to list List <State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); _userCompany = (UserCompanyModel)TempData["UserCompany"]; _userCompany.Branch = new Branch(); return(View(_userCompany)); } else { ViewBag.Type = ""; return(RedirectToAction("EmployeeLogin", "Login")); } }
protected void EditButton_Click(object sender, EventArgs e) { try { CompanyModel model = new CompanyModel() { Employer_Name = Employer_NameTextBox.Text, EmployeeID = Convert.ToInt32(EmployeeIDDropDownList.SelectedValue), Contact_Number = Convert.ToInt64(Contact_NumberTextBox.Text), Location = LocationTextBox.Text, Website = WebsiteTextBox.Text, }; CompanyAccess access = new CompanyAccess(); string EditComp = access.EditCompany(model); if (EditComp.Equals("Success")) { Response.Write("<script>alert('Details have been Updated successfully');</script>"); } } catch (Exception ex) { Response.Write("<script>alert(('Please enter the values: '" + ex.Message + ");</script>"); } }
public CompanyDepartmentsViewModel(string apiUrl, CompanyModel company) { ApiUrl = apiUrl; CurrentCompany = company; _companyAccess = new CompanyAccess(ApiUrl); WindowTitle = company.Name; }
public ActionResult CreateBranchPost(Branch branch) { ViewBag.Type = ""; int id = userData.UserId; //branch.StateId = branch.StateId2; BranchAccess br = new BranchAccess(); //int reslt = br.insertBranchDetails(branch, id); int reslt = 0; CompanyAccess ca = new CompanyAccess(); List <State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); if (reslt > 0) { ViewBag.SuccessMsg = "Branch is successfully added"; return(RedirectToAction("CreateBranch", "CreateBranch", new { success = 1 })); //branch = new Branch(); //return PartialView(branch); } else { ViewBag.ErrorMsg = "Failed to add branch"; return(PartialView()); } }
protected void btnupdate_Click(object sender, EventArgs e) { try { Company dpt = new Company(); dpt.Name = txtName.Text; dpt.Location = txtLocation.Text; dpt.ID = Int32.Parse(hdnID.Value); CompanyAccess manager = new CompanyAccess(); if (manager.Update(dpt) > 0) { GridView1.DataSourceID = ObjectDataSource1.ID; btnupdate.Visible = false; btnsave.Visible = true; lblMsg.Text = "success"; } else { lblMsg.Text = "Failed"; } GridView1.DataSourceID = ObjectDataSource1.ID; Clear(); } catch (Exception ex) { Response.Write(@"<script language='javascript'>alert('The following errors have occurred: \n" + ex + " .');</script>"); } }
/// <summary> /// CreatedBy : Kanishka SHM /// CreatedDate: 2016/01/18 /// /// Create company view /// </summary> /// <returns></returns> // GET: SetupCompany public ActionResult Setup() { if (Session["type"] == null) { return(RedirectToAction("UserLogin", "Login")); } var type = (string)Session["type"]; //if (type == "CompanyEmployee") //{ //} CompanyAccess ca = new CompanyAccess(); //Get states to list List <State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); _user = (User)TempData["User"]; List <CompanyType> ctList = ca.GetAllCompanyType(); ViewBag.TypeId = new SelectList(ctList, "TypeId", "TypeName"); return(View()); }
/* protected void EmployeeIDDropDownList_SelectedIndexChanged(object sender, EventArgs e) * { * CompanyModel companymodel = new CompanyModel(); * CompanyAccess companyaccess = new CompanyAccess(); * companymodel = companyaccess.GetCompany(Convert.ToInt32(EmployeeIDDropDownList.SelectedValue)); * Employer_NameTextBox.Text = companymodel.Employer_Name; * Contact_NumberTextBox.Text = companymodel.Contact_Number.ToString(); * LocationTextBox.Text = companymodel.Location; * WebsiteTextBox.Text = companymodel.Website; * * * * }*/ protected void EmployeeIDDropDownList_SelectedIndexChanged1(object sender, EventArgs e) { CompanyModel companymodel = new CompanyModel(); CompanyAccess companyaccess = new CompanyAccess(); companymodel = companyaccess.GetCompany(Convert.ToInt32(EmployeeIDDropDownList.SelectedValue)); Employer_NameTextBox.Text = companymodel.Employer_Name; Contact_NumberTextBox.Text = companymodel.Contact_Number.ToString(); LocationTextBox.Text = companymodel.Location; WebsiteTextBox.Text = companymodel.Website; }
// GET: CreateBranch /// <summary> /// /// </summary> /// <returns></returns> public ActionResult CreateBranch(int success = 0) { if (success == 1) { ViewBag.SuccessMsg = "Branch is successfully added"; } //Get states to list CompanyAccess ca = new CompanyAccess(); List <State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); return(PartialView()); }
/// <summary> /// CreatedBy : Kanishka SHM /// CreatedDate: 2016/02/08 /// /// generate company code /// /// argument: companyName(string) /// /// </summary> /// <returns>companyCode(string)</returns> public string GenerateNonRegCompanyCode(string companyName) { var prefix = companyName.Substring(0, 3).ToUpper(); var ca = new CompanyAccess(); var latestCode = ca.GetLatestNonRegCompanyCode(prefix); if (latestCode != "") { var sufix = (Convert.ToInt32(latestCode.Substring(3, latestCode.Length - 3)) + 1).ToString("00"); return(prefix + sufix); } return(prefix + "01"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CompanyAccess obj = new CompanyAccess(); List <int> EmpIDList = obj.GetEmployeeID(); int i = 0; foreach (int EmpID in EmpIDList) { EmployeeIDDropDownList.Items.Insert(i, new ListItem(EmpID.ToString())); i++; } } }
private void GetEditData(object p) { try { Company lst = new CompanyAccess().GetCompany(Int32.Parse(p.ToString())); txtName.Text = lst.Name; txtLocation.Text = lst.Location; hdnID.Value = lst.ID.ToString(); btnsave.Visible = false; btnupdate.Visible = true; } catch (Exception ex) { Response.Write(@"<script language='javascript'>alert('The following errors have occurred: \n" + ex + " .');</script>"); } }
// GET: SetupProcessTest public ActionResult Step1(int?edit) { Session["userId"] = 229; if (Session["userId"] == null || Session["userId"].ToString() == "") { return(RedirectToAction("UserLogin", "Login")); } int userId = Convert.ToInt32(Session["userId"]); CompanyAccess ca = new CompanyAccess(); StepAccess sa = new StepAccess(); // 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"); if (Convert.ToInt32(Session["companyStep"]) == 1 && edit != 1) { return(View()); } if (edit == 1) { if (!string.IsNullOrEmpty(Session["userId"].ToString())) { userId = Convert.ToInt32(Session["userId"]); //---------- Company preCompany = ca.GetCompanyDetailsCompanyId(userData.Company_Id); _comCode = preCompany.CompanyCode; ViewBag.Edit = "Yes"; return(View(preCompany)); } } return(RedirectToAction("UserLogin", "Login")); }
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")); } }
protected void btnCreate_Click(object sender, EventArgs e) { //string CompanyName = null, Address1 = null, Address2 = null, City = null, State = null, PostCode = null, // Phone = null, Fax = null, Email = null, URL1 = null, URL2 = null, IATA = null, FMCNo = null, IssuePlace = null, // TaxIDType = null, TaxIDNo = null, TSANo = null, TSAExpDate = null, AESContact = null, AESCity = null, // AESState = null, AESPostCode = null, AESCountry = null, AESEmail = null, AESPartyType = null; // passing null value instead of empty string between function call, but passing parameter value to SQL server ...which to choose ? // if ( txtCompanyName.Text.Trim() != "") CompanyName = txtCompanyName.Text; string CompanyName = txtCompanyName.Text; string Address1 = txtAddress1.Text; string Address2 = txtAddress2.Text; string City = txtCity.Text; string State = txtState.Text; string PostCode = txtPostCode.Text; string Phone = txtPhone.Text; string Fax = txtFax.Text; string Email = txtEmail.Text; string URL1 = txtURL1.Text; string URL2 = txtURL2.Text; string IATA = txtIATA.Text; string FMCNo = txtFMCNo.Text; string IssuePlace = txtIssuePlace.Text; string TaxIDType = drpTaxIDType.SelectedItem.Text; string TaxIDNo = txtTaxIDNo.Text; string TSANo = txtTSANo.Text; string TSAExpDate = txtTSAExpDate.Text; string AESContact = txtAESContact.Text; string AESCity = txtAESCity.Text; string AESState = txtAESState.Text; string AESPostCode = txtAESPostCode.Text; string AESCountry = txtAESCountry.Text; string AESEmail = txtAESEmail.Text; string AESPartyType = drpAESPartyType.SelectedItem.Text; bool flag = false; flag = CompanyAccess.Company_Create(CompanyName, Address1, Address2, City, State, PostCode, Phone, Fax, Email, URL1, URL2, IATA, FMCNo, IssuePlace, TaxIDType, TaxIDNo, TSANo, TSAExpDate, AESContact, AESCity, AESState, AESPostCode, AESCountry, AESEmail, AESPartyType); lblStatus.Text = flag ? "ACCOUNT CREATED" : "ERROR ! FAILED TO CREATE ACCOUNT"; //lblStatus.Text = Address1; }
public ActionResult CreateBranchFirstBranch(UserCompanyModel userCompany) { if (_type == "CompanyEmployee") { ViewBag.Type = "CompanyEmployee"; BranchAccess ba = new BranchAccess(); userCompany.Branch.BranchCode = ba.createBranchCode(_userCompany.Company.CompanyCode); _userCompany.Branch = userCompany.Branch; _userCompany.Branch.StateId = userCompany.StateId; CompanyAccess ca = new CompanyAccess(); //if (ca.SetupCompany(_userCompany)) if (ca.SetupCompanyRollback(_userCompany)) { ViewBag.SuccessMsg = "Company is successfully setup"; return(View()); } else { ViewBag.ErrorMsg = "Failed to setup company"; return(RedirectToAction("CreateFirstSuperUser", "CreateUser")); } } return(View()); }
protected void AddCompanyButton_Click(object sender, EventArgs e) { try { CompanyModel companymodel = new CompanyModel() { Employer_Name = Employer_NameTextBox.Text, Contact_Number = Convert.ToInt64(Contact_NumberTextBox.Text), Location = LocationTextBox.Text, Website = WebsiteTextBox.Text, }; CompanyAccess companydata = new CompanyAccess(); string SaveComp = companydata.SaveCompany1(companymodel); if (SaveComp.Equals("Success")) { Response.Write("<script>alert('Details have been saved successfully');</script>"); } } catch (Exception ex) { Response.Write("<script>alert(('Please enter the values: '" + ex.Message + ");/script>"); } }
public CompanyLogic() { companyAccess = new CompanyAccess(); csvHelper = new CsvHelper(); companyList = SelectAllCompanies(); }
/// <summary> /// Frontend page: Join Dealer /// Title: view of Link Dealer page /// Designed: Nadeeka /// User story: /// Developed: Nadeeka /// Date created: 2016/03/30 /// Edited: Piyumi Perera /// </summary> /// <returns></returns> public ActionResult LinkDealer() { //Check result of Join Dealer page if (TempData["msg"] != null) { //Check TempData["msg"] is 1 if (TempData["msg"].ToString() == "1") { ViewBag.SuccessMsg = "User Successfully Created"; } //Check TempData["msg"] is 2 else if (TempData["msg"].ToString() == "2") { ViewBag.Error = "Error"; } } CompanyAccess ca = new CompanyAccess(); BranchAccess ba = new BranchAccess(); Loan loan = new Loan(); //Check Session["oneLoanDashboard"] is not null if (Session["oneLoanDashboard"] != null) { //convert session object to loan object loan = (Loan)Session["oneLoanDashboard"]; } //Check Session["loanDashboardJoinDealer"] is not null if (Session["loanDashboardJoinDealer"] != null) { //convert session object to loan object loan = (Loan)Session["loanDashboardJoinDealer"]; } //remove Session["popUpSelectionType"] Session.Remove("popUpSelectionType"); //return non registered branch details by non registered branch id NonRegBranch nonRegBranches = ba.getNonRegBranchByNonRegBranchId(loan.NonRegBranchId); ViewBag.nonRegBranches = nonRegBranches.BranchName; ViewBag.nonRegCompany = nonRegBranches.CompanyNameBranchName; List <User> userList = new List <User>(); //return all users of given company id userList = (new UserAccess()).GetUserListByCompany(userData.Company_Id); //filter user list who has authorization for selected loan userList = userList.FindAll(t => t.BranchId == loan.BranchId || (t.BranchId == 0 && t.RoleId == 1)); ViewBag.UserIdForSendReq = new SelectList(userList, "UserId", "UserName"); //get report list for dealer user List <Right> ReportRightsList = new List <Right>(); User us = new User(); us.ReportRightsList = new List <Right>(); ReportRightsList = (new UserRightsAccess()).getReportRights(); if (ReportRightsList != null && ReportRightsList.Count > 0) { foreach (Right rgt in ReportRightsList) { //Check dealer user can view the report if (!rgt.DealerView) { continue; } else { //check title need not to be tracked for selected loan and report right for Title Status if ((loan.IsTitleTrack == 0) && (rgt.rightId == "R04")) { //if title need not to be tracked report right for Title Status is not added to right list continue; } //check there is no advance fee for selected loan and report right for advance fee invoice and advance fee receipt if ((loan.AdvanceFee == 0) && ((rgt.rightId == "R07") || (rgt.rightId == "R08"))) { //if there is no advance fee, report right for advance fee invoice and advance fee receipt are not added to right list continue; } //check there is no monthly loan fee for selected loan and report right for monthly loan fee invoice and monthly loan fee receipt if ((loan.MonthlyLoanFee == 0) && ((rgt.rightId == "R09") || (rgt.rightId == "R10"))) { //if there is no monthly loan fee, report right for monthly loan fee invoice and monthly loan fee receipt are not added to right list continue; } //check there is no lot inspection fee for selected loan and report right for lot inspection fee invoice and lot inspection fee receipt if ((loan.LotInspectionFee == 0) && ((rgt.rightId == "R11") || (rgt.rightId == "R12"))) { //if there is no lot inspection fee, report right for lot inspection fee invoice and lot inspection fee receipt are not added to right list continue; } } us.ReportRightsList.Add(rgt); } } //Check user is super admin if (userData.RoleId == 1) { //convert user list to session object Session["UserReqList"] = userList; } //Check user is admin else if (userData.RoleId == 2) { //convert user list to session object Session["UserReqList"] = userList; } else { //return to dashboard return(RedirectToAction("UserDetails", "UserManagement")); } return(View(us)); }
public ActionResult Create(User user) { int currentUser = 0; try { currentUser = int.Parse(Session["userId"].ToString()); } catch (Exception) { return(RedirectToAction("UserLogin", "Login")); } user.CreatedBy = _createById; user.IsDelete = false; user.Status = false; //Set admin branch to new user if (_curUserRoleId == 2) { user.BranchId = _curBranchId; } //Check role is selected if (user.RoleId == 0) { user.RoleId = 2; } //Check branch is selected if (_curUserRoleId == 1 && user.BranchId == 0) { user.BranchId = _curBranchId; } string passwordTemp = user.Password; UserAccess ua = new UserAccess(); string newSalt = PasswordEncryption.RandomString(); user.Password = PasswordEncryption.encryptPassword(user.Password, newSalt); user.Email = user.NewEmail; //Check this CompanyAccess ca = new CompanyAccess(); Company company = new Company();//ca.GetCompanyDetailsByFirstSpUserId(currentUser); //Insert user user.Company_Id = company.CompanyId; int res = ua.InsertUser(user); //Insert new user to user activation table string activationCode = Guid.NewGuid().ToString(); int userId = (new UserAccess()).getUserId(user.Email); res = ua.InsertUserActivation(userId, activationCode); if (res == 1) { ViewBag.SuccessMsg = "Data Successfully inserted!"; string body = "Hi " + user.FirstName + "! <br /><br /> Your account has been successfully created. Below in your account detail." + "<br /><br /> User name: " + user.UserName + "<br /> Password : <b>" + passwordTemp + "<br />Click <a href='http://localhost:57318/CreateUser/ConfirmAccount?userId=" + userId + "&activationCode=" + activationCode + "'>here</a> to activate your account." + "<br /><br/> Thanks,<br /> Admin."; Email email = new Email(user.Email); email.SendMail(body, "Account details"); // check the user as superadmin or admin.. if (user.RoleId == 1 || user.RoleId == 2) { ViewBag.SuccessMsg = "User Successfully Created"; return(RedirectToAction("create", new { lbls = ViewBag.SuccessMsg })); } Session["editUserIds"] = userId; return(RedirectToAction("SetRights", "EditRights", new { @lbl1 = ViewBag.SuccessMsg })); } else { ViewBag.ErrorMsg = "Failed to create user!"; //Restrict to create above user role RoleAccess ra = new RoleAccess(); List <UserRole> roleList = ra.GetAllUserRoles(); List <UserRole> tempRoleList = new List <UserRole>(); for (int i = roleList[_curUserRoleId - 1].RoleId; i <= roleList.Count && _curUserRoleId != 3; i++) { UserRole tempRole = new UserRole() { RoleId = roleList[i - 1].RoleId, RoleName = roleList[i - 1].RoleName }; tempRoleList.Add(tempRole); } ViewBag.RoleId = new SelectList(tempRoleList, "RoleId", "RoleName"); // get all branches List <Branch> branchesLists = (new BranchAccess()).getBranches(_companyId); ViewBag.BranchId = new SelectList(branchesLists, "BranchId", "BranchName"); return(PartialView("Create")); } }
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()); }
public CompanyDepartmentControlViewModel(string apiUrl, CompanyModel currentCompany) { CurrentCompany = currentCompany; _access = new CompanyAccess(apiUrl); }