public ActionResult _AddCategory(string fullName, string note, bool status = false)
        {
            // kiểm tra quyền thêm
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db = new ManagerCategoryBusiness();

            tbl_LoaiSP serviceCustomer = new tbl_LoaiSP();

            serviceCustomer.category_name = fullName;
            serviceCustomer.description   = note;
            serviceCustomer.isactive      = status;
            var result = db.AddCategory(serviceCustomer);

            // luu log - thêm mới
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Create.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = serviceCustomer }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult _EditBranch(int id = 0, string name = "", string add = "", string phone = "", string tax = "", string brandcode = "", string shortname = "", string city = "", bool status = false)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var    db   = new BranchBusiness();
            Branch item = new Branch();

            item.Id          = id;
            item.Name        = name;
            item.AddressName = add;
            item.Phone       = phone;
            item.Tax_Number  = tax;
            item.Branch_code = brandcode;
            item.ShortName   = shortname;
            item.City        = city;
            item.is_active   = Convert.ToInt32(status);

            var result = db.BS_EditBrandch(item);

            // luu log - sửa
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Update.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = item }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _EditPage(FormCollection formCollection)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var           db   = new gioithieuwebsiteBusiness();
            tbl_gioithieu item = new tbl_gioithieu();

            item.id           = int.Parse(formCollection.Get("id"));
            item.noidung      = formCollection.Get("noidung");
            item.ngaychinhsua = DateTime.Now;
            item.tennguoisua  = user.FullName;

            var result = db.BS_EditPage(item);

            // luu log - sửa
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Update.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = item }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public ActionResult _AddMenuIntoAccount(int idAccount, int idRole, int idMenu, string IsRead, string IsCreate, string IsUpdate, string IsDelete, string IsExport)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var            db   = new RoleUserBusiness();
            MenuPermission item = new MenuPermission();

            item.MenuId   = idMenu;
            item.RoleId   = idRole;
            item.UserId   = idAccount;
            item.IsRead   = bool.Parse(IsRead);
            item.IsCreate = bool.Parse(IsCreate);
            item.IsUpdate = bool.Parse(IsUpdate);
            item.IsDelete = bool.Parse(IsDelete);
            item.IsExport = bool.Parse(IsExport);

            var result = db.AddMenuIntoAccountRole(item);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public ActionResult _AddNguonnhap(string fullName, string address, string phone, string code, string note, int branchId = 0)
        {
            // kiểm tra quyền thêm
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db = new quanlynguonnhapBusiness();

            sys_nguonnhap serviceCustomer = new sys_nguonnhap();

            serviceCustomer.tennguon    = fullName;
            serviceCustomer.diachi      = address;
            serviceCustomer.sdt         = phone;
            serviceCustomer.code        = code;
            serviceCustomer.description = note;
            serviceCustomer.isactive    = true;
            serviceCustomer.id_center   = branchId;

            var result = db.AddNguonnhap(serviceCustomer);

            // luu log - thêm mới
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Create.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = serviceCustomer }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public ActionResult _AddNewRoleUserMenu()
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }


            int userid   = user.Id;
            int roleid   = user.Roleid;
            int branchId = user.BranchId;

            List <int>    lstAccount    = (List <int>)Newtonsoft.Json.JsonConvert.DeserializeObject(HttpContext.Request["listAccount"], typeof(List <int>));
            List <int>    listMenu      = (List <int>)Newtonsoft.Json.JsonConvert.DeserializeObject(HttpContext.Request["listMenu"], typeof(List <int>));
            List <string> lstOptionMenu = (List <string>)Newtonsoft.Json.JsonConvert.DeserializeObject(HttpContext.Request["lstOptionMenu"], typeof(List <string>));

            bool statusCheckAllAcount = false;
            int  RoleId = 0;

            int.TryParse(HttpContext.Request["roleId"], out RoleId);
            bool.TryParse(HttpContext.Request["statusCheckAllAcount"], out statusCheckAllAcount);

            var db = new RoleUserBusiness();

            var result = db._AddNewRoleUserMenu(lstAccount, listMenu, lstOptionMenu, RoleId, statusCheckAllAcount);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public ActionResult ChangeStatusBranch(int id, int status = 0)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }
            var db = new BranchBusiness();

            Branch item = new Branch();

            item.Id        = id;
            item.is_active = status;

            var result = db.BS_ChangeStatusBranch(item);

            // luu log - sửa
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Update.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = item }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        public ActionResult _EditUnit(string fullName, string note, int branchId = 0, int id = 0)
        {
            // kiểm tra quyền thêm sửa
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var      db = new quanlydonviBusiness();
            tbl_Unit serviceCustomer = new tbl_Unit();

            serviceCustomer.unit_name   = fullName;
            serviceCustomer.description = note;
            serviceCustomer.id_center   = branchId;
            serviceCustomer.id          = id;

            var result = db.EditUnit(serviceCustomer);

            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Update.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { log = "CapNhatThongTinDVT", newtdata = serviceCustomer }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _ThemmoiSP(int id_product = 0, int id = 0)
        {
            // kiểm tra quyền thêm
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db = new ManagerCategoryBusiness();

            tbl_detail_category item = new tbl_detail_category();

            item.id_product  = id_product;
            item.id_category = id;
            item.isactive    = true;
            var result = db.AddProductToCategory(item);

            // luu log - thêm mới
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Create.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = item }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _AddCustomer(string fullName, string cmt, string birth, string address, string phone, string note, int branchId = 0)
        {
            // kiểm tra quyền thêm
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db = new CustomerBusiness();

            service_customer serviceCustomer = new service_customer();


            var getbrand = entity.Branch.FirstOrDefault(m => m.Id == branchId);

            serviceCustomer.fullname    = fullName;
            serviceCustomer.id_card     = cmt;
            serviceCustomer.address     = address;
            serviceCustomer.mobile      = phone;
            serviceCustomer.note        = note;
            serviceCustomer.status      = 1;
            serviceCustomer.id_center   = branchId;
            serviceCustomer.code_center = getbrand.Branch_code;
            serviceCustomer.created_by  = user.FullName;
            serviceCustomer.created_at  = DateTime.Now;

            DateTime _birth;

            if (!string.IsNullOrEmpty(birth))
            {
                if (!DateTime.TryParseExact(birth, "dd/MM/yyyy", CultureInfo.InvariantCulture,
                                            DateTimeStyles.None, out _birth))
                {
                    SystemMessage systemMessage = new SystemMessage();
                    systemMessage.IsSuccess = false;
                    systemMessage.Message   = string.Format(SystemMessageConst.ValidateConst.DateIsNotValid, "Ngày sinh");
                    return(Json(new { result = systemMessage }, JsonRequestBehavior.AllowGet));
                }
                serviceCustomer.birthday = _birth;
            }
            var result = db.AddCustomer(serviceCustomer);

            // luu log - thêm mới
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Create.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = serviceCustomer }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #11
0
        public ActionResult _ChinhSua_Anh_TheoSP(int id_img, int id_product, string txt_des)
        {
            var db = new ProductServiceBusiness();
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }
            var result = db.BS_ChinhSua_Anh_TheoSP(id_img, id_product, txt_des);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _CongSL_Chil_SP(int id_p, string groupcode)
        {
            var db = new nhap_tonkhoBussiness();
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }
            var result = db.BS_CongSL_Chil_SP(id_p, groupcode);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #13
0
        public ActionResult _Chinhsua_TT_SP(int id, string tensp, string codesp, string loaisp, int unitsp, string gioithieusp, bool status = false)
        {
            var db = new ProductServiceBusiness();
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }
            var result = db.BS_Chinhsua_TT_SP(id, tensp, codesp, loaisp, unitsp, gioithieusp, status);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #14
0
        public ActionResult _ThemMoi_Gia_SP(int gianhap, int giaxuat, string type_price, int id_product)
        {
            var db = new ProductServiceBusiness();
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }
            var result = db.BS_ThemMoi_Gia_SP(gianhap, giaxuat, type_price, id_product);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #15
0
        public ActionResult _XoathongsoTheoSP(int id_config_attr = 0)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Delete);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db     = new ProductServiceBusiness();
            var result = db.BS_XoathongsoTheoSP(id_config_attr);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #16
