protected void btnRegister_Click(object sender, EventArgs e) { #region Server Side Validation string strErrorMessage = ""; if (txtUserName.Text.Trim() == "") { strErrorMessage += "-Enter User Name <br />"; } if (txtPassword.Text.Trim() == "") { strErrorMessage += "-Enter Password <br />"; } if (strErrorMessage.Trim() != "") { lblMassage.Text = strErrorMessage; lblMassage.CssClass = "text-danger"; return; } #endregion Server Side Validation UserENT entUser = new UserENT(); UserBAL balUser = new UserBAL(); if (balUser.SelectByUserName(txtUserName.Text.ToString().Trim()).IsNull) { readData(); string strOTP = GeneratePassword().ToString(); Session["OTP"] = strOTP; MailMessage msg = new MailMessage(); msg.From = new MailAddress("*****@*****.**"); msg.To.Add(txtUserName.Text); msg.Subject = "Verfiy your email account"; msg.Body = "Welcome to Income Expence <br/><br/>Your OTP is:<strong>" + strOTP + "</strong>"; msg.IsBodyHtml = true; SmtpClient smt = new SmtpClient(); smt.Host = "smtp.gmail.com"; System.Net.NetworkCredential ntwd = new NetworkCredential(); ntwd.UserName = "******"; // Your Email ID ntwd.Password = ""; // Your Password smt.UseDefaultCredentials = true; smt.Credentials = ntwd; smt.Port = 587; smt.EnableSsl = true; smt.Send(msg); lblMassage.Text = "Email Sent Successfully"; lblMassage.ForeColor = System.Drawing.Color.ForestGreen; ClearControls(); Response.Redirect("~/AdminPanel/Authentication/VerifyEmail.aspx"); } else { lblMassage.Text = "User Name is alrady Entered"; lblMassage.CssClass = "text-danger"; ClearControls(); } }
private void fillGridViewEmployee() { DataTable dtUser = new DataTable(); UserBAL balUser = new UserBAL(); UserENT entUser = new UserENT(); entUser = balUser.SelectUserCount(); lblTotalEmployee.Text = entUser.Usercount.ToString(); lblPendingLeave.Text = Session["PendingLeaveRequest"].ToString(); dtUser = balUser.SelectAll(); if (dtUser != null && dtUser.Rows.Count > 0) { gvEmployeeDetails.DataSource = dtUser; gvEmployeeDetails.DataBind(); } else if (dtUser.Rows.Count < 1) { gvEmployeeDetails.DataSource = null; gvEmployeeDetails.DataBind(); PanelGV.Visible = false; } else { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balUser.Message; } }
private void FillGridViewLeave() { LeaveStatusBAL balLeaveStatus = new LeaveStatusBAL(); DataTable dtLeaveStatus = new DataTable(); UserBAL balUser = new UserBAL(); UserENT entUser = new UserENT(); entUser = balUser.SelectUserCount(); lblTotalEmployee.Text = entUser.Usercount.ToString(); dtLeaveStatus = balLeaveStatus.SelectAll(); Session["PendingLeaveRequest"] = dtLeaveStatus.Rows.Count; if (dtLeaveStatus != null && dtLeaveStatus.Rows.Count > 0) { lblPendingLeave.Text = dtLeaveStatus.Rows.Count.ToString(); gvLeaveStatus.DataSource = dtLeaveStatus; gvLeaveStatus.DataBind(); } else if (dtLeaveStatus.Rows.Count < 1) { lblPendingLeave.Text = 0.ToString(); gvLeaveStatus.DataSource = null; gvLeaveStatus.DataBind(); PanelGV.Visible = false; } else { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balLeaveStatus.Message; } }
protected void btnUpdateProfileImage_Click(object sender, EventArgs e) { UserENT entUser = new UserENT(); entUser.UserID = Convert.ToInt32(Session["UserID"].ToString()); if (fuProfile.HasFiles) { string strPath = "~/UserImages/"; string strPhysicalPath = ""; strPhysicalPath = Server.MapPath(strPath); strPhysicalPath += fuProfile.FileName; strPath += fuProfile.FileName; if (File.Exists(strPhysicalPath)) { File.Delete(strPhysicalPath); } fuProfile.SaveAs(strPhysicalPath); entUser.UserProfileImage = strPath; Session["UserProfileImage"] = strPath; } UserBAL balUser = new UserBAL(); if (balUser.UpdateProfile(entUser)) { Response.Redirect("~/AdminPanel/Profile/Profile.aspx"); } else { lblMessageProfile.Text = balUser.Message; } }
private void createNewUser() { UserENT entUser = new UserENT(); #region Read Data entUser.UserName = Session["UserName"].ToString().Trim(); entUser.Password = Session["Password"].ToString().Trim(); entUser.DisplayName = Session["DisplayName"].ToString().Trim(); entUser.Address = Session["Address"].ToString().Trim(); entUser.MobileNumber = Session["MobileNumber"].ToString().Trim(); entUser.UserProfileImage = Session["UserProfileImage"].ToString().Trim(); #endregion UserBAL balUser = new UserBAL(); if (balUser.Insert(entUser)) { lblMessage.Text = "Insert Successfully"; lblMessage.CssClass = "text-success"; Session["Password"] = null; Session["MobileNumber"] = null; Response.Redirect("~/AdminPanel/Authentication/Login.aspx"); } else { lblMessage.Text = balUser.Message; } }
protected void btnRegister_Click(object sender, EventArgs e) { #region ServerSide Validation String strErrorMessage = ""; if (txtUserName.Text == "") { strErrorMessage += "Enter User Name<br/>"; } if (txtPassword.Text == "") { strErrorMessage += "Enter Password<br/>"; } if (strErrorMessage != "") { lblMessage.Text = strErrorMessage; divMessage.Visible = true; return; } #endregion ServerSide Validation #region Collect Form Data UserENT entUser = new UserENT(); if (txtUserName.Text != "") { entUser.UserName = txtUserName.Text.Trim(); } if (txtEmail.Text != "") { entUser.Email = txtEmail.Text.Trim(); } if (txtPassword.Text != "") { entUser.Password = txtPassword.Text.Trim(); } #endregion Collect Form Data UserBAL balUser = new UserBAL(); if (balUser.Insert(entUser)) { ClearControls(); lblMessage.Text = "Register SuccessFully"; divMessage.Visible = true; } else { lblMessage.Text = balUser.Message; divMessage.Visible = true; } }
public UserENT SelectUserCount() { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectUserCount"; #endregion Prepare Command #region Read Data and Set Controls UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { if (objSDR.HasRows) { while (objSDR.Read()) { if (!objSDR["Usercount"].Equals(DBNull.Value)) { entUser.Usercount = Convert.ToInt32(objSDR["Usercount"]); } } return(entUser); } else { return(null); } } #endregion Read Data and Set Controls } catch (SqlException ex) { Message = ex.Message; return(null); } catch (Exception ex) { Message = ex.Message; return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public Boolean Insert(UserENT entUser) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_Insert"; objCmd.Parameters.Add("@UserID", SqlDbType.Int, 4).Direction = ParameterDirection.Output; objCmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = entUser.UserName; objCmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = entUser.Password; objCmd.Parameters.Add("@DisplayName", SqlDbType.VarChar).Value = entUser.DisplayName; objCmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value = entUser.MobileNo; objCmd.Parameters.Add("@DOB", SqlDbType.VarChar).Value = entUser.DOB; objCmd.Parameters.Add("@Gender", SqlDbType.VarChar).Value = entUser.Gender; objCmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = entUser.Email; objCmd.Parameters.Add("@City", SqlDbType.VarChar).Value = entUser.City; objCmd.Parameters.Add("@Qualification", SqlDbType.VarChar).Value = entUser.Qualification; objCmd.Parameters.Add("@Experience", SqlDbType.VarChar).Value = entUser.Experience; objCmd.Parameters.Add("@DesignationID", SqlDbType.Int).Value = entUser.DesignationID; objCmd.Parameters.Add("@DepartmentID", SqlDbType.Int).Value = entUser.DepartmentID; objCmd.Parameters.Add("@InstituteID", SqlDbType.Int).Value = entUser.InstituteID; objCmd.Parameters.Add("@PhotoPath", SqlDbType.VarChar).Value = entUser.PhotoPath; #endregion Prepare Command objCmd.ExecuteNonQuery(); if (objCmd.Parameters["@UserID"] != null) { entUser.UserID = Convert.ToInt32(objCmd.Parameters["@UserID"].Value); } return(true); } catch (SqlException ex) { Message = ex.Message; return(false); } catch (Exception ex) { Message = ex.Message; return(false); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public Boolean Insert(UserENT entUser) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_Insert"; objCmd.Parameters.Add("@UserID", SqlDbType.Int, 4).Direction = ParameterDirection.Output; objCmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = entUser.UserName; objCmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = entUser.Email; //objCmd.Parameters.Add("@UserType", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output; objCmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = entUser.Password; #endregion Prepare Command objCmd.ExecuteNonQuery(); if (objCmd.Parameters["@UserID"] != null) { entUser.UserID = Convert.ToInt32(objCmd.Parameters["@UserID"].Value); } //if (objCmd.Parameters["@UserType"] != null) // entUser.UserType = Convert.ToString(objCmd.Parameters["@UserType"].Value); return(true); } catch (SqlException sqlex) { Message = sqlex.InnerException.Message; return(false); } catch (Exception ex) { Message = ex.InnerException.Message; return(false); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public UserENT SelectUserName(SqlInt32 UserID) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectUserNameByUserID"; objCmd.Parameters.Add("@UserID", SqlDbType.Int).Value = UserID; #endregion Prepare Command #region Read Data and Set Controls UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { while (objSDR.Read()) { if (!objSDR["UserName"].Equals(DBNull.Value)) { entUser.UserName = Convert.ToString(objSDR["UserName"]); } } } return(entUser); #endregion Read Data and Set Controls } catch (SqlException ex) { Message = ex.Message; return(null); } catch (Exception ex) { Message = ex.Message; return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public SqlString SelectByUserID(SqlInt32 UserID) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectByUserID"; objCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = UserID; UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { if (objSDR.HasRows) { while (objSDR.Read()) { if (!objSDR["Password"].Equals(DBNull.Value)) { entUser.Password = Convert.ToString(objSDR["Password"].ToString().Trim()); } } } } return(entUser.Password); } catch (SqlException sqlex) { Message = sqlex.InnerException.ToString(); return(null); } catch (Exception ex) { Message = ex.Message.ToString(); return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public Boolean UpdateByPK(UserENT entUser) { UserDAL dalUser = new UserDAL(); if (dalUser.UpdateByPK(entUser)) { return(true); } else { Message = dalUser.Message; return(false); } }
public SqlString selectByMobileNumber(SqlString MobileNo) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectByMobileNo"; objCmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value = MobileNo; UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { if (objSDR.HasRows) { while (objSDR.Read()) { if (!objSDR["MobileNo"].Equals(DBNull.Value)) { entUser.MobileNumber = objSDR["MobileNo"].ToString().Trim(); } } } } return(entUser.MobileNumber); } catch (SqlException sqlex) { Message = sqlex.InnerException.ToString(); return(null); } catch (Exception ex) { Message = ex.InnerException.ToString(); return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public Boolean Insert(UserENT entUser) { UserDAL dalUser = new UserDAL(); if (dalUser.Insert(entUser)) { return(true); } else { Message = dalUser.Message; return(false); } }
protected void gvLeaveStatus_RowCommand(object sender, GridViewCommandEventArgs e) { LeaveBAL balLeave = new LeaveBAL(); LeaveENT entLeave = new LeaveENT(); LeaveStatusBAL balLeaveStatus = new LeaveStatusBAL(); UserENT entUser = new UserENT(); UserBAL balUser = new UserBAL(); entUser = balUser.SelectUserName(Convert.ToInt32(Session["UserID"].ToString().Trim())); if (e.CommandName == "Approved") { if (e.CommandArgument != null) { #region Collect Data entLeave.LeaveStatus = e.CommandName.ToString().Trim(); entLeave.LeaveResponseBy = entUser.UserName; #endregion Collect Data if (!balLeave.UpdateLeaveStatusInLeave(entLeave, Convert.ToInt32(e.CommandArgument))) { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balLeave.Message; } } } else if (e.CommandName == "Rejected") { if (e.CommandArgument != null) { #region Collect Data entLeave.LeaveStatus = e.CommandName.ToString().Trim(); entLeave.LeaveResponseBy = entUser.UserName; #endregion Collect Data if (!balLeave.UpdateLeaveStatusInLeave(entLeave, Convert.ToInt32(e.CommandArgument))) { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balLeave.Message; } } } balLeaveStatus.Delete(Convert.ToInt32(e.CommandArgument)); FillGridViewLeave(); }
public Boolean Insert(UserENT entUser) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_Insert"; objCmd.Parameters.Add("@UserID", SqlDbType.Int).Direction = ParameterDirection.Output; objCmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = entUser.UserName; objCmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = entUser.Password; objCmd.Parameters.Add("@DisplayName", SqlDbType.VarChar).Value = entUser.DisplayName; objCmd.Parameters.Add("@Address", SqlDbType.VarChar).Value = entUser.Address; objCmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value = entUser.MobileNumber; objCmd.Parameters.Add("@UserProfileImage", SqlDbType.VarChar).Value = entUser.UserProfileImage; objCmd.ExecuteNonQuery(); entUser.UserID = Convert.ToInt32(objCmd.Parameters.Add("@UserID", SqlDbType.Int).Value); return(true); } catch (SqlException sqlex) { Message = sqlex.InnerException.ToString(); return(false); } catch (Exception ex) { Message = ex.InnerException.ToString(); return(false); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
protected void btnLogin_Click(object sender, EventArgs e) { #region Server Side Validation string strErrorMessage = ""; if (txtUserName.Text.Trim() == "") { strErrorMessage += "-Enter User Name <br />"; } if (txtPassword.Text.Trim() == "") { strErrorMessage += "-Enter Password <br />"; } if (strErrorMessage.Trim() != "") { lblErrorMessage.Text = strErrorMessage; return; } #endregion Server Side Validation UserENT entUser = new UserENT(); UserBAL balUser = new UserBAL(); entUser = balUser.SelectByUserNameAndPassword(txtUserName.Text.Trim(), txtPassword.Text.Trim()); if (entUser.UserID.IsNull) { ClearControls(); lblErrorMessage.Text = "Invalid User"; lblErrorMessage.CssClass = "text-danger"; } else { Session["UserID"] = entUser.UserID.ToString().Trim(); Session["UserName"] = entUser.UserName.ToString().Trim(); Session["DisplayName"] = entUser.DisplayName.ToString().Trim(); Session["Address"] = entUser.Address.ToString(); Session["MobileNo"] = entUser.MobileNumber.ToString().Trim(); Session["UserProfileImage"] = entUser.UserProfileImage.ToString().Trim(); ClearControls(); Response.Redirect("~/AdminPanel/Dashboard/Dashboard.aspx"); } }
public Boolean UpdateProfile(UserENT entUser) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_UpdateProfile"; objCmd.Parameters.Add("@UserID", SqlDbType.Int).Value = entUser.UserID; objCmd.Parameters.Add("@UserProfileImage", SqlDbType.VarChar).Value = entUser.UserProfileImage; objCmd.ExecuteNonQuery(); return(true); } catch (SqlException sqlex) { Message = sqlex.Message.ToString(); return(false); } catch (Exception ex) { Message = ex.Message.ToString(); return(false); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { UserENT entUser = new UserENT(); UserBAL balUser = new UserBAL(); DataTable dtUser = new DataTable(); entUser = balUser.SelectUserNamePasswordByEmail(txtEmail.Text); dtUser = balUser.SelectUserEmail(); foreach (DataRow row in dtUser.Rows) { if (txtEmail.Text == row[0].ToString()) { using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress("*****@*****.**"); mail.To.Add(txtEmail.Text); mail.Subject = "LMS - Password Reset"; mail.Body = "Dear " + Convert.ToString(entUser.UserName) + "," + "<br><br>Your Password Is :- " + Convert.ToString(entUser.Password) + "<br><br><i>Please don't reply, this is auto generated email</i>"; mail.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587)) { smtp.Credentials = new NetworkCredential("*****@*****.**", "Rus@17416"); smtp.EnableSsl = true; smtp.Send(mail); } } Response.Redirect("~/Content/Login.aspx"); } } lblErrorMesseage.Text = "Please enter registered Email address"; txtEmail.Text = ""; }
public UserENT SelectByPK(SqlInt32 UserID) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectByPK"; objCmd.Parameters.Add("@UserID", SqlDbType.Int).Value = UserID; #endregion Prepare Command #region Read Data and Set Controls UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { if (objSDR.HasRows) { while (objSDR.Read()) { if (!objSDR["UserName"].Equals(DBNull.Value)) { entUser.UserName = Convert.ToString(objSDR["UserName"]); } if (!objSDR["Password"].Equals(DBNull.Value)) { entUser.Password = Convert.ToString(objSDR["Password"]); } if (!objSDR["DisplayName"].Equals(DBNull.Value)) { entUser.DisplayName = Convert.ToString(objSDR["DisplayName"]); } if (!objSDR["MobileNo"].Equals(DBNull.Value)) { entUser.MobileNo = Convert.ToString(objSDR["MobileNo"]); } if (!objSDR["DOB"].Equals(DBNull.Value)) { entUser.DOB = Convert.ToString(objSDR["DOB"]); } if (!objSDR["Gender"].Equals(DBNull.Value)) { entUser.Gender = Convert.ToString(objSDR["Gender"]); } if (!objSDR["Email"].Equals(DBNull.Value)) { entUser.Email = Convert.ToString(objSDR["Email"]); } if (!objSDR["Experience"].Equals(DBNull.Value)) { entUser.Experience = Convert.ToString(objSDR["Experience"]); } if (!objSDR["Qualification"].Equals(DBNull.Value)) { entUser.Qualification = Convert.ToString(objSDR["Qualification"]); } if (!objSDR["City"].Equals(DBNull.Value)) { entUser.City = Convert.ToString(objSDR["City"]); } if (!objSDR["DepartmentID"].Equals(DBNull.Value)) { entUser.DepartmentID = Convert.ToInt32(objSDR["DepartmentID"]); } if (!objSDR["DesignationID"].Equals(DBNull.Value)) { entUser.DesignationID = Convert.ToInt32(objSDR["DesignationID"]); } if (!objSDR["InstituteID"].Equals(DBNull.Value)) { entUser.InstituteID = Convert.ToInt32(objSDR["InstituteID"]); } if (!objSDR["DepartmentName"].Equals(DBNull.Value)) { entUser.DepartmentName = Convert.ToString(objSDR["DepartmentName"]); } if (!objSDR["DesignationName"].Equals(DBNull.Value)) { entUser.DesignationName = Convert.ToString(objSDR["DesignationName"]); } if (!objSDR["InstituteName"].Equals(DBNull.Value)) { entUser.InstituteName = Convert.ToString(objSDR["InstituteName"]); } if (!objSDR["PhotoPath"].Equals(DBNull.Value)) { entUser.PhotoPath = Convert.ToString(objSDR["PhotoPath"]); } } return(entUser); } else { return(null); } } #endregion Read Data and Set Controls } catch (SqlException ex) { Message = ex.Message; return(null); } catch (Exception ex) { Message = ex.Message; return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
protected void btnLogin_Click(object sender, EventArgs e) { #region ServerSide Validatiion String strErrorMessage = ""; if (txtUserName.Text == "") { strErrorMessage += "Enter User Name<br/>"; } if (txtPassword.Text == "") { strErrorMessage += "Enter Password<br/>"; } if (strErrorMessage != "") { lblMessage.Text = strErrorMessage; divMessage.Visible = true; return; } #endregion ServerSide Validatiion #region Collect Data String UserName = txtUserName.Text.ToString(); String Password = txtPassword.Text.ToString(); UserENT entUser = new UserENT(); UserBAL balUser = new UserBAL(); entUser = balUser.SelectByUserPassword(UserName, Password); if (!entUser.UserID.IsNull) { Session["UserID"] = entUser.UserID.Value.ToString(); } if (!entUser.UserName.IsNull) { Session["UserName"] = entUser.UserName.Value.ToString(); } if (!entUser.UserID.IsNull) { #region Get AddressID AddressENT entAddress = new AddressENT(); AddressBAL balAddress = new AddressBAL(); entAddress = balAddress.GetAddressIDByUserID(entUser.UserID.Value); if (!entAddress.AddressID.IsNull) { Session["AddressID"] = entAddress.AddressID.Value; } #endregion Get AddressID } if (!entUser.UserID.IsNull) { if (entUser.UserType == "user") { Response.Redirect("~/User/Home.aspx"); } else { Response.Redirect("~/AdminPanel/Product/ProductList.aspx"); } } else { lblMessage.Text = "Enter Valid Name or Password"; divMessage.Visible = true; } #endregion Collect Data }
public UserENT SelectByUserNamePassword(SqlString UserName, SqlString Password) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectByUserNamePassword"; objCmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = UserName; objCmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = Password; #endregion Prepare Command #region Read Data and Set Controls UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { if (objSDR.HasRows) { while (objSDR.Read()) { if (!objSDR["UserID"].Equals(DBNull.Value)) { entUser.UserID = Convert.ToInt32(objSDR["UserID"]); } if (!objSDR["DesignationName"].Equals(DBNull.Value)) { entUser.DesignationName = Convert.ToString(objSDR["DesignationName"]); } if (!objSDR["DesignationID"].Equals(DBNull.Value)) { entUser.DesignationID = Convert.ToInt32(objSDR["DesignationID"]); } if (!objSDR["DisplayName"].Equals(DBNull.Value)) { entUser.DisplayName = Convert.ToString(objSDR["DisplayName"]); } if (!objSDR["PhotoPath"].Equals(DBNull.Value)) { entUser.PhotoPath = Convert.ToString(objSDR["PhotoPath"]); } } return(entUser); } else { return(null); } } #endregion Read Data and Set Controls } catch (SqlException ex) { Message = ex.Message; return(null); } catch (Exception ex) { Message = ex.Message; return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
protected void btnUpdateProfile_Click(object sender, EventArgs e) { #region Server Side Validation string strErrorMessage = ""; if (txtUserName.Text.Trim() == "") { strErrorMessage += "-Enter User Name <br />"; } if (txtDisplayName.Text.Trim() == "") { strErrorMessage += "-Enter Display Name <br />"; } if (txtMobileNo.Text.Trim() == "") { strErrorMessage += "-enter mobile number <br />"; } if (strErrorMessage.Trim() != "") { lblMessageProfile.Text = strErrorMessage; return; } #endregion Server Side Validation UserENT entUser = new UserENT(); #region Read Data if (txtUserName.Text.Trim() != "") { entUser.UserName = txtUserName.Text.ToString(); } if (txtDisplayName.Text.Trim() != "") { entUser.DisplayName = txtDisplayName.Text.ToString(); } if (txtMobileNo.Text.Trim() != "") { entUser.MobileNumber = txtMobileNo.Text.ToString(); } entUser.Address = txtAddress.Text.ToString(); entUser.UserID = Convert.ToInt32(Session["UserID"].ToString()); #endregion Read Data UserBAL balUser = new UserBAL(); if (balUser.UpdateByPK(entUser)) { lblMessageProfile.Text = "Updated Successfully"; divMessage.Visible = true; Session["UserName"] = txtUserName.Text; Session["DisplayName"] = txtDisplayName.Text; Session["Address"] = txtAddress.Text.ToString(); Session["MobileNo"] = txtMobileNo.Text.ToString(); profile(); } else { lblMessageProfile.Text = balUser.Message; } Response.Redirect("~/AdminPanel/Profile/Profile.aspx"); }
private void fillLabel(SqlInt32 UserID) { UserBAL balUser = new UserBAL(); UserENT entUser = new UserENT(); entUser = balUser.SelectByPK(Convert.ToInt32(Session["UserID"].ToString().Trim())); if (entUser != null) { if (!entUser.DepartmentName.IsNull) { lblDepartment.Text = entUser.DepartmentName.ToString().Trim(); } if (!entUser.DesignationName.IsNull) { lblDesignation.Text = entUser.DesignationName.ToString().Trim(); } if (!entUser.InstituteName.IsNull) { lblInstitute.Text = entUser.InstituteName.ToString().Trim(); } if (!entUser.Gender.IsNull) { if (entUser.Gender.ToString().Trim() == "Male") { lblGender.Text = "Male"; } if (entUser.Gender.ToString().Trim() == "Female") { lblGender.Text = "Female"; } } if (!entUser.UserName.IsNull) { lblUsername.Text = entUser.UserName.ToString().Trim(); } if (!entUser.DisplayName.IsNull) { lblDisplayname.Text = entUser.DisplayName.ToString().Trim(); } if (!entUser.MobileNo.IsNull) { lblMobileno.Text = entUser.MobileNo.ToString().Trim(); } if (!entUser.DOB.IsNull) { lblDOB.Text = entUser.DOB.ToString().Trim(); } if (!entUser.Email.IsNull) { lblEmail.Text = entUser.Email.ToString().Trim(); } if (!entUser.Experience.IsNull) { lblExperience.Text = entUser.Experience.ToString().Trim(); } if (!entUser.Qualification.IsNull) { lblQualification.Text = entUser.Qualification.ToString().Trim(); } if (!entUser.City.IsNull) { lblCity.Text = entUser.City.ToString().Trim(); } if (!entUser.PhotoPath.IsNull) { img.ImageUrl = entUser.PhotoPath.ToString().Trim(); } } else { PanelErrorMesseage.Visible = true; lblErrorMessage.Text = "missing data"; } }
private void fillControls(SqlInt32 UserID) { UserBAL balUser = new UserBAL(); UserENT entUser = new UserENT(); entUser = balUser.SelectByPK(Convert.ToInt32(Session["UserID"].ToString().Trim())); if (entUser != null) { if (!entUser.DepartmentID.IsNull) { ddlDepartment.SelectedValue = entUser.DepartmentID.ToString().Trim(); } if (Session["Select"].ToString() == "Employee") { if (!entUser.DesignationID.IsNull) { ddlDesignation.SelectedValue = entUser.DesignationID.ToString().Trim(); } PanelHOD.Visible = false; } else if (Session["Select"].ToString() == "HOD") { PanelEmployee.Visible = false; lblHOD.Text = "HOD"; ddlDesignation.SelectedValue = entUser.DesignationID.ToString().Trim(); } if (!entUser.InstituteID.IsNull) { ddlInstitute.SelectedValue = entUser.InstituteID.ToString().Trim(); } if (!entUser.Gender.IsNull) { if (entUser.Gender.ToString().Trim() == "Male") { rbMale.Checked = true; } if (entUser.Gender.ToString().Trim() == "Female") { rbFemale.Checked = true; } } if (!entUser.UserName.IsNull) { txtUsername.Text = entUser.UserName.ToString().Trim(); } if (!entUser.Password.IsNull) { txtPassword.Text = entUser.Password.ToString().Trim(); } if (!entUser.DisplayName.IsNull) { txtDisplayName.Text = entUser.DisplayName.ToString().Trim(); } if (!entUser.MobileNo.IsNull) { txtMobileNo.Text = entUser.MobileNo.ToString().Trim(); } if (!entUser.DOB.IsNull) { txtDOB.Text = entUser.DOB.ToString().Trim(); } if (!entUser.Email.IsNull) { txtEmail.Text = entUser.Email.ToString().Trim(); } if (!entUser.Experience.IsNull) { txtExperience.Text = entUser.Experience.ToString().Trim(); } if (!entUser.Qualification.IsNull) { txtQualification.Text = entUser.Qualification.ToString().Trim(); } if (!entUser.City.IsNull) { txtCity.Text = entUser.City.ToString().Trim(); } } else { lblErrorMessage.Text = "missing data"; } }
public UserENT SelectByUserNameAndPassword(SqlString UserName, SqlString Password) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectByUserNamePassword"; objCmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = UserName; objCmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = Password; UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { if (objSDR.HasRows) { while (objSDR.Read()) { if (!objSDR["UserID"].Equals(DBNull.Value)) { entUser.UserID = Convert.ToInt32(objSDR["UserID"].ToString().Trim()); } if (!objSDR["UserName"].Equals(DBNull.Value)) { entUser.UserName = objSDR["UserName"].ToString().Trim(); } if (!objSDR["DisplayName"].Equals(DBNull.Value)) { entUser.DisplayName = objSDR["DisplayName"].ToString().Trim(); } if (!objSDR["Address"].Equals(DBNull.Value)) { entUser.Address = objSDR["Address"].ToString().Trim(); } if (!objSDR["MobileNo"].Equals(DBNull.Value)) { entUser.MobileNumber = objSDR["MobileNo"].ToString().Trim(); } if (!objSDR["UserProfileImage"].Equals(DBNull.Value)) { entUser.UserProfileImage = objSDR["UserProfileImage"].ToString().Trim(); } } } } return(entUser); } catch (SqlException sqlex) { Message = sqlex.InnerException.ToString(); return(null); } catch (Exception ex) { Message = ex.InnerException.ToString(); return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
protected void btnSave_Click(object sender, EventArgs e) { #region Collect Data UserENT entUser = new UserENT(); LeaveTypeENT entLeaveType = new LeaveTypeENT(); DesignationENT entDesignation = new DesignationENT(); if (ddlDepartment.SelectedIndex > 0) { entUser.DepartmentID = Convert.ToInt32(ddlDepartment.SelectedValue); } if (ddlInstitute.SelectedIndex > 0) { entUser.InstituteID = Convert.ToInt32(ddlInstitute.SelectedValue); } if (ddlDesignation.SelectedIndex > 0) { entUser.DesignationID = Convert.ToInt32(ddlDesignation.SelectedValue); entDesignation.DesignationID = Convert.ToInt32(ddlDesignation.SelectedValue); } if (rbFemale.Checked != false) { entUser.Gender = rbFemale.Text.Trim(); } if (rbMale.Checked != false) { entUser.Gender = rbMale.Text.Trim(); } if (txtUsername.Text.Trim() != "") { entUser.UserName = txtUsername.Text.Trim(); } if (txtPassword.Text.Trim() != "") { entUser.Password = txtPassword.Text.Trim(); } if (txtDisplayName.Text.Trim() != "") { entUser.DisplayName = txtDisplayName.Text.Trim(); } if (txtMobileNo.Text.Trim() != "") { entUser.MobileNo = txtMobileNo.Text.Trim(); } if (txtDOB.Text.Trim() != "") { entUser.DOB = txtDOB.Text.Trim(); } if (txtEmail.Text.Trim() != "") { entUser.Email = txtEmail.Text.Trim(); } if (txtExperience.Text.Trim() != "") { entUser.Experience = txtExperience.Text.Trim(); } if (txtQualification.Text.Trim() != "") { entUser.Qualification = txtQualification.Text.Trim(); } if (txtCity.Text.Trim() != "") { entUser.City = txtCity.Text.Trim(); } if (fuStaffPhoto.HasFile) { string strFileLocationSave = "~/Content/assets/images/"; string strPhysicalPath = ""; strPhysicalPath = Server.MapPath(strFileLocationSave); strPhysicalPath += fuStaffPhoto.FileName; strFileLocationSave += fuStaffPhoto.FileName; if (File.Exists(strPhysicalPath)) { File.Delete(strPhysicalPath); } fuStaffPhoto.SaveAs(strPhysicalPath); entUser.PhotoPath = strFileLocationSave; } #endregion Collect Data UserBAL balUser = new UserBAL(); LeaveTypeBAL balLeaveType = new LeaveTypeBAL(); DesignationBAL balDesignation = new DesignationBAL(); entDesignation = balDesignation.SelectByPK(entDesignation.DesignationID); if (Session["UserID"] == null) { if (entDesignation.DesignationName == "HOD") { balUser.Insert(entUser); entUser = balUser.SelectByPK(entUser.UserID); clearSelection(); lblSuccess.Text = "Data Inserted Successfully"; } else if (entDesignation.DesignationName != "HOD") { balUser.Insert(entUser); if (entUser.UserID > 0) { entLeaveType.UserID = entUser.UserID; entUser = balUser.SelectByPK(entUser.UserID); } else { lblErrorMessage.Text = "empty"; return; } entLeaveType.LeaveType = "Casual Leave"; entLeaveType.TotalDays = 25; balLeaveType.Insert(entLeaveType); entLeaveType.LeaveType = "Medical Leave"; entLeaveType.TotalDays = 15; balLeaveType.Insert(entLeaveType); entLeaveType.LeaveType = "LOP"; entLeaveType.TotalDays = 10; balLeaveType.Insert(entLeaveType); entLeaveType.LeaveType = "Other Leave"; entLeaveType.TotalDays = 5; balLeaveType.Insert(entLeaveType); clearSelection(); lblSuccess.Text = "Data Inserted Successfully"; } else { lblErrorMessage.Text = balUser.Message; } using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress("*****@*****.**"); mail.To.Add(entUser.Email.ToString()); mail.Subject = "User Created Successfully !!"; mail.Body = "<h3>You can now login into Leave management system</h3><br>" + "Your Username Is :- " + Convert.ToString(entUser.UserName) + "<br>Your Password Is :- " + Convert.ToString(entUser.Password) + "<br><br><i>Please don't reply, this is auto generated email</i>"; mail.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587)) { smtp.Credentials = new NetworkCredential("*****@*****.**", "password"); smtp.EnableSsl = true; smtp.Send(mail); } } } else { entUser.UserID = Convert.ToInt32(Session["UserID"].ToString().Trim()); if (balUser.Update(entUser)) { if (Session["Select"].ToString() == "Employee") { Response.Redirect("~/Content/Home/Employee_Home.aspx"); } else if (Session["Select"].ToString() == "HOD") { Response.Redirect("~/Content/Home/HOD_Home.aspx"); } } else { lblErrorMessage.Text = balUser.Message; } } }
private void fillSession() { UserBAL balUser = new UserBAL(); UserENT entUser = new UserENT(); #region Local Variables SqlString strUserName = SqlString.Null; SqlString strPassword = SqlString.Null; string strError = ""; #endregion #region Server Side Validation if (txtUserName.Text.Trim() == "") { strError += "Enter UserName </br>"; } if (txtPassword.Text.Trim() == "") { strError += "Enter Password </br>"; } if (strError.Trim() != "") { lblErrorMesseage.Text = strError; return; } #endregion #region Read Form Value if (txtUserName.Text.Trim() != "") { strUserName = txtUserName.Text.Trim(); } if (txtPassword.Text.Trim() != "") { strPassword = txtPassword.Text.Trim(); } #endregion if (strUserName == "admin" && strPassword == "admin") { Session["Select"] = "Admin"; Response.Redirect("~/Content/Institute/InstituteList.aspx"); return; } entUser = balUser.SelectByUserNamePassword(strUserName, strPassword); if (entUser != null) { if (!entUser.UserID.IsNull) { Session["UserID"] = entUser.UserID; } if (!entUser.DisplayName.IsNull) { Session["DisplayName"] = entUser.DisplayName; } if (!entUser.PhotoPath.IsNull) { Session["PhotoPath"] = entUser.PhotoPath; } if (entUser.DesignationName == "HOD") { Session["Select"] = "HOD"; Response.Redirect("~/Content/Home/HOD_Home.aspx"); } else { Session["Select"] = "Employee"; Response.Redirect("~/Content/Home/Employee_Home.aspx"); } } else { lblErrorMesseage.Text = "Either Username Or PAssword Is Invalid"; } }
public UserENT SelectByUserPassword(String UserName, String password) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region Prepare command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_User_SelectByUserPassword"; objCmd.Parameters.AddWithValue("@UserName", UserName); objCmd.Parameters.AddWithValue("@Password", password); #endregion Prepare command #region Read Data and Set Controls UserENT entUser = new UserENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { while (objSDR.Read()) { if (!objSDR["UserID"].Equals(DBNull.Value)) { entUser.UserID = Convert.ToInt32(objSDR["UserID"]); } if (!objSDR["UserName"].Equals(DBNull.Value)) { entUser.UserName = Convert.ToString(objSDR["UserName"]); } if (!objSDR["Email"].Equals(DBNull.Value)) { entUser.Email = Convert.ToString(objSDR["Email"]); } if (!objSDR["UserType"].Equals(DBNull.Value)) { entUser.UserType = Convert.ToString(objSDR["UserType"]); } if (!objSDR["Password"].Equals(DBNull.Value)) { entUser.Password = Convert.ToString(objSDR["Password"]); } } } return(entUser); #endregion Read Data and Set Controls } catch (SqlException sqlex) { Message = sqlex.InnerException.Message.ToString(); return(null); } catch (Exception ex) { Message = ex.InnerException.Message.ToString(); return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }