public void SetEmpStatusByUsername(string username, string password, string Username, bool isactive) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VEmployeesRepository vempir = new VEmployeesRepository(); Employee emp = vempir.FindByuserName2(Username); if (isactive == true) { emp.Status = "0".ToInt(); } else { emp.Status = "1".ToInt(); } vempir.Saveemp(emp); } else { } } else { } }
public void UpdateEmployeeByID(string username, string password, int EmpID, Employee emp) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VEmployeesRepository vempir = new VEmployeesRepository(); Employee employee = vempir.FindByid2(EmpID); vempir.Saveemp(emp); } else { } } else { } }
protected void Button1_Click(object sender, EventArgs e) { if (lblempid.Text.Length > 0) { try { string serverpath = Server.MapPath(Request.ApplicationPath) + @"\file\" + PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName; string filename = PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName; VEmployeesRepository vLecir = new VEmployeesRepository(); if (vLecir.FindByLinkUrl(filename) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadrepeat, Color.Red); return; } else { if (FileUpload1.FileName.Length > 0) { int filesize = FileUpload1.FileBytes.Length / 1024; if (filesize >= 4000) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadsize, Color.Red); return; } else { FileUpload1.SaveAs(serverpath); } } else { filename = Session["imageurl"].ToString(); } } if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { if (vLecir.FindByuserName(txtusername.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red); return; } } VEmployeesRepository vempirr = new VEmployeesRepository(); Employee emp = new Employee(); emp.EmployeeID = lblempid.Text.ToInt(); emp.FirstName = txtname.Text; emp.LastName = txtlastname.Text; emp.Gender = RadioButtonList1.SelectedValue.ToInt(); emp.NationalCode = txtnationalcode.Text; emp.DepartmentID = Session["newdep"].ToString().ToInt(); emp.RoleID = Session["newrole"].ToString().ToInt(); if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { emp.Username = txtusername.Text; } else { emp.Username = lblusername.Text; } //emp.Password = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : emp.Password); if (txtpass.Text.Length > 0) { emp.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); } else { emp.Password = Session["pass"].ToString(); } emp.Status = (chkActiveAccount.Checked == true ? 0 : 1); emp.ImageFileName = filename; vempirr.Saveemp(emp); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red); } } }
protected void Button2_Click(object sender, EventArgs e) { VEmployeesRepository emp = new VEmployeesRepository(); if (emp.FindByuserName(txtmail.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red); return; } // bool successfullCreateAccount = true; //try //{ string serverpath = Server.MapPath(Request.ApplicationPath) + @"\file\" + PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName; string filename = PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName; //VEmployeesRepository vstdir = new VEmployeesRepository(); //if (vstdir.FindByLinkUrl(filename) != null) //{ // PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadrepeat, Color.Red); // return; //} //else //{ if (FileUpload1.FileName.Length > 0) { //int filesize = FileUpload1.FileBytes.Length / 1024; //if (filesize >= 4000) //{ // PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadsize, Color.Red); // return; //} //else //{ FileUpload1.SaveAs(serverpath); // } } else { // PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadempty, Color.Red); // return; filename = ""; } // } Employee newemp = new Employee(); newemp.DepartmentID = ddldep.SelectedValue.ToInt(); newemp.RoleID = ddlrole.SelectedValue.ToInt(); newemp.FirstName = txtname.Text; newemp.LastName = txtlastname.Text; newemp.Gender = RadioButtonList1.SelectedValue.ToInt(); newemp.NationalCode = txtnationalcode.Text; newemp.ImageFileName = filename; newemp.FixTel = txttel.Text; newemp.Email = txtmail.Text; newemp.Mobile = txtmobile.Text; VEmployeesRepository vstdirr = new VEmployeesRepository(); vstdirr.Saveemp(newemp); clearform(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green); }