0
        public ActionResult DeleteUserAndRole(int idrole, int iduser, int idroleuser)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Delete);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db     = new RoleUserBusiness();
            var result = db.DeleteRoleUserAndMenu(idrole, iduser, idroleuser);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #17
0
        public ActionResult _xuat_ban_daily(FormCollection formCollection)
        {
            // kiểm tra quyền thêm sửa
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            Add_Bill item = new Add_Bill();

            item.type     = "DL";
            item.loaibill = 1;
            item.data     = formCollection.Get("data");

            item.billType   = formCollection.Get("billType");
            item.bonusTotal = long.Parse(formCollection.Get("bonusTotal"));
            item.total      = long.Parse(formCollection.Get("total"));
            item.discount   = long.Parse(formCollection.Get("discount"));

            item.billNumber = formCollection.Get("billNumber");
            item.ngayxuat   = formCollection.Get("ngayxuat");
            item.nguoixuat  = formCollection.Get("nguoixuat");
            item.notebill   = formCollection.Get("notebill");

            item.tenkh        = formCollection.Get("tenkh");
            item.diachi       = formCollection.Get("diachi");
            item.nguoidaidien = formCollection.Get("nguoidaidien");
            item.dienthoai    = formCollection.Get("dienthoai");

            item.id_center       = user.BranchId;
            item.id_thaotac      = user.Id;
            item.code_center     = user.Code_brand;
            item.tennguoithaotac = user.FullName;

            var db = new xuat_dailyBusiness();

            var result = db.AddBillProduct(item);

            // luu log - thêm mới
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Create.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = item }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _NhapKho(int id_product = 0, int soluong = 0, int id_nguonnhap = 0, float tongtien = 0, string group_code_product = "", string ngaynhap = "", string mota = "")
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db = new nhap_tonkhoBussiness();

            sys_Nhap item = new sys_Nhap();

            System.Globalization.CultureInfo enUS = new System.Globalization.CultureInfo("en-US");
            DateTime n_n;

            DateTime.TryParseExact(ngaynhap, "dd/MM/yyyy", enUS,
                                   System.Globalization.DateTimeStyles.None,
                                   out n_n);


            double tb = 0;

            tb = Math.Round(tongtien / soluong, 0);

            item.id_product         = id_product;
            item.soluong            = soluong;
            item.id_nguonnhap       = id_nguonnhap;
            item.tongtien           = tongtien;
            item.group_code_product = group_code_product;
            item.ngaynhap           = n_n;
            item.mota         = mota;
            item.trangthai    = true;
            item.nguoinhap    = user.Id;
            item.id_center    = user.BranchId;
            item.giatrungbinh = tb;

            var result = db.BS_NhapKho(item);

            // luu log - thêm mới
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Create.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = item }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _EditCustomer(string fullName, string cmt, string birth, string address, string phone, string note, int branchId = 0, int id = 0)
        {
            // kiểm tra quyền thêm sửa
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }



            var db = new CustomerBusiness();
            service_customer serviceCustomer = new service_customer();

            serviceCustomer.fullname  = fullName;
            serviceCustomer.id_card   = cmt;
            serviceCustomer.address   = address;
            serviceCustomer.mobile    = phone;
            serviceCustomer.note      = note;
            serviceCustomer.id_center = branchId;
            serviceCustomer.id        = id;

            DateTime _birth;

            if (!string.IsNullOrEmpty(birth))
            {
                if (!DateTime.TryParseExact(birth, "dd/MM/yyyy", CultureInfo.InvariantCulture,
                                            DateTimeStyles.None, out _birth))
                {
                    SystemMessage systemMessage = new SystemMessage();
                    systemMessage.IsSuccess = false;
                    systemMessage.Message   = string.Format(SystemMessageConst.ValidateConst.DateIsNotValid, "Ngày sinh");
                    return(Json(new { result = systemMessage }, JsonRequestBehavior.AllowGet));
                }
                serviceCustomer.birthday = _birth;
            }
            var result = db.EditCustomer(serviceCustomer);

            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Update.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { log = "CapNhatThongTinKH", newtdata = serviceCustomer }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));


            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #20
