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 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); } }