protected void Button1_Click(object sender, EventArgs e) { VStudentsRepository vstdir = new VStudentsRepository(); if (vstdir.Getexeldatavstd3() != null) { DumpExcel(vstdir.Getexeldatavstd3(), "Students"); } }
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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddata"] = vstdir.GetAllvstd(); GridView1.DataSource = Session["stddata"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 Button3_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) { VStudentsRepository vstdir = new VStudentsRepository(); vstdir.Deletestudent(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 GetStudent(string username, string password) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VStudentsRepository depir = new VStudentsRepository(); return(depir.GetAllstd()); } else { return(null); } } else { return(null); } }
public void SetstdPasswordByID(string username, string password, int studentID, string NewPassword) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VStudentsRepository vempir = new VStudentsRepository(); Student emp = vempir.FindByid2(studentID); emp.Password = NewPassword; vempir.Savestd(emp); } else { } } else { } }
public VStudent FindByStdNationalCode(string username, string password, string stdcode) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VStudentsRepository depir = new VStudentsRepository(); return(depir.FindBynationatcode(stdcode)); } else { return(null); } } else { return(null); } }
public VStudent FindByStudentID(string username, string password, int id) { WebServiceAccountsRepository webir = new WebServiceAccountsRepository(); WebServiceAccount currentuser = webir.FindByUserName(username); if (currentuser != null) { if (currentuser.Password == password) { VStudentsRepository depir = new VStudentsRepository(); 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(); }
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); } }
public void loadform(string stdi) { //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())); } EduLevelsRepository leveir = new EduLevelsRepository(); DataTable dtlevel = leveir.GetAllEduLevels(); foreach (DataRow dr in dtlevel.Rows) { ddllevel.Items.Add(new ListItem(dr["LevelTitle"].ToString(), dr["LevelID"].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())); } VStudentsRepository vstir = new VStudentsRepository(); VStudent std = vstir.FindByid(stdi.ToInt()); if (std != null) { lblstdid.Text = std.StudentID.ToString(); txtstdcode.Text = std.StudentCode; txtname.Text = std.FirstName; txtlastname.Text = std.LastName; RadioButtonList1.SelectedValue = std.Gender.ToString(); txtnationalcode.Text = std.NationalCode; lblfaculty.Text = std.FacultyTitle; lbllevel.Text = std.LevelTitle; lblfield.Text = std.FieldTitle; lbltend.Text = std.TendencyTitle; RadioButtonList2.SelectedValue = std.EntryTerm.ToString(); lblusername.Text = std.Username; if (txtpass.Text != null) { txtpass.Text = std.Password; } // ImageButton1.ImageUrl = std.ImageFileName; Session["newfacultyid"] = std.FacultyID.ToString(); Session["newlevelid"] = std.LevelID.ToString(); Session["newfieldid"] = std.FieldID.ToString(); Session["newtenid"] = std.TendencyID.ToString(); Session["pass"] = std.Password; chkActiveAccount.Checked = (std.Status.Value == 0 ? true : false); Session["imageurl"] = std.ImageFileName; if (Session["imageurl"].ToString() != null) { ImageButton2.ImageUrl = "~/file/" + std.ImageFileName; } } else { Redirector.Goto(Redirector.PageName.errorpage); } //} //catch //{ // Redirector.Goto(Redirector.PageName.errorpage); //} }
protected void Button1_Click(object sender, EventArgs e) { if (lblstdid.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; VStudentsRepository vstdir = new VStudentsRepository(); 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 { filename = Session["imageurl"].ToString(); } } if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { if (vstdir.FindByuserName(txtusername.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red); return; } } VStudentsRepository vstdirr = new VStudentsRepository(); Student std = new Student(); std.StudentID = lblstdid.Text.ToInt(); std.StudentCode = txtstdcode.Text; std.FirstName = txtname.Text; std.LastName = txtlastname.Text; std.Gender = RadioButtonList1.SelectedValue.ToInt(); std.NationalCode = txtnationalcode.Text; std.FacultyID = Session["newfacultyid"].ToString().ToInt(); std.LevelID = Session["newlevelid"].ToString().ToInt(); std.FieldID = Session["newfieldid"].ToString().ToInt(); std.TendencyID = Session["newtenid"].ToString().ToInt(); std.EntryTerm = RadioButtonList2.SelectedValue.ToInt(); if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { std.Username = txtusername.Text; } else { std.Username = lblusername.Text; } if (txtpass.Text.Length > 0) { std.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); } else { std.Password = Session["pass"].ToString(); } std.Status = (chkActiveAccount.Checked == true ? 0 : 1); std.ImageFileName = filename; vstdirr.Savestd(std); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red); } } }
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 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); } }
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { lblmessage.Text = ""; if (txtsearch.Text.Length > 0) { if (DropDownList1.SelectedValue == "0") { try { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindid"] = vstdir.Searchstdid(txtsearch.Text.ToInt()); GridView1.DataSource = Session["stddatafindid"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindcode"] = vstdir.Searchstdcode(txtsearch.Text); GridView1.DataSource = Session["stddatafindcode"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindFirstName"] = vstdir.SearchFirstName(txtsearch.Text); GridView1.DataSource = Session["stddatafindFirstName"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindLasttName"] = vstdir.SearchLastName(txtsearch.Text); GridView1.DataSource = Session["stddatafindLasttName"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindUsername"] = vstdir.SearchUserName(txtsearch.Text); GridView1.DataSource = Session["stddatafindUsername"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindFacultyTitle"] = vstdir.SearchFacultyTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindFacultyTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 == "6") { try { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindLevelTitle"] = vstdir.SearchLevelTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindLevelTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindLevelTitle"] 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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindFielsTitle"] = vstdir.SearchFieldTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindFielsTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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 { VStudentsRepository vstdir = new VStudentsRepository(); Session["stddatafindTendencyTitle"] = vstdir.SearchTendencyTitle(txtsearch.Text); GridView1.DataSource = Session["stddatafindTendencyTitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", vstdir.stdcount().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(); } }
protected void Button1_Click(object sender, EventArgs e) { VStudentsRepository vstd = new VStudentsRepository(); if (vstd.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; VStudentsRepository vstdir = new VStudentsRepository(); 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 = ""; } } Student newstd = new Student(); newstd.StudentCode = txtstdcode.Text; newstd.FirstName = txtname.Text; newstd.LastName = txtlastname.Text; newstd.Gender = RadioButtonList1.SelectedValue.ToInt(); newstd.NationalCode = txtnationalcode.Text; newstd.FacultyID = ddlfacultuy.SelectedValue.ToInt(); newstd.LevelID = ddllevel.SelectedValue.ToInt(); newstd.FieldID = ddlfield.SelectedValue.ToInt(); newstd.TendencyID = ddltendency.SelectedValue.ToInt(); newstd.EntryTerm = RadioButtonList2.SelectedValue.ToInt(); newstd.Username = txtusername.Text; newstd.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); newstd.ImageFileName = filename; newstd.Status = (chkActiveAccount.Checked == true ? 0 : 1); VStudentsRepository vstdirr = new VStudentsRepository(); vstdirr.Savestd(newstd); clearform(); } catch (System.Exception err) { //OnlineTools.ShowMessage(lblMessage, err.Message, Color.Red); successfullCreateAccount = false; PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red); } if (successfullCreateAccount) { // ClearForm(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green); } }