0
        public ActionResult DeleteMenuInRoleAccount(int id)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Delete);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var            db   = new RoleUserBusiness();
            EditSelectMenu item = new EditSelectMenu();

            item.id = id;
            var result = db.Delete_Select_Menu(item);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #21
0
        public ActionResult _AddAccountIntoRole(int idAccount, int idRole)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Addnew);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var            db   = new RoleUserBusiness();
            MenuPermission item = new MenuPermission();

            item.RoleId = idRole;
            item.UserId = idAccount;
            var result = db.Add_Account_Into_Role(item);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #22
0
        public ActionResult UpdateSelectInMenu(int id, string type, bool gt)
        {
            // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var            db   = new RoleUserBusiness();
            EditSelectMenu item = new EditSelectMenu();

            item.id   = id;
            item.type = type;
            item.gt   = gt;
            var result = db.Edit_Select_Menu(item);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Example #23
0
        public ActionResult DeleteUnit(int id)
        {
            // kiểm tra quyền thêm xóa
            var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Delete);

            if (sys.IsSuccess == false)
            {
                return(Json(new { result = sys }, JsonRequestBehavior.AllowGet));
            }

            var db     = new quanlydonviBusiness();
            var result = db.DeleteUnitById(id);

            // luu log - xóa
            CheckRuleAndSaveLog.ReturnCheckRuleAndSaveLog(DbLogType.Delete.ToString(), result.IsSuccess, JsonConvert.SerializeObject(new { data = new { id = id } }, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }