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");
     }
 }
 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");
 }
Exemplo n.º 3
0
 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 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 = "";
        }
Exemplo n.º 5
0
 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");
 }
Exemplo n.º 6
0
        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";
        }
Exemplo n.º 7
0
        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");
        }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
        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";
           
        }
Exemplo n.º 11
0
 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";
 }