protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; _user = (Users)Session["User"]; if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) Response.Redirect("LogIn.aspx?refPage=index.aspx"); else Response.Redirect("LogIn.aspx?refPage=index.aspx?" + str); } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string bankId = Request.QueryString["id"].ToString(); Bank bank = new Bank().GetBankByBankId(int.Parse(bankId), _company.CompanyId); if (bank != null || bank.BankId != 0) { lblId.Text = bank.BankId.ToString(); txtBankCode.Value = bank.BankCode; txtBankName.Value = bank.BankName; txtContactPerson.Value = bank.ContactPerson; txtDesignation.Value = bank.ContactDesignation; txtContactNo.Value = bank.ContactNo; txtEmail.Value = bank.ContactEmail; chkIsActive.Checked = bank.IsActive; } } } }
private bool isValidSession() { if (Session["user"] == null) return false; user = (Users) Session["user"]; return user.UserId != 0; }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; _user = (Users)Session["user"]; if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) Response.Redirect("LogIn.aspx?refPage=default.aspx"); else Response.Redirect("LogIn.aspx?refPage=default.aspx?" + str); } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string costCenterId = Request.QueryString["id"].ToString(); CostCenter costCenter = new CostCenter().GetCostCenterByCostCenterId(int.Parse(costCenterId), _company.CompanyId); if (costCenter != null || costCenter.CostCenterId != 0) { lblId.Text = costCenter.CostCenterId.ToString(); txtCostCenterType.Value = costCenter.CostCenterType; txtCostCentreName.Value = costCenter.CostCenterName; } } } this.GetAllCostCentre(); }
protected void btnLogIn_Click(object sender, EventArgs e) { try { Users user = new Users().GetUserByUserName(txtUserName.Value); if (user.UserId != 0) { if (user.UserPassword != txtPassword.Value) { Alert.Show("User and password didn't match. Please re-enter the correct password."); txtPassword.Focus(); return; } int companyId = int.Parse(ddlCompany.SelectedValue); Session["user"] = user; UserRoleMapping userRole = new UserRoleMapping().GetUserRoleMappingByUserId(user.UserId); UserRole role = new UserRole().GetUserRoleById(userRole.RoleId, companyId); Session["Role"] = role; //Get host and port from the url; string host = HttpContext.Current.Request.Url.Host; string port = HttpContext.Current.Request.Url.Port.ToString(); string path = "http://" + host + ":" + port + "/"; this.GenerateMenu(user, path, Int32.Parse("0")); Company company= new Company().GetCompanyByCompanyId(companyId); Session["company"] = company; if (user.EmployeeId != 0) { Employee employee = new Employee().GetEmployeeByEmployeeId(user.EmployeeId, user.CompanyId); Session["Employee"] = employee; //Department objDepartment = new Department().GetEmployeeDepartment(user.EmployeeId); //Session["Department"] = objDepartment.DepartmentName; } else Session["Department"] = "All"; string refPage = (Request.QueryString["refPage"] == null) ? string.Empty : Request.QueryString["refPage"].ToString(); Response.Redirect(((refPage == string.Empty || refPage.ToLower() == "logout") ? "index.aspx" : refPage), false); } else { Alert.Show("The user is not exist in the database. Please check the username."); txtUserName.Focus(); return; } } catch (Exception ex) { Alert.Show("Error during process user authentication. Error: " + ex.Message); } }
public bool isValidSession() { if (Session["user"] == null) { return false; } user = (Users) Session["user"]; return user.UserId != 0; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { user = (Users)Session["user"]; this.Clear(); this.LoadCompanyDropDownList(); } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; user =(Users) Session["user"]; if (Session["savedListMessage"] !=null) { string msg = Session["savedListMessage"].ToString(); Alert.Show(msg); Session["savedListMessage"] = null; } this.GetAllListTable(); this.LoadListTable(); }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; user = (Users)Session["user"]; if (!IsPostBack) { if (Session["savedMessage"]!=null) { Alert.Show("Successfully saved information"); Session["savedMessage"] = null; } this.LoadCompanyIdDropDown(); this.LoadUserInfoTable(); } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) Response.Redirect("LogIn.aspx?refPage=default.aspx"); else Response.Redirect("LogIn.aspx?refPage=default.aspx?" + str); } if (!IsPostBack) { _user = (Users)Session["user"]; } this.GetAllCostCentre(); this.LoadCostCentreTable(); }
protected void btnSave_Click(object sender, EventArgs e) { try { Users aUsers=new Users(); List<Users> userList = aUsers.GetAllUsersActiceInactive(_company.CompanyId); Users newU = userList[userList.Count - 1]; int id = (newU.UserId) + 1; Users aUser = new Users(); aUser.UserId = id; aUser.UserName = txtUsername.Value; aUser.UserPassword = txtPassword.Value; aUser.UpdateBy = user.UserId; aUser.UpdateDate = DateTime.Now; aUser.IsActive = (chkIsActive.Checked); aUser.CompanyId = int.Parse(CompanyNameDropDownList.SelectedItem.Value); int chk = aUser.InsertUsers(); //Response.Redirect(Request.RawUrl); if (chk > 0) { Session["savedMessage"] = true; Response.Redirect(Request.RawUrl); } else { Alert.Show("Error Occured while inserting a new user"); } } catch (Exception exp) { Alert.Show(exp.Message); } }
private void GenerateMenu(Users _user, string url) { StringBuilder str = new StringBuilder(); int parentId = 0; bool parentUlOpen = false; List<AppPermission> permissionList = new AppPermission().GelAppFunctionalityForMenu(_user.CompanyId, _user.UserId); List<AppModule> moduleList = new AppModule().GetAllAppModule(_user.CompanyId, _user.UserId); foreach (AppModule module in moduleList) { List<AppPermission> modulePermission = permissionList.FindAll(x => x.ModuleName == module.Module); if (modulePermission.Count == 0) continue; modulePermission = modulePermission.OrderBy(x => x.Sequence).ToList(); if (modulePermission[0].IsView) { foreach (AppPermission appPermission in modulePermission) { if (appPermission.IsView) { if (appPermission.Url == "#") { if (parentUlOpen) { str.Append("</ul>\n"); str.Append("</li>\n"); } str.Append("<li class='treeview'>\n"); str.Append("<a href='#'><i class='fa fa-pie-chart'></i><span>"+appPermission.FunctionalityName+"</span><i class='fa fa-angle-left pull-right'></i></a>\n"); str.Append("<ul class='treeview-menu'>\n"); parentId = appPermission.FunctionalityId; parentUlOpen = true; } else { if (appPermission.ParentId != parentId) { if (parentUlOpen) { str.Append("</ul>\n"); str.Append("</li>\n"); } if (appPermission.ParentId == 0) parentUlOpen = false; } str.Append("<li><a href='" + url + appPermission.Url + "'><i class='fa fa-circle-o'></i>" + appPermission.FunctionalityName + "</a></li>\n"); //str.Append("<li><a target=\"_self\" href=\"" + url + appPermission.Url + "\">" + appPermission.FunctionalityName + "</a> </li>\n"); } } } } } if (parentUlOpen) { str.Append("</ul>\n"); str.Append("</li>\n"); } str.Append("</ul>\n"); Session["Menu"] = str.ToString(); }
protected void btnLogIn_Click(object sender, EventArgs e) { try { Users user = new Users().GetUserByUserName(txtUserName.Value); if (user.UserId != 0) { if (user.UserPassword != txtPassword.Value) { Alert.Show("User and password didn't match. Please re-enter the correct password."); txtPassword.Focus(); return; } //string IP = Request.UserHostName; //string compName = DetermineCompName(IP); //UserLoginLog log = new UserLoginLog().GetUserLastLogin(user.UserId); //if (log.Id != 0) //{ // if (log.IpAddress != IP && log.Status == "Logged In") // { // Alert.Show("Sorry! This is user is already logged in from another PC."); // return; // } //} Session["user"] = user; UserRoleMapping userRole = new UserRoleMapping().GetUserRoleMappingByUserId(user.UserId); UserRole role = new UserRole().GetUserRoleById(userRole.RoleId, user.CompanyId); Session["Role"] = role; //Get host and port from the url; string host = HttpContext.Current.Request.Url.Host; string port = HttpContext.Current.Request.Url.Port.ToString(); string path = "http://" + host + ":" + port + "/"; this.GenerateMenu(user, path); //log = new UserLoginLog(); //log.UserId = user.UserId; //log.SessionId = Session.SessionID; //log.IpAddress = IP; //log.LoginPCName = compName; //log.LoginTime = DateTime.Now; //log.Status = "Logged In"; //log.LogOutTime = PublicVariables.minDate; //log.InsertUserLoginLog(); Company company; UserRoleMapping userRoles = new UserRoleMapping().GetUserRoleMappingByUserId(user.UserId); if (userRoles.RoleId != 0 && user.UserId == 1) { user.IsSuperUser = true; company = new Company().GetCompanyByCompanyId(1); } else { user.IsSuperUser = false; company = new Company().GetCompanyByCompanyId(user.CompanyId); } Session["company"] = company; if (user.CompanyId == 0 && !user.IsSuperUser) { Alert.Show("Sorry this user is not associated with any company. Contact your system administrator to fix this issue."); return; } if (user.EmployeeId != 0) { Employee employee = new Employee().GetEmployeeByEmployeeId(user.EmployeeId, user.CompanyId); Session["Employee"] = employee; //Department objDepartment = new Department().GetEmployeeDepartment(user.EmployeeId); //Session["Department"] = objDepartment.DepartmentName; } else Session["Department"] = "All"; string refPage = (Request.QueryString["refPage"] == null) ? string.Empty : Request.QueryString["refPage"].ToString(); Response.Redirect(((refPage == string.Empty || refPage.ToLower() == "logout") ? "index.aspx" : refPage), false); } else { Alert.Show("The user is not exist in the database. Please check the username."); txtUserName.Focus(); return; } } catch (Exception ex) { Alert.Show("Error during process user authentication. Error: " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; user = (Users)Session["user"]; this.LoadCountryDropDownList(); if (Session["empMessage"] != null) { string message = Session["empMessage"].ToString(); Session["empMessage"] = null; Alert.Show(message); } this.LoadCountryDropDownList(); this.LoadDepartmentDropDownList(); this.LoadDesignationDropDownList(); this.Show(); }
protected void Page_Load(object sender, EventArgs e) { user = (Users)Session["user"]; _company = (Company)Session["Company"]; if (Session["JournalInformationMessage"]!=null) { string message = (string) Session["JournalInformationMessage"]; Session["JournalInformationMessage"] = null; Alert.Show(message); } _company = (Company)Session["Company"]; if (!IsPostBack) { LoadFirstTime(); } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; user = (Users)Session["user"]; if (Session["savedSupplicerMessage"] != null) { string msg = Session["savedSupplicerMessage"].ToString(); Alert.Show(msg); Session["savedSupplicerMessage"] = null; } this.LoadCountryDropDownList(); this.Show(); }
private void LoadUserInfoTable() { Users newUsers = new Users(); List<Users> userList = new List<Users>(); userList = newUsers.GetAllUsersList(); Company aCompanyList = new Company(); List<Company> companyNameList = aCompanyList.GetAllCompany(_company.CompanyId); string htmlContent = ""; foreach (Users aUserInfo in userList) { if ((aUserInfo.UserName == "Super") || (aUserInfo.UserName == "Admin")) { continue; } else { string companyName = ""; foreach (Company aCompany in companyNameList) { if (aCompany.CompanyId == aUserInfo.CompanyId) companyName = aCompany.CompanyName; } htmlContent += String.Format( @"<tr><th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th></tr>", aUserInfo.UserName, aUserInfo.UpdateBy, aUserInfo.UpdateDate, aUserInfo.IsActive ); } } userInformationTableBody.InnerHtml += htmlContent; }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; _user = (Users)Session["User"]; if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) Response.Redirect("LogIn.aspx?refPage=index.aspx"); else Response.Redirect("LogIn.aspx?refPage=index.aspx?" + str); } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string bankAccountId = Request.QueryString["id"].ToString(); BankAccounts objBankAccounts = new BankAccounts().GetBankAccountsByBankAccountId(int.Parse(bankAccountId), _company.CompanyId); if (objBankAccounts != null || objBankAccounts.BankAccountId != 0) { List<Bank> bankList = new List<Bank>(); Bank bank = new Bank(); lblId.Text = objBankAccounts.BankAccountId.ToString(); bankIdRadDropDownList1.Items.Clear(); bankList = bank.GetAllBank(_company.CompanyId); List<string> bankName = new List<string>(); foreach (Bank bankNew in bankList) { if (bankNew.BankId == objBankAccounts.BankId) bankName.Add(bankNew.BankName); } bankIdRadDropDownList1.DataSource = bankName; bankIdRadDropDownList1.DataBind(); txtBranchName.Value = objBankAccounts.BranchName; txtAccountNo.Value = objBankAccounts.AccountNo; txtTitle.Value = objBankAccounts.AccountTitle; accountTypeRadDropDownList1.Items.Clear(); List<string> list = new List<string>(); list.Add(objBankAccounts.AccountType); accountTypeRadDropDownList1.DataSource = list; accountTypeRadDropDownList1.DataBind(); RadDatePicker2.SelectedDate = DateTime.Parse(objBankAccounts.OpeningDate); chkIsActive.Checked = objBankAccounts.IsActive; } } } this.LoadBankNames(); this.LoadAccountTypeDropDown(); }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; _user =(Users) Session["user"]; if (Session["savedListMessage"] !=null) { string msg = Session["savedListMessage"].ToString(); Alert.Show(msg); Session["savedListMessage"] = null; } if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) Response.Redirect("LogIn.aspx?refPage=index.aspx"); else Response.Redirect("LogIn.aspx?refPage=index.aspx?" + str); } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string listId = Request.QueryString["id"].ToString(); ListTable objTable = new ListTable().GetListTableById(int.Parse(listId), _company.CompanyId); if (objTable != null || objTable.Id != 0) { lblId.Text = objTable.Id.ToString(); txtListType.Value = objTable.ListType; txtListValue.Value = objTable.ListValue; } } } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; if (Session["savedDepartmentMessage"] != null) { string msg = Session["savedDepartmentMessage"].ToString(); Session["savedDepartmentMessage"] = null; Alert.Show(msg); } user = (Users)Session["user"]; this.LoadCompanyList(); this.LoadDepartmentDropDownList(); }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; user = (Users)Session["user"]; this.LoadCountryDropDownList(); this.LoadDepartmentDropDownList(); if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) { Response.Redirect("LogIn.aspx?refPage=index.aspx"); } else { Response.Redirect("LogIn.aspx?regPage=index.aspx"+str); } } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string id = Request.QueryString["id"].ToString(); Employee tempEmployee= new Employee().GetEmployeeByEmployeeId(int.Parse(id),_company.CompanyId); if (tempEmployee != null || tempEmployee.EmployeeId != 0) { List<string> countryList = Country.CountryList(); List<Addresses> addressList = new Addresses().GetAllAddresses(_company.CompanyId); Designation designation = new Designation().GetDesignationByDesignationId(tempEmployee.DesignationId, _company.CompanyId); Department department; if (tempEmployee.DepartmentId != 0) { department = new Department().GetDepartmentByDepartmentId(tempEmployee.DepartmentId, _company.CompanyId); SetIndex(departmentDropDownList, department.DepartmentId.ToString()); LoadDesignationDropDownList(tempEmployee.DepartmentId); } else { department = new Department(); departmentDropDownList.SelectedIndex = -1; LoadDesignationDropDownList(0); } SetIndex(designationDropDownList,tempEmployee.DesignationId.ToString()); lblId.Text = tempEmployee.EmployeeId.ToString(); txtEmployeeCode.Value = tempEmployee.EmployeeCode; txtEmployeeName.Value = tempEmployee.EmployeeName; JoinRadDatePicker.SelectedDate = DateTime.Parse(tempEmployee.JoinDate); RadDatePicker1.SelectedDate = DateTime.Parse(tempEmployee.DOB); chkIsActive.Checked = tempEmployee.IsActive; //SetIndex(designationDropDownList,designation.DesignationId.ToString()); foreach (Addresses tAddress in addressList) { if (tAddress.SourceType == "Employee" && tAddress.SourceId == tempEmployee.EmployeeId) { addlblId.Text = tAddress.AddressId.ToString(); txtAddressLine1.Value = tAddress.AddressLine1; txtAddressLine2.Value = tAddress.AddressLine2; txtCity.Value = tAddress.City; txtEmail.Value = tAddress.Email; txtZipCode.Value = tAddress.ZipCode; txtPhoneNo.Value = tAddress.Phone; countryDropDownList.SelectedIndex = tAddress.CountryId; break; } } } } } if (Session["empMessage"] != null) { string message = Session["empMessage"].ToString(); Session["empMessage"] = null; Alert.Show(message); } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; user = (Users)Session["user"]; this.LoadCountryDropDownList(); if (Session["savedSupplicerMessage"] != null) { string msg = Session["savedSupplicerMessage"].ToString(); Alert.Show(msg); Session["savedSupplicerMessage"] = null; } if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) { Response.Redirect("LogIn.aspx?refPage=index.aspx"); } else { Response.Redirect("LogIn.aspx?refPage=index.aspx?"+str); } } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string id = Request.QueryString["id"].ToString(); Supplier tempSupplier= new Supplier().GetSupplierBySupplierId(int.Parse(id),_company.CompanyId); if (tempSupplier != null || tempSupplier.SupplierId != 0) { List<Addresses> addressList = new Addresses().GetAllAddresses(_company.CompanyId); Addresses tempAddress = new Addresses(); foreach (Addresses address in addressList) { if (address.SourceType == "Supplier" && address.SourceId == int.Parse(id)) { tempAddress = address; break; } } lblId.Text = id; addlblId.Text = tempAddress.AddressId.ToString(); txtSupplierName.Value = tempSupplier.SupplierName; txtAddressLine1.Value = tempAddress.AddressLine1; txtAddressLine2.Value = tempAddress.AddressLine2; txtCity.Value = tempAddress.City; txtZipCode.Value = tempAddress.ZipCode; txtEmail.Value = tempAddress.Email; txtPhone.Value = tempAddress.Phone; txtMobile.Value = tempAddress.Mobile; txtWeb.Value = tempAddress.Web; txtTotalCredit.Value = tempSupplier.TotalCredit.ToString(); txtTotalDebit.Value = tempSupplier.TotalDebit.ToString(); chkIsActive.Checked = tempSupplier.IsActive; countryDropDownList.SelectedIndex = tempAddress.CountryId; } } } }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; if (Session["savedAddressMessage"] != null) { string msg = Session["savedAddressMessage"].ToString(); Alert.Show(msg); Session["savedAddressMessage"] = null; } if (Session["savedContactMessage"]!=null) { string msg = Session["savedContactMessage"].ToString(); Alert.Show(msg); Session["savedContactMessage"] = null; } user = (Users) Session["user"]; this.LoadBillingCountryDropDownList(); this.LoadShippingCountryDropDownList(); this.LoadContactInformationList(); this.LoadDesignationDropDownList(); }
protected void Page_Load(object sender, EventArgs e) { _company = (Company)Session["Company"]; _user = (Users)Session["user"]; if (!isValidSession()) { string str = Request.QueryString.ToString(); if (str == string.Empty) Response.Redirect("LogIn.aspx?refPage=default.aspx"); else Response.Redirect("LogIn.aspx?refPage=default.aspx?" + str); } if (!IsPostBack) { if (Request.QueryString["id"] != null) { string CoaGroupId = Request.QueryString["id"].ToString(); ChartOfAccountGroup coa = new ChartOfAccountGroup().GetChartOfAccountGroupByCoaGroupId(int.Parse(CoaGroupId), _company.CompanyId); if (coa != null || coa.CoaGroupId != 0) { lblId.Text = coa.CoaGroupId.ToString(); txtGroupName.Value = coa.CoaGroupName; chkIsActive.Checked = true; } } } }