private void btnDelete_Click(object sender, EventArgs e) { if (selectedRecordId != 0) { try { Cursor = Cursors.WaitCursor; DesignationBAL _objBAL = new DesignationBAL(); _objBAL.DeleteDesignation(selectedRecordId); MessageBox.Show("Record has been deleted successfully!"); FillGrid(); } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number == 547) { MessageBox.Show("You cannot delete this record. Its refference exists in other documents."); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor = Cursors.Default; MakeEmpty(); } } }
protected void gvDesignation_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRecord") { if (e.CommandArgument != null) { DesignationBAL balDesignation = new DesignationBAL(); if (balDesignation.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim()))) { FillGridViewDesignation(); } else { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balDesignation.Message; } } } else if (e.CommandName == "EditRecord") { if (e.CommandArgument != null) { Response.Redirect(e.CommandArgument.ToString().Trim()); } } }
protected void btnSave_Click(object sender, EventArgs e) { #region Server Side Validation String strError = ""; if (txtDesignationName.Text.Trim() == "") { strError += "Enter Designation +</br>"; } if (strError.Trim() != "") { PanelErrorMesseage.Visible = true; lblErrorMessage.Text = strError; return; } #endregion Server Side Validation #region Collect Data DesignationENT entDesignation = new DesignationENT(); if (txtDesignationName.Text.Trim() != "") { entDesignation.DesignationName = txtDesignationName.Text.Trim(); } #endregion Collect Data DesignationBAL balDesignation = new DesignationBAL(); if (Request.QueryString["DesignationID"] == null) { if (balDesignation.Insert(entDesignation)) { clearSelection(); PanelSuccess.Visible = true; lblSuccess.Text = "Data Inserted Succesfully"; } else { PanelErrorMesseage.Visible = true; lblErrorMessage.Text = balDesignation.Message; } } else { entDesignation.DesignationID = Convert.ToInt32(Request.QueryString["DesignationID"].ToString().Trim()); if (balDesignation.Update(entDesignation)) { Response.Redirect("~/Content/Designation/DesignationList.aspx"); } else { PanelErrorMesseage.Visible = true; lblErrorMessage.Text = balDesignation.Message; } } }
public static void SelectWithoutHODForDropDownList(DropDownList ddl) { DesignationBAL balDesignation = new DesignationBAL(); ddl.DataSource = balDesignation.SelectWithoutHODForDropDownList(); ddl.DataValueField = "DesignationID"; ddl.DataTextField = "DesignationName"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem(" --Select Designation--", "-1")); }
private void fillControls(SqlInt32 DesignationID) { DesignationBAL balDesignation = new DesignationBAL(); DesignationENT entDesignation = new DesignationENT(); entDesignation = balDesignation.SelectByPK(DesignationID); if (!entDesignation.DesignationName.IsNull) { txtDesignationName.Text = entDesignation.DesignationName.Value.ToString(); } }
//private void DayLoad() //{ // cmbRestDay.Items.Add("Monday"); // cmbRestDay.Items.Add("Tuseday"); // cmbRestDay.Items.Add("Wednesday"); // cmbRestDay.Items.Add("Thursday"); // cmbRestDay.Items.Add("Friday"); // cmbRestDay.Items.Add("Saturday"); // cmbRestDay.Items.Add("Sunday"); //} private void FillDesignationList() { DesignationBAL _objBAL = new DesignationBAL(); List <DesignationModel> DesignationList = new List <DesignationModel>(); DesignationList = _objBAL.GetDesignationList(); cmbDesignation.DataSource = DesignationList; cmbDesignation.DisplayMember = "_DesgName"; cmbDesignation.ValueMember = "_DesgID"; cmbDesignation.SelectedIndex = -1; cmbDesignation.Text = "Select Designation"; }
private void FillGridViewDesignation() { DesignationBAL balDesignation = new DesignationBAL(); DataTable dtDesignation = new DataTable(); dtDesignation = balDesignation.SelectAll(); if (dtDesignation != null && dtDesignation.Rows.Count > 0) { gvDesignation.DataSource = dtDesignation; gvDesignation.DataBind(); } }
private void FillForm(Int32 _DesgID) { try { DesignationBAL _objBAL = new DesignationBAL(); DesignationModel _objModel = _objBAL.SearchDesignation(_DesgID); tbxDesignationName.Text = _objModel._DesgName; tbxDescription.Text = _objModel._Description; tbxModifiedDate.Text = _objModel._ModifiedDate.ToString(); cmbIsActive.SelectedIndex = (_objModel._IsActive == true) ? 0 : 1; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void FillGrid() { DesignationBAL _objBAL = new DesignationBAL(); List <DesignationModel> DesignationList = new List <DesignationModel>(); grdDesignation.DataSource = null; grdDesignation.Rows.Clear(); DesignationList = _objBAL.GetDesignationList(); grdDesignation.AutoGenerateColumns = false; int count = 0; foreach (var item in DesignationList) { count++; grdDesignation.Rows.Add(item._DesgID, item._DesgName, (item._IsActive == true) ? "Active" : "Deactive", item._ModifiedDate.ToShortDateString(), item._Description); } tbxCount.Text = count.ToString(); }
private void btnSave_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { if (validate() == true) { DesignationBAL _objBAL = new DesignationBAL(); DesignationModel _objModel = new DesignationModel(); _objModel._DesgID = selectedRecordId; _objModel._DesgName = tbxDesignationName.Text; _objModel._Description = tbxDescription.Text; _objModel._ModifiedDate = DateTime.Now; _objModel._IsActive = (cmbIsActive.SelectedIndex == 0) ? true : false; if (selectedRecordId == 0) { _objBAL.SaveDesignation(_objModel); } else { _objBAL.UpdateDesignation(_objModel); } MakeEmpty(); MessageBox.Show("Record Saved Successfully!"); FillGrid(); } } catch { } finally { Cursor = Cursors.Default; } }
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; } } }