protected void dtgAccount_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "save")
            {
                try
                {
                    int Id = int.Parse(e.CommandArgument.ToString());
                    Manager mn = _db.Managers.Where(x => x.Id == Id).First();
                    mn.Name = (e.Item.FindControl("tbName") as TextBox).Text;
                    mn.Phone = (e.Item.FindControl("tbPhone") as TextBox).Text;
                    mn.Skype = (e.Item.FindControl("tbSkype") as TextBox).Text;
                    mn.Active = (e.Item.FindControl("chkActive") as CheckBox).Checked;
                    DropDownList ddlSex = (e.Item.FindControl("ddlSex") as DropDownList);
                    if (ddlSex.SelectedValue == "0")
                    {
                        mn.Sex = false;
                    }
                    else
                        mn.Sex = true;
                    if (mn.UserName != "phuongnv")
                    {
                        int id = int.Parse((e.Item.FindControl("ddlPermission") as DropDownList).SelectedValue);
                        mn.ManagerPermission = _db.ManagerPermissions.Where(x => x.Id == id).First();
                    }
                    _db.SaveChanges();
                    Notify.ShowMessageSuccess("Lưu thành công !", Page);
                }
                catch
                {
                    Notify.ShowMessageError("Lưu bị lỗi !", Page);
                }
            }
            else if (e.CommandName == "delete")
            {
                try
                {
                    int Id = int.Parse(e.CommandArgument.ToString());
                    Manager mn = _db.Managers.Where(x => x.Id == Id).First();
                    if (mn.UserName == "phuongnv")
                    {
                        Notify.ShowMessageError("Không thể xóa tài khoản mặc định !", Page);
                        return;
                    }
                    _db.Managers.Remove(mn);
                    _db.SaveChanges();
                    Notify.ShowMessageSuccess("Xóa thành công !", Page);
                }
                catch
                {
                    Notify.ShowMessageError("Xóa bị lỗi !", Page);
                }
            }
            else if (e.CommandName == "add")
            {
                try
                {
                    Manager mn = new Manager();
                    mn.UserName = (e.Item.FindControl("tbUserName") as TextBox).Text;
                    mn.Password = "******";
                    if (mn.UserName.Trim().Length == 0)
                    {
                        Notify.ShowMessageError("Bắt buộc phải có UserName !", Page);
                        return;
                    }
                    if (_db.Managers.Where(x => x.UserName == mn.UserName).Count() > 0)
                    {
                        Notify.ShowMessageError("Tài khoản đã tồn tại !", Page);
                        return;
                    }
                    mn.Name = (e.Item.FindControl("tbName") as TextBox).Text;
                    mn.Phone = (e.Item.FindControl("tbPhone") as TextBox).Text;
                    mn.Email = (e.Item.FindControl("tbEmail") as TextBox).Text;
                    mn.Skype = (e.Item.FindControl("tbSkype") as TextBox).Text;
                    mn.Active = (e.Item.FindControl("chkActive") as CheckBox).Checked;
                    mn.BirthDay = DateTime.Parse((e.Item.FindControl("tbBirthDay") as TextBox).Text, CultureInfo.GetCultureInfo("en-Gb"));
                    DropDownList ddlSex = (e.Item.FindControl("ddlSex") as DropDownList);
                    if (ddlSex.SelectedValue == "0")
                    {
                        mn.Sex = false;
                    }
                    else
                        mn.Sex = true;

                    int id = int.Parse((e.Item.FindControl("ddlPermission") as DropDownList).SelectedValue);
                    mn.ManagerPermission = _db.ManagerPermissions.Where(x => x.Id == id).First();
                    _db.Managers.Add(mn);
                    _db.SaveChanges();
                    Notify.ShowMessageSuccess("Thêm thành công !", Page);
                }
                catch
                {
                    Notify.ShowMessageError("Thêm bị lỗi !", Page);
                }
            }
            LoadData();
        }
 public List<Order> GetListOrder(Manager currentUser)
 {
     if (currentUser.ManagerPermission.Permission == Permission.Admin)
         return this.Orders.ToList();
     return Orders.ToList();
 }