protected void btnEdit_Click(object sender, EventArgs e) { Attendance.Entities.UserInfo objInfo = new UserInfo(); try { txtEditEmpID.Text = lblEditEmpID.Text; txtEditFirstname.Text = lblEditFirstname.Text; txtEditLastname.Text = lblEditLastname.Text; txtEditStartDate.Text = lblEditStartDate.Text; txtEditDesg.Text = lblEditDesg.Text; //ddlEditDepart.SelectedIndex = ; ddlEditDepart.SelectedIndex = ddlEditDepart.Items.IndexOf(ddlEditDepart.Items.FindByText(lblEditDepartmentName.Text.Trim())); if (lblActive.Text.Trim() == "Yes") { rdEditActiveTrue.Checked = true; rdEditActiveFalse.Checked = false; lblEdit1TermDate.Visible = false; // txtEditTermDate.Text = lblEditTermDate.Text; txtEditTermDate.Visible = false; lblEdit1Termreason.Visible = false; // txtEdit1TermReason.Text = txtReason.Text; txtEdit1TermReason.Visible = false; // txtEdit1TermReason.Enabled = true; } else { rdEditActiveFalse.Checked = true; rdEditActiveTrue.Checked = false; lblEdit1TermDate.Visible = true; txtEditTermDate.Text = lblEditTermDate.Text; txtEditTermDate.Visible = true; lblEdit1Termreason.Visible = true; txtEdit1TermReason.Text = txtReason.Text; txtEdit1TermReason.Visible = true; txtEdit1TermReason.Enabled = true; } if (txtEditStartDate.Text == "") { txtEditStartDate.Enabled = true; } else { txtEditStartDate.Enabled = false; } viewPopup.Style["display"] = "none"; Editpopup.Style["display"] = "block"; btnEdit.Visible = false; btnUpdate.Visible = true; btnEditCancel.Visible = true; Image1.ImageUrl = "~/Photos/" + hdnPhotLink.Value.Trim(); } catch (Exception ex) { } }
protected void btnAdd_Click(object sender, EventArgs e) { Attendance.Entities.UserInfo objInfo = new UserInfo(); Attendance.Entities.EmergencyContactInfo objContactInfo = new EmergencyContactInfo(); try { Attendance.BAL.Report obj = new Report(); objInfo.Firstname = txtAddFirstName.Text == "" ? "" : GeneralFunction.ToProper(txtAddFirstName.Text.Trim()).Trim(); objInfo.Lastname = txtAddLastName.Text == "" ? "" : GeneralFunction.ToProper(txtAddLastName.Text.Trim()).Trim(); string PhotoLink = "defaultUSer.jpg"; try { if (photoUpload.HasFile) { string filePhotoName = photoUpload.FileName; string Photoextension = System.IO.Path.GetExtension(filePhotoName); if (Photoextension == ".jpg" || Photoextension == ".png" || Photoextension == ".jpeg" || Photoextension == ".JPG" || Photoextension == ".PNG" || Photoextension == ".JPEG") { string SaveFileLoc = Server.MapPath("~/Photos/"); if (System.IO.Directory.Exists(SaveFileLoc) == false) { System.IO.Directory.CreateDirectory(SaveFileLoc); } string FileNameSaveData = SaveFileLoc + (objInfo.Firstname.Trim() + objInfo.Lastname.Trim()).Trim() + ".jpeg"; PhotoLink = (objInfo.Firstname.Trim() + objInfo.Lastname.Trim()).Trim() + ".jpeg"; photoUpload.SaveAs(FileNameSaveData); Bitmap oBitmap = default(Bitmap); oBitmap = new Bitmap(FileNameSaveData); Graphics oGraphic = default(Graphics); int newwidthimg = 140; // Here create a new bitmap object of the same height and width of the image. //float AspectRatio = (float)oBitmap.Size.Width / (float)oBitmap.Size.Height; //int newHeight = Convert.ToInt32(newwidthimg / AspectRatio); int newHeight = 140; Bitmap bmpNew = new Bitmap(newwidthimg, newHeight); oGraphic = Graphics.FromImage(bmpNew); oGraphic.CompositingQuality = CompositingQuality.HighQuality; oGraphic.SmoothingMode = SmoothingMode.HighQuality; oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphic.DrawImage(oBitmap, new Rectangle(0, 0, bmpNew.Width, bmpNew.Height), 0, 0, oBitmap.Width, oBitmap.Height, GraphicsUnit.Pixel); // Release the lock on the image file. Of course, // image from the image file is existing in Graphics object oBitmap.Dispose(); oBitmap = bmpNew; //SolidBrush oBrush = new SolidBrush(Color.Black); //Font ofont = new Font("Arial", 8); //oGraphic.DrawString("Some text to write", ofont, oBrush, 10, 10); //oGraphic.Dispose(); //ofont.Dispose(); //oBrush.Dispose(); oBitmap.Save(FileNameSaveData, ImageFormat.Jpeg); oBitmap.Dispose(); } } } catch (Exception ex) { System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('File access denied');", true); } int UserID = Convert.ToInt32(Session["UserID"]); //objInfo.EmpID = txtAddEmpID.Text.Trim(); objInfo.Deptname = ddlDeptment.SelectedItem.Text.ToString(); objInfo.Designation = txtDesignation.Text == "" ? "" : GeneralFunction.ToProper(txtDesignation.Text.Trim()); objInfo.ScheduleID = Convert.ToInt32(ddlSchedule.SelectedItem.Value); objInfo.StartDt = txtStartDt.Text == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(txtStartDt.Text); if (rdActiveFalse.Checked == true) { objInfo.IsActive = false; } else { objInfo.IsActive = true; } if (rdGenderMale.Checked == true) { objInfo.Gender = "Male"; } else { objInfo.Gender = "Female"; } if (rdMarriedSingle.Checked == true) { objInfo.MaritalID = 1; } else { objInfo.MaritalID = 2; } objInfo.DateOfBirth = txtDateOfBirth.Text.ToString() == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(txtDateOfBirth.Text); objInfo.Phone = txtEmpPhone.Text; objInfo.Mobile = txtEmpMobile.Text; objInfo.BusinessEmail = txtBusinessEmail.Text; objInfo.PersonalEmail = txtPersonalEmail.Text; objInfo.WageID = Convert.ToInt32(ddlWagetype.SelectedItem.Value); objInfo.Salary = txtsalary.Text.Trim(); objInfo.Deductions = Convert.ToInt32(ddlDeductions.SelectedItem.Value); objInfo.County = txtCounty.Text.Trim(); objContactInfo.Person1 = txtCn1Name.Text.ToString() == "" ? "" : GeneralFunction.ToProper(txtCn1Name.Text.ToString().Trim()); objContactInfo.P1Address1 = GeneralFunction.ToProperNotes(txtCn1Address1.Text.ToString().Trim()); objContactInfo.P1Address2 = GeneralFunction.ToProperNotes(txtCn1Address2.Text.ToString().Trim()); objContactInfo.Phone1 = txtCn1Phone.Text.ToString().Trim(); objContactInfo.Relation1 = GeneralFunction.ToProperNotes(txtCn1Relation.Text.ToString().Trim()); objContactInfo.Email1 = txtCn1Email.Text.ToString().Trim(); objContactInfo.StateID1 = Convert.ToInt32(ddlCn1State.SelectedItem.Value); // objContactInfo.Zip1 = txtCn1Zip.Text.Trim(); if (txtCn1Zip.Text != "" && txtCn1Zip.Text.Trim().Length == 4) { objContactInfo.Zip1 = "0" + txtCn1Zip.Text.Trim(); } else { objContactInfo.Zip1 = txtCn1Zip.Text.Trim(); } objContactInfo.Person2 = txtCn2Name.Text.ToString() == "" ? "" : GeneralFunction.ToProper(txtCn2Name.Text.ToString().Trim()); objContactInfo.P2Address1 = GeneralFunction.ToProperNotes((txtCn2Address1.Text.ToString().Trim())); objContactInfo.P2Address2 = GeneralFunction.ToProperNotes(txtCn2Address2.Text.ToString().Trim()); objContactInfo.Phone2 = txtCn2Phone.Text.ToString().Trim(); objContactInfo.Relation2 = GeneralFunction.ToProperNotes(txtCn2Relation.Text.ToString().Trim()); objContactInfo.Email2 = txtCn2Email.Text.ToString().Trim(); objContactInfo.StateID2 = Convert.ToInt32(ddlCn2State.SelectedItem.Value); if (txtCn2Zip.Text != "" && txtCn2Zip.Text.Trim().Length == 4) { objContactInfo.Zip2 = "0" + txtCn2Zip.Text.Trim(); } else { objContactInfo.Zip2 = txtCn2Zip.Text.Trim(); } objContactInfo.Person3 = txtCn3Name.Text.ToString() == "" ? "" : GeneralFunction.ToProper(txtCn3Name.Text.ToString().Trim()); objContactInfo.P3Address1 = GeneralFunction.ToProperNotes(txtCn3Address1.Text.ToString().Trim()); objContactInfo.P3Address2 = GeneralFunction.ToProperNotes(txtCn3Address2.Text.ToString().Trim()); objContactInfo.Phone3 = txtCn3Phone.Text.ToString().Trim(); objContactInfo.Relation3 = GeneralFunction.ToProperNotes(txtCn3Relation.Text.ToString().Trim()); objContactInfo.Email3 = txtCn3Email.Text.ToString().Trim(); objContactInfo.StateID3 = Convert.ToInt32(ddlCn3State.SelectedItem.Value); if (txtCn3Zip.Text != "" && txtCn3Zip.Text.Trim().Length == 4) { objContactInfo.Zip3 = "0" + txtCn3Zip.Text.Trim(); } else { objContactInfo.Zip3 = txtCn3Zip.Text.Trim(); } string LocationName = ddlLocation.SelectedItem.Text.ToString().Trim(); if (LocationName.Trim().ToUpper() == "INBH" || LocationName.Trim().ToUpper() == "INDG") { objInfo.SSN = ""; } else { objInfo.SSN = txtEmpSSN.Text.Trim(); } objInfo.Address1 = GeneralFunction.ToProperNotes(txtEmpAddress1.Text.ToString().Trim()); objInfo.Address2 = GeneralFunction.ToProperNotes(txtEmpAddress2.Text.ToString().Trim()); objInfo.StateID = Convert.ToInt32(ddlEmpState.SelectedItem.Value); if (txtEmpZip.Text != "" && txtEmpZip.Text.Trim().Length == 4) { objInfo.Zip = "0" + txtEmpZip.Text.Trim(); } else { objInfo.Zip = txtEmpZip.Text.Trim(); } objInfo.DriverLicense = txtEmpDriveLicense.Text.Trim(); objInfo.EmpTypeID = Convert.ToInt32(ddlEmpType.SelectedItem.Value); if (objInfo.SSN != "") { if (obj.CheckUniqueSSN(objInfo.SSN.Trim())) { bool bnew = obj.AddUser(objInfo, objContactInfo, UserID, LocationName, PhotoLink); if (bnew) { txtAddFirstName.Text = ""; txtAddLastName.Text = ""; txtBusinessEmail.Text = ""; txtDateOfBirth.Text = ""; txtDesignation.Text = ""; txtEmpAddress1.Text = ""; txtEmpAddress2.Text = ""; txtEmpDriveLicense.Text = ""; txtEmpMobile.Text = ""; txtEmpPhone.Text = ""; txtEmpSSN.Text = ""; txtEmpZip.Text = ""; txtCn1Address1.Text = ""; txtCn1Address2.Text = ""; txtCn1Email.Text = ""; txtCn1Name.Text = ""; txtCn1Phone.Text = ""; txtCn1Relation.Text = ""; txtCn2Address1.Text = ""; txtCn2Address2.Text = ""; txtCn2Email.Text = ""; txtCn2Name.Text = ""; txtCn2Phone.Text = ""; txtCn2Relation.Text = ""; txtCn3Address1.Text = ""; txtCn3Address2.Text = ""; txtCn3Email.Text = ""; txtCn3Name.Text = ""; txtCn3Phone.Text = ""; txtCn3Relation.Text = ""; ddlDeptment.SelectedIndex = 0; ddlEmpState.SelectedIndex = 0; ddlEmpType.SelectedIndex = 0; ddlSchedule.SelectedIndex = 0; mdlAddPopUp.Hide(); GetUserDetails(Convert.ToInt32(Session["SortBy"]),ddlLocation.SelectedItem.Text.ToString().Trim()); } } else { lblError.Visible = true; lblError.Text = "Employee details are not added. SSN is already existed"; txtEmpSSN.Text = ""; txtEmpSSN.Focus(); mdlAddPopUp.Show(); } } else { bool bnew = obj.AddUser(objInfo, objContactInfo, UserID, LocationName, PhotoLink); if (bnew) { txtAddFirstName.Text = ""; txtAddLastName.Text = ""; txtBusinessEmail.Text = ""; txtDateOfBirth.Text = ""; txtDesignation.Text = ""; txtEmpAddress1.Text = ""; txtEmpAddress2.Text = ""; txtEmpDriveLicense.Text = ""; txtEmpMobile.Text = ""; txtEmpPhone.Text = ""; txtEmpSSN.Text = ""; txtEmpZip.Text = ""; txtCn1Address1.Text = ""; txtCn1Address2.Text = ""; txtCn1Email.Text = ""; txtCn1Name.Text = ""; txtCn1Phone.Text = ""; txtCn1Relation.Text = ""; txtCn2Address1.Text = ""; txtCn2Address2.Text = ""; txtCn2Email.Text = ""; txtCn2Name.Text = ""; txtCn2Phone.Text = ""; txtCn2Relation.Text = ""; txtCn3Address1.Text = ""; txtCn3Address2.Text = ""; txtCn3Email.Text = ""; txtCn3Name.Text = ""; txtCn3Phone.Text = ""; txtCn3Relation.Text = ""; ddlDeptment.SelectedIndex = 0; ddlEmpState.SelectedIndex = 0; ddlEmpType.SelectedIndex = 0; ddlSchedule.SelectedIndex = 0; mdlAddPopUp.Hide(); GetUserDetails(Convert.ToInt32(Session["SortBy"]),ddlLocation.SelectedItem.Text.ToString()); } } } catch (Exception ex) { //System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('"+ex.ToString()+"');", true); } }
protected void btnSalEdit_Click(object sender, EventArgs e) { try { Attendance.Entities.UserInfo objInfo = new UserInfo(); objInfo.WageID = Convert.ToInt32(ddlEditWage.SelectedIndex); objInfo.Deductions = Convert.ToInt32(ddlDeductions.SelectedIndex); objInfo.Salary = txtEditSal.Text.Trim(); if (rdSingle.Checked) { objInfo.MaritalID = 1; } else { objInfo.MaritalID = 2; } int UserID = Convert.ToInt32(Session["UserID"]); int EmployeeID = Convert.ToInt32(hdnUserID.Value); String strHostName = Request.UserHostAddress.ToString(); string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); Attendance.BAL.Report obj = new Report(); bool bnew = obj.UpdateUserSalTaxDetails(objInfo, EmployeeID, UserID, strIp); ddlDeductions.SelectedIndex = 0; txtEditSal.Text = ""; ddlEditWage.SelectedIndex = 0; rdSingle.Checked = true; //Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); GetEmpDet(EmployeeID); mdlEditSalTaxPopup.Hide(); } catch (Exception ex) { } }
protected void btnUpdatePersonal_Click(object sender, EventArgs e) { try { Attendance.Entities.UserInfo objInfo = new UserInfo(); int UserID = Convert.ToInt32(Session["UserID"]); int EmployeeID = Convert.ToInt32(hdnUserID.Value); String strHostName = Request.UserHostAddress.ToString(); string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); if (rdMale.Checked == true) { objInfo.Gender = "Male"; } else { objInfo.Gender = "Female"; } objInfo.DateOfBirth = txtDatBirth.Text.ToString() == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(Convert.ToDateTime(txtDatBirth.Text.Trim()).ToString("MM/dd/yyyy")); objInfo.Phone = txtEmpPhone.Text; objInfo.Mobile = txtEmpMobile.Text; objInfo.BusinessEmail = txtBusinessEmail.Text; objInfo.PersonalEmail = txtPersonalEmail.Text; string LocationName = ViewState["Location"].ToString().Trim(); if (LocationName.Trim().ToUpper() == "INBH" || LocationName.Trim().ToUpper() == "INDG") { objInfo.SSN = ""; } else { objInfo.SSN = txtSSN.Text.Trim(); } objInfo.Address1 = GeneralFunction.ToProperNotes(txtAddress1.Text.ToString().Trim()); objInfo.Address2 = GeneralFunction.ToProperNotes(txtAddress2.Text.ToString().Trim()); objInfo.StateID = Convert.ToInt32(ddlState.SelectedItem.Value); objInfo.County = txtCounty.Text; if (txtZip.Text != "" && txtZip.Text.Trim().Length == 4) { objInfo.Zip = "0" + txtZip.Text.Trim(); } else { objInfo.Zip = txtZip.Text.Trim(); } objInfo.DriverLicense = txtDriving.Text.Trim(); Attendance.BAL.Report obj = new Report(); obj.UpdatePersonalDetails(objInfo, UserID, EmployeeID, strIp); GetEmpDet(EmployeeID); mdlEditPersonalDetails.Hide(); } catch (Exception ex) { } }
protected void btnUpdate_Click(object sender, EventArgs e) { Attendance.Entities.UserInfo objInfo = new UserInfo(); string timezone = ""; try { if (Convert.ToInt32(Session["TimeZoneID"]) == 2) { timezone = "Eastern Standard Time"; } else { timezone = "India Standard Time"; } DateTime ISTTime = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone)); var CurentDatetime = ISTTime; hdnToday.Value = ISTTime.ToString("MM/dd/yyyy"); btnUpdate.Attributes.Add("Enabled", "False"); int UserID = Convert.ToInt32(Session["UserID"]); int EmployeeID = Convert.ToInt32(hdnUserID.Value); objInfo.Firstname = txtEditFirstname.Text == "" ? "" : GeneralFunction.ToProper(txtEditFirstname.Text.Trim()); objInfo.Lastname = txtEditLastname.Text == "" ? "" : GeneralFunction.ToProper(txtEditLastname.Text.Trim()); objInfo.BLastname = txtEditBLname.Text == "" ? txtEditFirstname.Text.Trim() : GeneralFunction.ToProper(txtEditBLname.Text.Trim()); objInfo.BFirstname = txtEditBFname.Text == "" ? txtEditLastname.Text.Trim() : GeneralFunction.ToProper(txtEditBFname.Text.Trim()); string PhotoLink = imgPhoto.ImageUrl.Replace("~/Photos/", "").Trim(); try { if (photoUpload1.HasFile) { string filePhotoName = photoUpload1.FileName; string Photoextension = System.IO.Path.GetExtension(filePhotoName); if (Photoextension == ".jpg" || Photoextension == ".png" || Photoextension == ".jpeg" || Photoextension == ".JPG" || Photoextension == ".PNG" || Photoextension == ".JPEG") { string SaveFileLoc = Server.MapPath("~/Photos/"); if (System.IO.Directory.Exists(SaveFileLoc) == false) { System.IO.Directory.CreateDirectory(SaveFileLoc); } string FileNameSaveData = SaveFileLoc + (objInfo.Firstname.Trim() + objInfo.Lastname.Trim()).Trim() + ".jpeg"; PhotoLink = (objInfo.Firstname.Trim() + objInfo.Lastname.Trim()).Trim() + ".jpeg"; photoUpload1.SaveAs(FileNameSaveData); Bitmap oBitmap = default(Bitmap); oBitmap = new Bitmap(FileNameSaveData); Graphics oGraphic = default(Graphics); int newwidthimg = 140; // Here create a new bitmap object of the same height and width of the image. // float AspectRatio = (float)oBitmap.Size.Width / (float)oBitmap.Size.Height; int newHeight = 140; Bitmap bmpNew = new Bitmap(newwidthimg, newHeight); oGraphic = Graphics.FromImage(bmpNew); oGraphic.CompositingQuality = CompositingQuality.HighQuality; oGraphic.SmoothingMode = SmoothingMode.HighQuality; oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphic.DrawImage(oBitmap, new Rectangle(0, 0, bmpNew.Width, bmpNew.Height), 0, 0, oBitmap.Width, oBitmap.Height, GraphicsUnit.Pixel); // Release the lock on the image file. Of course, // image from the image file is existing in Graphics object oBitmap.Dispose(); oBitmap = bmpNew; //SolidBrush oBrush = new SolidBrush(Color.Black); //Font ofont = new Font("Arial", 8); //oGraphic.DrawString("Some text to write", ofont, oBrush, 10, 10); //oGraphic.Dispose(); //ofont.Dispose(); //oBrush.Dispose(); oBitmap.Save(FileNameSaveData, ImageFormat.Jpeg); oBitmap.Dispose(); } } } catch (Exception ex) { System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('File access denied');", true); } //objInfo.Lastname = GeneralFunction.ToProper(txtEditLastname.Text.Trim()); objInfo.ScheduleID = Convert.ToInt32(ddlSchedule.SelectedItem.Value); objInfo.EmpTypeID = Convert.ToInt32(ddlEmpType.SelectedItem.Value); objInfo.Deptname = ddlEditDepart.SelectedItem.Text.ToString(); objInfo.Designation = GeneralFunction.ToProper(txtEditDesg.Text.Trim()); objInfo.StartDt = txtEditStartDate.Text == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(txtEditStartDate.Text); objInfo.TermDt = txtEditTermDate.Text == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(txtEditTermDate.Text); objInfo.TermReason = txtEdit1TermReason.Text.Trim(); if (rdEditActiveFalse.Checked == true) { objInfo.IsActive = false; } else { objInfo.IsActive = true; objInfo.TermDt = Convert.ToDateTime("01/01/1900"); objInfo.TermReason = ""; } Attendance.BAL.Report obj = new Report(); String strHostName = Request.UserHostAddress.ToString(); string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); bool bnew = obj.UpdateUser(objInfo, EmployeeID, UserID, PhotoLink, strIp); if (bnew) { btnUpdate.Enabled = true; btnEditCancel.Enabled = true; mdlEditPopup.Hide(); txtEdit1TermReason.Text = ""; txtEditTermDate.Text = ""; txtEditDesg.Text = ""; txtEditEmpID.Text = ""; txtEditFirstname.Text = ""; txtEditLastname.Text = ""; txtEditStartDate.Text = ""; ddlEditDepart.SelectedIndex = 0; ddlEmpType.SelectedIndex = 0; ddlSchedule.SelectedIndex = 0; GetEmpDet(EmployeeID); } } catch (Exception ex) { } }