public VVPN FindByUsername(string username) { VVPN result = null; using (PersonsDBEntities DC = conn.GetContext()) { //-- SELECT * FROM vPhoneList WHERE PhobeID = phoneID result = (from r in DC.VVPNs where r.Username == username select r).FirstOrDefault(); } return(result); }
public VVPN FindByid(int id) { VVPN result = null; using (PersonsDBEntities DC = conn.GetContext()) { //-- SELECT * FROM vPhoneList WHERE PhobeID = phoneID result = (from r in DC.VVPNs where r.VPNID == id select r).FirstOrDefault(); } return(result); }
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); } }