protected void Button3_Click(object sender, EventArgs e) { VLecturersRepository vstdir = new VLecturersRepository(); if (vstdir.Getexeldata() != null) { DumpExcel(vstdir.Getexeldata(), "VLecturers"); } }
protected void Button1_Click(object sender, EventArgs e) { try { if (lbllecid.Text.Length > 0) { VLecturersRepository vLecirr = new VLecturersRepository(); if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { if (vLecirr.FindByuserName(txtusername.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red); return; } } PersonsAdmin person = new PersonsAdmin(); person.AdminID = lbllecid.Text.ToInt(); person.FirstName = txtname.Text; person.LastName = txtlastname.Text; if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { person.Username = txtusername.Text; } else { person.Username = lblusername.Text; } //person.Password = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : person.Password); if (txtpass.Text.Length > 0) { person.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); } else { person.Password = Session["pass"].ToString(); } person.Status = (chkActiveAccount.Checked == true ? 0 : 1); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green); } } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red); } }
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 { VLecturersRepository vstdir = new VLecturersRepository(); Session["lecdata"] = vstdir.GetAllVLec(); GridView1.DataSource = Session["lecdata"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().ToString().ToFarsiNumber(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["lecdata"] 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) { VLecturersRepository vstdir = new VLecturersRepository(); vstdir.Deletelec(selectedRows); // vstdir.Deletelecturer(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 VLecturer FindByLecturerID(string username, string password, int id) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VLecturersRepository depir = new VLecturersRepository(); return(depir.FindByid(id)); } else { return(null); } } else { return(null); } }
public void SetLecPasswordByID(string username, string password, int lecturerID, string NewPassword) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VLecturersRepository vempir = new VLecturersRepository(); Lecturer emp = vempir.FindByid2(lecturerID); emp.Password = NewPassword; vempir.Savestd(emp); } else { } } else { } }
public VLecturer FindByLecNationalCode(string username, string password, string lecnationalcode) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VLecturersRepository depir = new VLecturersRepository(); return(depir.FindBynationalcode(lecnationalcode)); } else { return(null); } } else { return(null); } }
public DataTable GetLecturer(string username, string password) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VLecturersRepository depir = new VLecturersRepository(); return(depir.GetAllVLec()); } 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 ImageButton2_Click(object sender, ImageClickEventArgs e) { lblmessage.Text = ""; if (txtsearch.Text.Length > 0) { if (DropDownList1.SelectedValue == "0") { try { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindid"] = vstdir.Searchlecid(txtsearch.Text.ToInt()); GridView1.DataSource = Session["stddatafindid"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().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 == "2") { try { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindFirstName"] = vstdir.SearchFirstName(txtsearch.Text); GridView1.DataSource = Session["stddatafindFirstName"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().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 { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindLasttName"] = vstdir.SearchLastName(txtsearch.Text); GridView1.DataSource = Session["stddatafindLasttName"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().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 { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindUsername"] = vstdir.SearchUserName(txtsearch.Text); GridView1.DataSource = Session["stddatafindUsername"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().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 { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindFacultyTitle"] = vstdir.SearchFacultyTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindFacultyTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindFacultyTitle"] 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 == "7") { try { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindFielsTitle"] = vstdir.SearchFieldTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindFielsTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindFielsTitle"] 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 == "8") { try { VLecturersRepository vstdir = new VLecturersRepository(); Session["stddatafindTendencyTitle"] = vstdir.SearchTendencyTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindTendencyTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.leccount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindTendencyTitle"] 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); } } } else { LoadStdData(); } }
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); } }
public void loadform(string Leci) { try { FacultiesRepositpry fair = new FacultiesRepositpry(); DataTable dt = fair.GetAllFaculties(); ddlfacultuy.Items.Clear(); foreach (DataRow dr in dt.Rows) { ddlfacultuy.Items.Add(new ListItem(dr["FacultyTitle"].ToString(), dr["FacultyID"].ToString())); } EduFieldsRepository fieldir = new EduFieldsRepository(); DataTable dtfield = fieldir.GetAllEduFields(); foreach (DataRow dr in dtfield.Rows) { ddlfield.Items.Add(new ListItem(dr["FieldTitle"].ToString(), dr["FieldID"].ToString())); } VEduTendenciesRepository tenir = new VEduTendenciesRepository(); DataTable ten = tenir.GetAllTendency(); foreach (DataRow dr in ten.Rows) { ddltendency.Items.Add(new ListItem(dr["TendencyTitle"].ToString(), dr["TendencyID"].ToString())); } VLecturersRepository vstir = new VLecturersRepository(); VLecturer Lec = vstir.FindByid(Leci.ToInt()); if (Lec != null) { lbllecid.Text = Lec.LecturerID.ToString(); txtname.Text = Lec.FirstName; txtlastname.Text = Lec.LastName; RadioButtonList1.SelectedValue = Lec.Gender.ToString(); txtnationalcode.Text = Lec.NationalCode; lblfaculty.Text = Lec.FacultyTitle; lblfield.Text = Lec.FieldTitle; lbltend.Text = Lec.TendencyTitle; lblusername.Text = Lec.Username; if (txtpass.Text != null) { txtpass.Text = Lec.Password; } // ImageButton1.ImageUrl = Lec.ImageFileName; Session["newfacultyid"] = Lec.FacultyID.ToString(); Session["pass"] = Lec.Password.ToString(); Session["newfieldid"] = Lec.FieldID.ToString(); Session["newtenid"] = Lec.TendencyID.ToString(); chkActiveAccount.Checked = (Lec.Status.Value == 0 ? true : false); Session["imageurl"] = Lec.ImageFileName.ToString(); if (Session["imageurl"].ToString() != null) { ImageButton2.ImageUrl = "~/file/" + Lec.ImageFileName; } } else { Redirector.Goto(Redirector.PageName.errorpage); } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
protected void Button1_Click(object sender, EventArgs e) { if (lbllecid.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; VLecturersRepository vLecir = new VLecturersRepository(); 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; } } VLecturersRepository vLecirr = new VLecturersRepository(); Lecturer Lec = new Lecturer(); Lec.LecturerID = lbllecid.Text.ToInt(); Lec.FirstName = txtname.Text; Lec.LastName = txtlastname.Text; Lec.Gender = RadioButtonList1.SelectedValue.ToInt(); Lec.NationalCode = txtnationalcode.Text; Lec.FacultyID = Session["newfacultyid"].ToString().ToInt(); Lec.FieldID = Session["newfieldid"].ToString().ToInt(); Lec.TendencyID = Session["newtenid"].ToString().ToInt(); if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { Lec.Username = txtusername.Text; } else { Lec.Username = lblusername.Text; } //Lec.Password = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : Lec.Password); if (txtpass.Text.Length > 0) { Lec.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); } else { Lec.Password = Session["pass"].ToString(); } Lec.Status = (chkActiveAccount.Checked == true ? 0 : 1); Lec.ImageFileName = filename; vLecirr.Savestd(Lec); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red); } } }
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 Button1_Click(object sender, EventArgs e) { VLecturersRepository vlec = new VLecturersRepository(); if (vlec.FindByuserName(txtusername.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; VLecturersRepository vstdir = new VLecturersRepository(); 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 = ""; } } Lecturer newstd = new Lecturer(); newstd.FirstName = txtname.Text; newstd.LastName = txtlastname.Text; newstd.Gender = RadioButtonList1.SelectedValue.ToInt(); newstd.NationalCode = txtnationalcode.Text; newstd.FacultyID = ddlfacultuy.SelectedValue.ToInt(); newstd.FieldID = ddlfield.SelectedValue.ToInt(); newstd.TendencyID = ddltendency.SelectedValue.ToInt(); newstd.Username = txtusername.Text; newstd.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); newstd.ImageFileName = filename; newstd.Status = (chkActiveAccount.Checked == true ? 0 : 1); VLecturersRepository vstdirr = new VLecturersRepository(); vstdirr.Savestd(newstd); clearform(); } catch (System.Exception err) { successfullCreateAccount = false; PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red); } if (successfullCreateAccount) { // ClearForm(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green); } }