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 { } }
protected void Button3_Click(object sender, EventArgs e) { VEmployeesRepository vstdir = new VEmployeesRepository(); if (vstdir.Getexeldata() != null) { DumpExcel(vstdir.Getexeldata(), "VEmployees"); } }
public void LoadTelContactData(string userid, string usertypeid) { //try //{ TelContactsRepository dir = new TelContactsRepository(); Session["TelPersonContactData"] = dir.GetTelpersonContactList(userid.ToInt(), usertypeid.ToInt()); GridView1.DataSource = Session["TelPersonContactData"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", dir.TelContactCount().ToString().ToFarsiNumber(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["TelPersonContactData"] as DataTable).Rows.Count.ToString().ToFarsiNumber(), Resources.DashboardText.SelectRecordCount); switch (Session["UserTypeID"].ToString()) { case "1": { VStudentsRepository vstdir = new VStudentsRepository(); VStudent std = vstdir.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "دانشجو" + ":" + std.FirstName + " " + std.LastName; } break; case "2": { VLecturersRepository vlec = new VLecturersRepository(); VLecturer lec = vlec.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "استاد" + ":" + lec.FirstName + " " + lec.LastName; } break; case "3": { VEmployeesRepository vlec = new VEmployeesRepository(); VEmployee emp = vlec.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "کارمند" + ":" + emp.FirstName + " " + emp.LastName; } break; } // } // catch // { //// Redirector.Goto(Redirector.PageName.errorpage); // } }
public void loadform() { try { lbluserid.Text = Session["UserID"].ToString(); lblusertypeid.Text = Session["UserTypeID"].ToString(); EmailTypesRepository etr = new EmailTypesRepository(); DataTable dt = etr.GetAllEmailTypes(); ddlemailtype.Items.Clear(); foreach (DataRow dr in dt.Rows) { ddlemailtype.Items.Add(new ListItem(dr["EmailTypeTitle"].ToString(), dr["EmailTypeID"].ToString())); } switch (Session["UserTypeID"].ToString()) { case "1": { VStudentsRepository vstdir = new VStudentsRepository(); VStudent std = vstdir.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "دانشجو" + ":" + std.FirstName + " " + std.LastName; } break; case "2": { VLecturersRepository vlec = new VLecturersRepository(); VLecturer lec = vlec.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "استاد" + ":" + lec.FirstName + " " + lec.LastName; } break; case "3": { VEmployeesRepository vlec = new VEmployeesRepository(); VEmployee emp = vlec.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "کارمند" + ":" + emp.FirstName + " " + emp.LastName; } break; } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
public void LoadStdData() { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddata"] = vstdir.GetAllvEmp(); GridView1.DataSource = Session["stddata"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString().ToFarsiNumber(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddata"] as DataTable).Rows.Count.ToString().ToFarsiNumber(), Resources.DashboardText.SelectRecordCount); } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
protected void Button2_Click(object sender, EventArgs e) { try { List <int> selectedRows = new List <int>(); foreach (GridViewRow gvr in GridView1.Rows) { if ((gvr.FindControl("CheckBox2") as CheckBox).Checked == true) { selectedRows.Add(gvr.Cells[0].Text.ToInt()); } } if (selectedRows.Count > 0) { VEmployeesRepository vstdir = new VEmployeesRepository(); vstdir.Deleteemp(selectedRows); LoadStdData(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green); EmailContactsRepository emrir = new EmailContactsRepository(); emrir.DeletepersonEmailContact(selectedRows); LoadStdData(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green); TelContactsRepository trir = new TelContactsRepository(); trir.DeletepersonTelContact(selectedRows); LoadStdData(); } } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDeleteFailed, Color.Red); } }
public DataTable GetEmployee(string username, string password) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VEmployeesRepository depir = new VEmployeesRepository(); return(depir.GetAllvEmp()); } else { return(null); } } else { return(null); } }
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 { } }
public VEmployee FindByEmpNationalCode(string username, string password, string empcode) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VEmployeesRepository depir = new VEmployeesRepository(); return(depir.FindBynationalcode(empcode)); } else { return(null); } } else { return(null); } }
public VEmployee FindByEmployeeID(string username, string password, int id) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VEmployeesRepository depir = new VEmployeesRepository(); return(depir.FindByid(id)); } else { return(null); } } else { return(null); } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedValue == "1") { VStudentsRepository vstd = new VStudentsRepository(); DataTable dtstd = vstd.GetAllstd(); ddluserid.Items.Clear(); foreach (DataRow dr in dtstd.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["StudentID"].ToString())); } } if (DropDownList1.SelectedValue == "2") { VLecturersRepository vlrir = new VLecturersRepository(); DataTable dtlec = vlrir.GetAllLec(); ddluserid.Items.Clear(); foreach (DataRow dr in dtlec.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["LecturerID"].ToString())); } } if (DropDownList1.SelectedValue == "3") { VEmployeesRepository verir = new VEmployeesRepository(); DataTable dtemp = verir.GetAllEmp(); ddluserid.Items.Clear(); foreach (DataRow dr in dtemp.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["EmployeeID"].ToString())); } } Session["UserTypeID"] = DropDownList1.SelectedValue.ToString(); }
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); } } }
public void loadform(string empid) { try { DepartmentsRepository depir = new DepartmentsRepository(); DataTable dep = depir.GetAllDepartment(); foreach (DataRow dr in dep.Rows) { ddldep.Items.Add(new ListItem(dr["DepartmentTitle"].ToString(), dr["DepartmentID"].ToString())); } RolesRepository roleir = new RolesRepository(); DataTable role = roleir.GetAllRoles(); foreach (DataRow dr in role.Rows) { ddlrole.Items.Add(new ListItem(dr["RoleTitle"].ToString(), dr["RoleID"].ToString())); } VEmployeesRepository vstir = new VEmployeesRepository(); VEmployee emp = vstir.FindByid(empid.ToInt()); if (emp != null) { lblempid.Text = emp.EmployeeID.ToString(); txtname.Text = emp.FirstName; txtlastname.Text = emp.LastName; RadioButtonList1.SelectedValue = emp.Gender.ToString(); txtnationalcode.Text = emp.NationalCode; lbldep.Text = emp.DepartmentTitle; lblrole.Text = emp.RoleTitle; lblusername.Text = emp.Username.ToString(); if (txtpass.Text != null) { txtpass.Text = emp.Password.ToString(); } // ImageButton1.ImageUrl = emp.ImageFileName; Session["newdep"] = emp.DepartmentID.ToString(); Session["pass"] = emp.Password.ToString(); Session["newrole"] = emp.RoleID.ToString(); chkActiveAccount.Checked = (emp.Status.Value == 0 ? true : false); Session["imageurl"] = emp.ImageFileName.ToString(); if (Session["imageurl"].ToString() != null) { ImageButton2.ImageUrl = "~/file/" + emp.ImageFileName; } } else { Redirector.Goto(Redirector.PageName.errorpage); } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
public void LoadData(string id) { try { EmailContactsRepository ecrir = new EmailContactsRepository(); EmailContact email = ecrir.FindByid(id.ToInt()); lblid.Text = email.ID.ToString(); Session["UserID"] = email.UserID.ToString(); Session["EmailType"] = email.EmailTypeID.ToString(); Session["UserType"] = email.UserTypeID.ToString(); lblEmailaddrress.Text = email.EmailAddrress.ToString(); Session["newuserid"] = email.UserID.ToString(); Session["newemailtype"] = email.EmailTypeID.ToString(); VStudentsRepository vstdir = new VStudentsRepository(); VStudent std = vstdir.FindByid(Session["UserID"].ToString().ToInt()); if (std != null) { Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString(); } else { Redirector.Goto(Redirector.PageName.errorpage); } EmailTypesRepository etir = new EmailTypesRepository(); EmailType emailtype = etir.FindByid(Session["EmailType"].ToString().ToInt()); if (emailtype != null) { lblEmailtype.Text = emailtype.EmailTypeTitle; // Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString(); } else { Redirector.Goto(Redirector.PageName.errorpage); } EmailTypesRepository etr = new EmailTypesRepository(); DataTable dt2 = etr.GetAllEmailTypes(); ddlemailtype.Items.Clear(); foreach (DataRow dr in dt2.Rows) { ddlemailtype.Items.Add(new ListItem(dr["EmailTypeTitle"].ToString(), dr["EmailTypeID"].ToString())); } switch ((Session["UserType"].ToString())) { case "1": { DropDownList1.SelectedValue = "1"; VStudentsRepository vstd = new VStudentsRepository(); DataTable dtstd = vstd.GetAllstd(); ddluserid.Items.Clear(); foreach (DataRow dr in dtstd.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["StudentID"].ToString())); } } break; case "2": { DropDownList1.SelectedValue = "2"; VLecturersRepository vlrir = new VLecturersRepository(); DataTable dtlec = vlrir.GetAllLec(); ddluserid.Items.Clear(); foreach (DataRow dr in dtlec.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["LecturerID"].ToString())); } } break; case "3": { DropDownList1.SelectedValue = "3"; VEmployeesRepository verir = new VEmployeesRepository(); DataTable dtemp = verir.GetAllEmp(); ddluserid.Items.Clear(); foreach (DataRow dr in dtemp.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["EmployeeID"].ToString())); } } break; } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { lblmessage.Text = ""; if (txtsearch.Text.Length > 0) { if (DropDownList1.SelectedValue == "0") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindid"] = vstdir.Searchid(txtsearch.Text.ToInt()); GridView1.DataSource = Session["stddatafindid"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindid"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "1") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindcode"] = vstdir.SearchNationalcode(txtsearch.Text); GridView1.DataSource = Session["stddatafindcode"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindcode"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "2") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindFirstName"] = vstdir.SearchFirstName(txtsearch.Text); GridView1.DataSource = Session["stddatafindFirstName"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindFirstName"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "3") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindLasttName"] = vstdir.SearchLastName(txtsearch.Text); GridView1.DataSource = Session["stddatafindLasttName"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindLasttName"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "4") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindUsername"] = vstdir.SearchUserName(txtsearch.Text); GridView1.DataSource = Session["stddatafindUsername"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindUsername"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "5") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindUsername"] = vstdir.searchDepartmenttitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindUsername"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindUsername"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "6") { try { VEmployeesRepository vstdir = new VEmployeesRepository(); Session["stddatafindUsername"] = vstdir.searchRoletitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindUsername"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.Empcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindUsername"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } } }
public void LoadData(string id) { try { VPNsRepository vpnir = new VPNsRepository(); // EmailContactsRepository ecrir = new EmailContactsRepository(); VVPN vpn = vpnir.FindByid(id.ToInt()); lblid.Text = id; Session["UserID"] = vpn.UserID.ToString(); Session["UserType"] = vpn.UserTypeID.ToString(); Session["DepartmentID"] = vpn.DepartmentID; lblusername.Text = vpn.Username; Lbldep.Text = vpn.DepartmentTitle; VStudentsRepository vstdir = new VStudentsRepository(); VStudent std = vstdir.FindByid(Session["UserID"].ToString().ToInt()); if (std != null) { Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString(); } else { Redirector.Goto(Redirector.PageName.errorpage); } DepartmentsRepository etr = new DepartmentsRepository(); DataTable dt = etr.GetAllDepartment(); ddldepartment.Items.Clear(); foreach (DataRow dr in dt.Rows) { ddldepartment.Items.Add(new ListItem(dr["DepartmentTitle"].ToString(), dr["DepartmentID"].ToString())); } switch ((Session["UserType"].ToString())) { case "1": { DropDownList1.SelectedValue = "1"; VStudentsRepository vstd = new VStudentsRepository(); DataTable dtstd = vstd.GetAllstd(); ddluserid.Items.Clear(); foreach (DataRow dr in dtstd.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["StudentID"].ToString())); } } break; case "2": { DropDownList1.SelectedValue = "2"; VLecturersRepository vlrir = new VLecturersRepository(); DataTable dtlec = vlrir.GetAllLec(); ddluserid.Items.Clear(); foreach (DataRow dr in dtlec.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["LecturerID"].ToString())); } } break; case "3": { DropDownList1.SelectedValue = "3"; VEmployeesRepository verir = new VEmployeesRepository(); DataTable dtemp = verir.GetAllEmp(); ddluserid.Items.Clear(); foreach (DataRow dr in dtemp.Rows) { ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["EmployeeID"].ToString())); } } break; } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
public void loadform() { try { EmailContactsRepository ecrir = new EmailContactsRepository(); EmailContact email = ecrir.FindByid(Session["ID"].ToString().ToInt()); lblid.Text = email.ID.ToString(); lbluserid.Text = Session["UserID"].ToString(); lblusertypeid.Text = Session["UserTypeID"].ToString(); Session["EmailType"] = email.EmailTypeID.ToString(); lblemailaddrress.Text = email.EmailAddrress; Session["newemailtype"] = email.EmailTypeID.ToString(); switch (Session["UserTypeID"].ToString()) { case "1": { VStudentsRepository vstdir = new VStudentsRepository(); VStudent std = vstdir.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "دانشجو" + ":" + std.FirstName + " " + std.LastName; } break; case "2": { VLecturersRepository vlec = new VLecturersRepository(); VLecturer lec = vlec.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "استاد" + ":" + lec.FirstName + " " + lec.LastName; } break; case "3": { VEmployeesRepository vlec = new VEmployeesRepository(); VEmployee emp = vlec.FindByid(Session["UserID"].ToString().ToInt()); Label9.Text = "کارمند" + ":" + emp.FirstName + " " + emp.LastName; } break; } EmailTypesRepository etir = new EmailTypesRepository(); EmailType emailtype = etir.FindByid(Session["EmailType"].ToString().ToInt()); if (emailtype != null) { lblEmailtype.Text = emailtype.EmailTypeTitle; // Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString(); } else { Redirector.Goto(Redirector.PageName.errorpage); } EmailTypesRepository etr = new EmailTypesRepository(); DataTable dt2 = etr.GetAllEmailTypes(); ddlemailtype.Items.Clear(); foreach (DataRow dr in dt2.Rows) { ddlemailtype.Items.Add(new ListItem(dr["EmailTypeTitle"].ToString(), dr["EmailTypeID"].ToString())); } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
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); }