public static List<Event> GetAllEvents(string dataName, int Page) { List<Event> Events = new List<Event>(); >>>>>>> 3aabe62cdccf29aead7c454a773c6bc3e00d87ab List<User> Users = new List<User>(); Dal.DB db = new DB(); db.Configuration.ProxyCreationEnabled = false; <<<<<<< HEAD ///分页查询 按时间倒叙查询 Events = (from e in db.Events orderby e.Time descending select e).ToList(); int total = Events.Count; //跳过的总条数 int totalNum = (Page) * 10; Events = Events.Skip(totalNum).ToList(); if (Events.Count > 10) { Events.RemoveRange(10, total - 10); } /*Events=db.Events.OrderByDescending(e=>e.Time).Select(e => e).Skip( (Page) * 10).Take(Page).ToList(); */ foreach (Events Event in Events) { Event.Root = db.Users.Find(Event.RootID); } return Events; }
protected void Page_Load(object sender, EventArgs e) { User User = (User)Session["User"]; if (User != null) { user_rank = User.RoleAsInt.ToString(); user_id = User.ID.ToString(); } <<<<<<< HEAD ======= using (Dal.DB db = new Dal.DB()) { var departments = (from d in db.Departments select d).ToList(); foreach (var d in departments) { ListItem item = new ListItem(); item.Text = d.Title; item.Value = d.ID.ToString(); cbbDepartment.Items.Add(item); } } >>>>>>> 3aabe62cdccf29aead7c454a773c6bc3e00d87ab }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int sid = Convert.ToInt32(Request.QueryString["id"]); Schedule Schedule=new Entity.Schedule(); List<Department> Departments=new List<Department> (); List<User> Users = new List<User>(); using (Dal.DB db = new Dal.DB()) { Departments=(from d in db.Departments select d).ToList(); Schedule = db.Schedules.Find(sid); Users = db.Users.Where<User>(u => u.DepartmentID == Schedule.DepartmentID).ToList(); txtEditScheduleName.Text = Schedule.Title; txtEditScheduleContent.Text = Schedule.Content; foreach (Department Department in Departments) { ddlEditScheduleDepartment.Items.Add(Department.Title); ddlEditScheduleDepartment.Items.FindByText(Department.Title).Value = Department.ID.ToString(); } ddlEditScheduleDepartment.SelectedValue = Schedule.DepartmentID.ToString(); foreach (User User in Users) { ddlEditScheduleToUser.Items.Add(User.Username); ddlEditScheduleToUser.Items.FindByText(User.Username).Value = User.ID.ToString(); } ddlEditScheduleToUser.SelectedValue = Schedule.ToUserID.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (Dal.DB db = new Dal.DB()) { var departments = (from d in db.Departments select d).ToList(); foreach (var d in departments) { ListItem item = new ListItem(); item.Text = d.Title; item.Value = d.ID.ToString(); cbbDepartment.Items.Add(item); } int uid = Convert.ToInt32(Request.QueryString["ID"]); var user = db.Users.Find(uid); txtName.Text = user.Name; if (user.Avatar != null) { imgAvatar.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(user.Avatar); } if (user.DepartmentID != null) { var item = cbbDepartment.Items.FindByValue(user.DepartmentID.GetValueOrDefault().ToString()); cbbDepartment.SelectedIndex = cbbDepartment.Items.IndexOf(item); } var i = cbbRole.Items.FindByValue(user.RoleAsInt.ToString()); cbbRole.SelectedIndex = cbbRole.Items.IndexOf(i); } } }
public static List<File> GetFiles(string dataName, int Page, int DepartmentID) { List<File> Files = new List<File>(); Dal.DB db = new DB(); db.Configuration.ProxyCreationEnabled = false; Files = (from f in db.Files select f).ToList(); if (dataName != "") { Files = (from f in db.Files where f.User.Name == dataName select f).ToList(); } if (DepartmentID != 0) { Files = (from f in db.Files where f.User.DepartmentID == DepartmentID select f).ToList(); } foreach (File File in Files) { File.User = db.Users.Find(File.UserID); File.User.DepartmentTitle = db.Departments.Find(File.User.ID).Title; } return Files; }
public static List<Schedule> GetSchedulesList(string dataName, int Page, int DepartmentID) { List<Schedule> Schedules = new List<Schedule>(); List<User> Users = new List<User>(); Dal.DB db = new DB(); db.Configuration.ProxyCreationEnabled = false; Schedules = (from s in db.Schedules select s).ToList(); if (dataName != "") { Schedules = (from s in db.Schedules where s.ToUser.Username.Contains(dataName) select s).ToList(); } if (DepartmentID != 0) { Schedules = (from s in db.Schedules where s.DepartmentID==DepartmentID select s).ToList(); } foreach (Schedule Schedule in Schedules) { Schedule.ToUser = db.Users.Find(Schedule.ToUserID); Schedule.SubmittionUser = db.Users.Find(Schedule.SubmittionUserID); Schedule.Department = db.Departments.Find(Schedule.DepartmentID); } return Schedules; }
protected void Page_Load(object sender, EventArgs e) { using (Dal.DB db = new Dal.DB()) { departments = (from d in db.Departments select d).ToList(); } }
protected void btnDeleteSchedule_Click(object sender, EventArgs e) { int sid = Convert.ToInt32(Request.QueryString["id"]); Schedule Schedule = new Schedule(); using (Dal.DB db = new Dal.DB()) { Schedule = db.Schedules.Find(sid); db.Schedules.Remove(Schedule); db.SaveChanges(); } Response.Redirect("Admin_Schedules.aspx"); }
protected void btnSubmit_Click(object sender, EventArgs e) { using (Dal.DB db = new Dal.DB()) { int did = Convert.ToInt32(Request.QueryString["ID"]); var Department = db.Departments.Find(did); Department.Title = departmentName.Text; Department.Description = descripment.Text; db.SaveChanges(); Response.Redirect("Admin_Departments.aspx"); } }
public static List<User> GetUserByDepartment(int department_id) { List<User> Users = new List<User>(); using (Dal.DB db = new DB()) { db.Configuration.ProxyCreationEnabled = false; Users = (from u in db.Users where u.DepartmentID == department_id select u).ToList(); } return Users; }
protected void btnAdd_Click(object sender, EventArgs e) { using (Dal.DB db = new Dal.DB()) { db.Users.Add(new Entity.User() { Name = txtAddName.Text, Username = txtAddUsername.Text, Password = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(txtAddPassword.Text)) }); db.SaveChanges(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (Dal.DB db = new Dal.DB()) { int did = Convert.ToInt32(Request.QueryString["ID"]); var Department = db.Departments.Find(did); departmentName.Text = Department.Title; descripment.Text = Department.Description; } } }
protected void btnAddSign_click(object sender, EventArgs e) { string SignType = dllAddSignInKind.SelectedValue; SignLog Sign = new SignLog(); Sign.UserID = user_id; Sign.TypeAsInt = Convert.ToInt32(SignType); Sign.Time = DateTime.Now; using (Dal.DB db = new Dal.DB()) { db.SignLogs.Add(Sign); db.SaveChanges(); } Response.Redirect("Admin_SignIn.aspx"); }
protected void btnAdd_Click(object sender, EventArgs e) { Department Department = new Department(); Department.Title = departmentAddName.Text; Department.Description = departmentAddDecriptment.Text; using (Dal.DB db = new Dal.DB()) { db.Departments.Add(Department); db.SaveChanges(); } departmentAddName.Text = ""; departmentAddDecriptment.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { using (Dal.DB db = new Dal.DB()) { var departments = (from d in db.Departments select d).ToList(); foreach(var d in departments) { ListItem item = new ListItem(); item.Text = d.Title; item.Value = d.ID.ToString(); cbbDepartment.Items.Add(item); } } }
public static string AddEvent(int root_id, string title,string content) { Event Event = new Event(); >>>>>>> 3aabe62cdccf29aead7c454a773c6bc3e00d87ab Event.Title = title; Event.Content = content; Event.RootID = root_id; Event.Time = DateTime.Now; using (DB db = new DB()) { db.Configuration.ProxyCreationEnabled = false; db.Events.Add(Event); db.SaveChanges(); } return "ok"; }
public static List<File> GetFilesListByUserId(int userID) { List<File> Files = new List<File>(); Dal.DB db = new DB(); db.Configuration.ProxyCreationEnabled = false; Files = (from f in db.Files where f.UserID == userID select f).ToList(); foreach (File File in Files) { File.User = db.Users.Find(File.UserID); File.User.DepartmentTitle = db.Departments.Find(File.User.ID).Title; } return Files; }
protected void Upload_Click(object sender, EventArgs e) { if (upFile.HasFile) { var filename = DateTime.Now.ToString("yyMMddHHmmss") + System.IO.Path.GetExtension(upFile.FileName); System.IO.File.WriteAllBytes(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "\\Uploads\\" + filename, upFile.FileBytes); } File File = new File(); File.Time = DateTime.Now; File.FileName = upFile.FileName; File.UserID =Convert.ToInt32(user_id); using (DB db = new DB()) { db.Files.Add(File); db.SaveChanges(); } }
protected void btnSubmitUpdate_Click(object sender, EventArgs e) { int sid = Convert.ToInt32(Request.QueryString["id"]); User User=(User)Session["User"]; Schedule Schedule = new Schedule(); using (Dal.DB db = new Dal.DB()) { Schedule = db.Schedules.Find(sid); Schedule.Title = txtEditScheduleName.Text; Schedule.Content = txtEditScheduleContent.Text; Schedule.Time = DateTime.Now; Schedule.ToUserID = Convert.ToInt32(ddlEditScheduleToUser.SelectedValue); Schedule.SubmittionUserID = User.ID; Schedule.DepartmentID = Convert.ToInt32(ddlEditScheduleDepartment.SelectedValue); db.SaveChanges(); } Response.Redirect("Admin_Schedules.aspx"); }
protected void Page_Load(object sender, EventArgs e) { User User = (User)Session["User"]; if (User != null) { user_id = User.ID; } using (Dal.DB db = new Dal.DB()) { var departments = (from d in db.Departments select d).ToList(); foreach (var d in departments) { ListItem item = new ListItem(); item.Text = d.Title; item.Value = d.ID.ToString(); cbbDepartment.Items.Add(item); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { using (Dal.DB db = new Dal.DB()) { int uid = Convert.ToInt32(Request.QueryString["ID"]); var user = db.Users.Find(uid); if (!string.IsNullOrEmpty(txtPassword.Text)) { user.Password = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(txtPassword.Text)); } user.DepartmentID = Convert.ToInt32(cbbDepartment.SelectedValue); if (user.DepartmentID == 0) user.DepartmentID = null; user.Role = (Entity.UserRole)Convert.ToInt32(cbbRole.SelectedValue); user.Name = txtName.Text; if (FileUpload1.HasFile) { user.Avatar = FileUpload1.FileBytes; } db.SaveChanges(); imgAvatar.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(user.Avatar); } }
protected void ddlEditScheduleDepartment_SelectedIndexChanged(object sender, EventArgs e) { List<User> Users = new List<Entity.User>(); int? DepartmentID =Convert.ToInt32(ddlEditScheduleDepartment.SelectedValue); using (Dal.DB db = new Dal.DB()) { Users = db.Users.Where(u => u.DepartmentID == DepartmentID).ToList(); } ddlEditScheduleToUser.Items.Clear(); if (Users.Count== 0) { ddlEditScheduleToUser.Items.Add("无"); ddlEditScheduleToUser.Items.FindByText("无").Value = "0"; } else { foreach (User User in Users) { ddlEditScheduleToUser.Items.Add(User.Username); ddlEditScheduleToUser.Items.FindByText(User.Username).Value = User.ID.ToString(); // ddlEditScheduleToUser.SelectedItem.Value = Schedule.ToUserID.ToString(); } } }
public static List<Schedule> GetSchedulesListByUserId(int userID) { List<Schedule> Schedules = new List<Schedule>(); List<User> Users = new List<User>(); Dal.DB db = new DB(); db.Configuration.ProxyCreationEnabled = false; Schedules = (from s in db.Schedules where s.ToUserID==userID select s).ToList(); foreach (Schedule Schedule in Schedules) { Schedule.ToUser = db.Users.Find(Schedule.ToUserID); Schedule.SubmittionUser = db.Users.Find(Schedule.SubmittionUserID); Schedule.Department = db.Departments.Find(Schedule.DepartmentID); } return Schedules; }
public static string AddSchedule(int submit_user_id, int to_user_id, string title, string content, int department_id) { Schedule Schedule = new Schedule(); Schedule.ToUserID = to_user_id; Schedule.SubmittionUserID = submit_user_id; Schedule.Title = title; Schedule.Content = content; Schedule.DepartmentID = department_id; Schedule.Time = DateTime.Now; using (Dal.DB db = new DB()) { db.Schedules.Add(Schedule); db.SaveChanges(); } return "ok"; }
public static string DeleteEvent(int event_id) { Events Event = new Events(); using(DB db =new DB ()) { Event = db.Events.Find(event_id); db.Events.Remove(Event); db.SaveChanges(); } return "ok"; }