Пример #1
0
 public void ActionSaveNew(ModThongBaoSuCoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Пример #2
0
 public void ActionSaveNew(FormBaoCaoKetThucSuCoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Пример #3
0
 public void ActionSave(ModThongBaoSuCoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         SaveRedirect();
     }
 }
Пример #4
0
 public void ActionApply(ModBaoCaoKetThucSuCoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         ApplyRedirect(model.RecordID, entity.ID);
     }
 }
Пример #5
0
 public void ActionSaveNew(ModDichVuCanhBaoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Пример #6
0
 public void ActionSave(FormBaoCaoKetThucSuCoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         SaveRedirect();
     }
 }
Пример #7
0
 public void ActionSave(ModDichVuCanhBaoModel model, MAppend append)
 {
     if (ValidSave(model, append))
     {
         SaveRedirect();
     }
 }
Пример #8
0
        private bool ValidSave(FormBaoCaoKetThucSuCoModel model, MAppend append)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
            {
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");
            }

            //kiem tra ten
            if (entity.Name.Trim() == string.Empty)
            {
                CPViewPage.Message.ListMessage.Add("Nhập tên.");
            }

            //kiem tra chuyen muc
            //if (entity.MenuID < 1)
            //    CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                //neu khong nhap code -> tu sinh
                if (entity.Code.Trim() == string.Empty)
                {
                    entity.Code = Data.GetCode(entity.Name);
                }

                //cap nhat state
                entity.State = GetState(model.ArrState);

                DateTime date            = DateTime.Now;
                string   ngayGioPhatHien = append.Ngay + " " + append.GioPhut;
                if (!string.IsNullOrEmpty(ngayGioPhatHien))
                {
                    entity.NgayGioPhatHien = HL.Core.Global.Convert.ToDateTime(ngayGioPhatHien);
                }
                else
                {
                    entity.NgayGioPhatHien = DateTime.MinValue;
                }

                ViewBag.Data = entity;

                //save
                ModBaoCaoKetThucSuCoService.Instance.Save(entity);

                return(true);
            }

            return(false);
        }
Пример #9
0
        public void SaveOther(int id, ModDauMoiUCSCEntity entityDm, MAppend append)
        {
            ViewBag.HoSo   = entity;
            ViewBag.DauMoi = entityDm;

            WebMenuEntity menu = WebMenuService.Instance.CreateQuery().Where(o => o.Activity == true && o.Type == "DauMoiUCSC" && o.Code == "Chinh").ToSingle();

            entityDm.HSThanhVienUCSCID = id;
            entityDm.MenuID            = menu.ID;
            entityDm.Order             = GetMaxOrder_DauMoi();
            entityDm.Published         = DateTime.Now;
            entityDm.Activity          = true;
            int id1 = ModDauMoiUCSCService.Instance.Save(entityDm);

            //He thong thong tin
            var arr = append.M.Split(';');
            List <ModHeThongThongTinEntity> entityHTTT = new List <ModHeThongThongTinEntity>();

            for (int i = 0; i < arr.Length; i++)
            {
                if (string.IsNullOrEmpty(arr[i]))
                {
                    continue;
                }
                var tmp = arr[i].Split('_');
                int m   = HL.Core.Global.Convert.ToInt(tmp[0], 0);
                if (m <= 0 || tmp.Length != 2)
                {
                    continue;
                }
                var lstName = tmp[1].Split(',');

                for (int j = 0; j < lstName.Length; j++)
                {
                    if (string.IsNullOrEmpty(lstName[j]))
                    {
                        continue;
                    }
                    var entityTmp = new ModHeThongThongTinEntity
                    {
                        DauMoiUCSCID = id1,
                        MenuID       = m,
                        Name         = lstName[j],
                        Code         = Data.GetCode(lstName[j]),
                        Published    = DateTime.Now,
                        Order        = GetMaxOrder_HTTT(),
                        Activity     = true
                    };
                    entityHTTT.Add(entityTmp);
                }
                ModHeThongThongTinService.Instance.Save(entityHTTT);
            }
        }
Пример #10
0
        public void ActionAdd(ModBaoCaoDienBienSuCoEntity entity, MAppend append, string endCode)
        {
            if (entity.ID == 0)
            {
                entity = new ModBaoCaoDienBienSuCoEntity();

                // khoi tao gia tri mac dinh khi insert
                entity.MenuID = 0;
                entity.UserID = Lib.Global.CPLogin.UserID;
                DateTime d = DateTime.Now;
                entity.ChiTiet_NgayTao = d;
                entity.Activity        = CPViewPage.UserPermissions.Approve;
            }
            else
            {
                bool isValid = ValidBCDienBien(ref entity, append, endCode);
                ViewBag.BaoCao = entity;

                if (isValid == true)
                {
                    int                 userId = HL.Lib.Global.CPLogin.UserIDOnWeb;
                    string              ec     = endCode.ToLower();
                    string[]            ecArr  = ec.Split('-');
                    string              codes  = ecArr[0].ToString();
                    ModBaoCaoSuCoEntity sc     = ModBaoCaoSuCoService.Instance.CreateQuery()
                                                 .Where(userId > 0, o => o.UserID == userId)
                                                 .Where(o => o.Code == codes)
                                                 .ToSingle();
                    if (sc != null)
                    {
                        string code = "BCDBSC" + ModBaoCaoDienBienSuCoService.Instance.GetMaxID();
                        entity.Name             = code;
                        entity.Code             = Data.GetCode(code);
                        entity.UserID           = Lib.Global.CPLogin.UserIDOnWeb;
                        entity.Activity         = true;
                        entity.BaoCaoSuCoID     = sc.ID;
                        entity.ToChuc_Ten       = sc.Name;
                        entity.ToChuc_DiaChi    = sc.Address;
                        entity.ToChuc_DienThoai = sc.Phone;
                        entity.ToChuc_Email     = sc.Email;
                        int id = ModBaoCaoDienBienSuCoService.Instance.Save(entity);

                        CPViewPage.Alert("Thêm báo cáo diễn biến thành công.");
                        CPViewPage.RefreshPage();
                        //ViewPage.Navigate("/vn/Bao-cao-su-co/" + sc.Code + "-bc-dien-bien-su-co.aspx");
                    }
                }
            }

            ViewBag.Data = entity;
        }
Пример #11
0
        private bool ValidSave(ModDichVuCanhBaoModel model, MAppend append)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Data  = entity;
            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
            {
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");
            }

            //kiem tra ten
            if (entity.Name.Trim() == string.Empty)
            {
                CPViewPage.Message.ListMessage.Add("Nhập tên đơn vị đăng ký.");
            }

            //kiem tra chuyen muc
            //if (entity.MenuID < 1)
            //    CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                //neu khong nhap code -> tu sinh
                if (entity.Code.Trim() == string.Empty)
                {
                    entity.Code = Data.GetCode(entity.Name);
                }

                entity.Time = TimeSpan.Parse(append.ThoiGian);

                //cap nhat state
                entity.State = GetState(model.ArrState);

                //save
                ModDichVuCanhBaoService.Instance.Save(entity);

                return(true);
            }

            return(false);
        }
Пример #12
0
        private bool ValidBCDienBien(ref ModBaoCaoDienBienSuCoEntity entity, MAppend append, string endCode)
        {
            if (string.IsNullOrEmpty(entity.ChiTiet_MoTa))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Mô tả diễn biến sự cố.");
            }

            if (CPViewPage.Message.ListMessage.Count > 0)
            {
                string message = @"Thông tin còn thiếu hoặc chưa hợp lệ: \n";

                for (int i = 0; i < CPViewPage.Message.ListMessage.Count; i++)
                {
                    message += @"\n + " + CPViewPage.Message.ListMessage[i];
                }

                CPViewPage.Alert(message);
                return(false);
            }

            return(true);
        }
Пример #13
0
        private bool ValidSave(ModBaoCaoBanDauSuCoModel model, MInfoMagicModel modelInfo, MAppend append)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Data  = entity;
            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
            {
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");
            }

            //kiem tra ten
            if (entity.Name.Trim() == string.Empty)
            {
                CPViewPage.Message.ListMessage.Add("Nhập tên.");
            }

            //kiem tra chuyen muc
            //if (entity.MenuID < 1)
            //    CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                //neu khong nhap code -> tu sinh
                if (entity.Code.Trim() == string.Empty)
                {
                    entity.Code = Data.GetCode(entity.Name);
                }

                //cap nhat state
                entity.State = GetState(model.ArrState);

                //save
                int id = ModBaoCaoBanDauSuCoService.Instance.Save(entity);
                if (model.RecordID > 0)
                {
                    UpdateOther(entity, modelInfo, append);
                }
                else
                {
                    SaveOther(id, modelInfo, append);
                }

                return(true);
            }

            return(false);
        }
Пример #14
0
 public void ActionSaveNew(ModBaoCaoBanDauSuCoModel model, MInfoMagicModel modelInfo, MAppend append)
 {
     if (ValidSave(model, modelInfo, append))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Пример #15
0
 public void ActionSave(ModBaoCaoBanDauSuCoModel model, MInfoMagicModel modelInfo, MAppend append)
 {
     if (ValidSave(model, modelInfo, append))
     {
         SaveRedirect();
     }
 }
Пример #16
0
        public void UpdateOther(ModHSThanhVienUCSCEntity entityHs, ModDauMoiUCSCEntity entityDm, MAppend append)
        {
            int userId = HL.Lib.Global.CPLogin.UserID;
            var entity = ModHSThanhVienUCSCService.Instance.CreateQuery()
                         //.Where(userId > 0, o => o.UserID == userId)
                         .Where(o => o.Code == entityHs.Code)
                         .ToSingle();

            if (entity != null)
            {
                DateTime date = DateTime.Now;

                //Thong tin chung
                entityHs.ID         = entity.ID;
                entityHs.UserID     = entity.UserID;
                entityHs.UserID1    = entity.UserID1;
                entityHs.MenuID     = entity.MenuID;
                entityHs.State      = entity.State;
                entityHs.Name       = entity.Name;
                entityHs.Code       = entity.Code;
                entityHs.Order      = entity.Order;
                entityHs.Published  = entity.Published;
                entityHs.Published1 = date;
                entityHs.Activity   = false;
                ModHSThanhVienUCSCService.Instance.Save(entityHs);

                //Dau moi UCSC
                var dm = ModDauMoiUCSCService.Instance.CreateQuery().Where(o => o.Activity == true && o.HSThanhVienUCSCID == entity.ID).ToSingle();
                entityDm.ID = dm.ID;
                entityDm.HSThanhVienUCSCID = dm.HSThanhVienUCSCID;
                entityDm.MenuID            = dm.MenuID;
                entityDm.State             = dm.State;
                entityDm.Name      = append.Name1;
                entityDm.Code      = Data.GetCode(append.Name1);
                entityDm.Order     = dm.Order;
                entityDm.Published = entity.Published;
                entityDm.Activity  = dm.Activity;
                ModDauMoiUCSCService.Instance.Save(entityDm);

                //He thong thong tin
                var httt = ModHeThongThongTinService.Instance.CreateQuery().Where(o => o.Activity == true && o.DauMoiUCSCID == dm.ID).ToList();
                if (httt != null)
                {
                    ModHeThongThongTinService.Instance.Delete(httt);
                }
                var arr = append.M.Split(';');
                List <ModHeThongThongTinEntity> entityHTTT = new List <ModHeThongThongTinEntity>();
                for (int i = 0; i < arr.Length; i++)
                {
                    if (string.IsNullOrEmpty(arr[i]))
                    {
                        continue;
                    }
                    var tmp = arr[i].Split('_');
                    int m   = HL.Core.Global.Convert.ToInt(tmp[0], 0);
                    if (m <= 0 || tmp.Length != 2)
                    {
                        continue;
                    }
                    var lstName = tmp[1].Split(',');

                    for (int j = 0; j < lstName.Length; j++)
                    {
                        if (string.IsNullOrEmpty(lstName[j]))
                        {
                            continue;
                        }
                        var entityTmp = new ModHeThongThongTinEntity
                        {
                            DauMoiUCSCID = dm.ID,
                            MenuID       = m,
                            Name         = lstName[j],
                            Code         = Data.GetCode(lstName[j]),
                            Published    = DateTime.Now,
                            Order        = GetMaxOrder_HTTT(),
                            Activity     = true
                        };
                        entityHTTT.Add(entityTmp);
                    }
                    ModHeThongThongTinService.Instance.Save(entityHTTT);
                }

                ViewBag.HoSo   = entityHs;
                ViewBag.DauMoi = entityDm;
                ViewBag.HTTT   = entityHTTT;
            }
        }
Пример #17
0
 public void ActionSaveNew(ModHSThanhVienUCSCModel model, ModDauMoiUCSCEntity entityDm, MAppend append)
 {
     if (ValidSave(model, entityDm, append))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Пример #18
0
        private void SaveOther(int id, MInfoMagicModel modelInfo, MAppend append)
        {
            DateTime date            = DateTime.Now;
            string   ngayGioPhatHien = append.Ngay + " " + append.GioPhut;

            string[] arr = append.ThoiGian.Split('/');
            string   thoiGianThucHien = "";

            if (arr.Length == 5)
            {
                thoiGianThucHien = arr[0] + "/" + arr[1] + "/" + arr[2] + " " + arr[3] + ":" + arr[4];
            }
            string code = "BCBDSC" + ModBaoCaoBanDauSuCoService.Instance.GetMaxID();

            //Cach thuc phat hien
            int num = modelInfo.chkCachThuc != null ? modelInfo.chkCachThuc.Length : 0;

            for (int i = 0; i < num; i++)
            {
                string[] tmp = modelInfo.chkCachThuc[i].Split('_');
                if (tmp.Length == 3)
                {
                    ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                    {
                        BaoCaoBanDauSuCoID = id,
                        Order     = GetMaxOrder_InfoMagic(),
                        Published = date,
                        Activity  = true
                    };
                    entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                    if (tmp[0] == "1")
                    {
                        int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                        if (modelInfo.txtCachThuc != null && modelInfo.txtCachThuc.Length >= idx)
                        {
                            entityTmp.Name = modelInfo.txtCachThuc[idx];
                            entityTmp.Code = Data.GetCode(modelInfo.txtCachThuc[idx]);
                        }
                    }
                    ModInfoMagicService.Instance.Save(entityTmp);
                }
            }

            //Da gui thong bao su co
            num = modelInfo.chkThongBao != null ? modelInfo.chkThongBao.Length : 0;
            for (int i = 0; i < num; i++)
            {
                string[] tmp = modelInfo.chkThongBao[i].Split('_');
                if (tmp.Length == 3)
                {
                    ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                    {
                        BaoCaoBanDauSuCoID = id,
                        Order     = GetMaxOrder_InfoMagic(),
                        Published = date,
                        Activity  = true
                    };
                    entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                    if (tmp[0] == "1")
                    {
                        int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                        if (modelInfo.txtThongBao != null && modelInfo.txtThongBao.Length >= idx)
                        {
                            entityTmp.Name = modelInfo.txtThongBao[idx];
                            entityTmp.Code = Data.GetCode(modelInfo.txtThongBao[idx]);
                        }
                    }
                    ModInfoMagicService.Instance.Save(entityTmp);
                }
            }

            //Dich vu
            num = modelInfo.chkDichVu != null ? modelInfo.chkDichVu.Length : 0;
            for (int i = 0; i < num; i++)
            {
                string[] tmp = modelInfo.chkDichVu[i].Split('_');
                if (tmp.Length == 3)
                {
                    ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                    {
                        BaoCaoBanDauSuCoID = id,
                        Order     = GetMaxOrder_InfoMagic(),
                        Published = date,
                        Activity  = true
                    };
                    entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                    if (tmp[0] == "1")
                    {
                        int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                        if (modelInfo.txtDichVu != null && modelInfo.txtDichVu.Length >= idx)
                        {
                            entityTmp.Name = modelInfo.txtDichVu[idx];
                            entityTmp.Code = Data.GetCode(modelInfo.txtDichVu[idx]);
                        }
                    }
                    ModInfoMagicService.Instance.Save(entityTmp);
                }
            }

            //Bien phap
            num = modelInfo.chkBienPhap != null ? modelInfo.chkBienPhap.Length : 0;
            for (int i = 0; i < num; i++)
            {
                string[] tmp = modelInfo.chkBienPhap[i].Split('_');
                if (tmp.Length == 3)
                {
                    ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                    {
                        BaoCaoBanDauSuCoID = id,
                        Order     = GetMaxOrder_InfoMagic(),
                        Published = date,
                        Activity  = true
                    };
                    entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                    if (tmp[0] == "1")
                    {
                        int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                        if (modelInfo.txtBienPhap != null && modelInfo.txtBienPhap.Length >= idx)
                        {
                            entityTmp.Name = modelInfo.txtBienPhap[idx];
                            entityTmp.Code = Data.GetCode(modelInfo.txtBienPhap[idx]);
                        }
                    }
                    ModInfoMagicService.Instance.Save(entityTmp);
                }
            }

            //Thong tin gui kem
            num = modelInfo.chkThongTinGuiKem != null ? modelInfo.chkThongTinGuiKem.Length : 0;
            for (int i = 0; i < num; i++)
            {
                string[] tmp = modelInfo.chkThongTinGuiKem[i].Split('_');
                if (tmp.Length == 3)
                {
                    ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                    {
                        BaoCaoBanDauSuCoID = id,
                        Order     = GetMaxOrder_InfoMagic(),
                        Published = date,
                        Activity  = true
                    };
                    entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                    if (tmp[0] == "1")
                    {
                        int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                        if (modelInfo.txtThongTinGuiKem != null && modelInfo.txtThongTinGuiKem.Length >= idx)
                        {
                            entityTmp.Name = modelInfo.txtThongTinGuiKem[idx];
                            entityTmp.Code = Data.GetCode(modelInfo.txtThongTinGuiKem[idx]);
                        }
                        ModInfoMagicService.Instance.Save(entityTmp);
                    }
                }
            }

            ViewBag.BaoCao = entity;
        }
Пример #19
0
        private bool ValidSave(ModThongBaoSuCoModel model, MAppend append)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Data  = entity;
            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
            {
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");
            }

            if (string.IsNullOrEmpty(entity.ToChuc_Ten))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Tên tổ chức/cá nhân thông báo sự cố.");
            }
            if (string.IsNullOrEmpty(entity.ToChuc_DiaChi))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Địa chỉ tổ chức/cá nhân thông báo sự cố.");
            }
            if (string.IsNullOrEmpty(entity.ChiTiet_TenHeThong))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Tên hoặc tên miền, địa chỉ IP của hệ thống thông tin bị sự cố.");
            }
            if (string.IsNullOrEmpty(entity.ChiTiet_TenDonVi))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Tên cơ quan chủ quản hệ thống thông tin bị sự cố.");
            }
            if (string.IsNullOrEmpty(entity.ChiTiet_MoTa))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Mô tả sơ bộ về sự cố.");
            }
            if (string.IsNullOrEmpty(entity.ChiTiet_KetQua))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Kết quả xử lý sự cố đề xuất.");
            }

            // Ngay & thoi gian phat hien su co
            if (entity.ChiTiet_NgayGioPhatHien == DateTime.MinValue)
            {
                CPViewPage.Message.ListMessage.Add("Ngày hoặc Thời gian phát hiện sự cố không hợp lệ.");
            }
            else
            {
                bool hasThoiGian = true;
                if (string.IsNullOrEmpty(append.Ngay))
                {
                    CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Ngày phát hiện sự cố.");
                    hasThoiGian = false;
                }
                if (string.IsNullOrEmpty(append.Gio.ToString()) && string.IsNullOrEmpty(append.Phut.ToString()))
                {
                    CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Thời gian phát hiện sự cố.");
                    hasThoiGian = false;
                }
                if (hasThoiGian == true)
                {
                    string[] arr             = append.GioPhut.Split(':');
                    string   gio             = !string.IsNullOrEmpty(arr[0]) ? arr[0] : "00";
                    string   phut            = !string.IsNullOrEmpty(arr[1]) ? arr[1] : "00";
                    string   ngayGioPhatHien = append.Ngay + " " + gio + ":" + phut;


                    if (Int32.Parse(gio, 0) < 0 || Int32.Parse(gio, 0) > 24 || Int32.Parse(phut, 0) < 0 || Int32.Parse(phut, 0) > 59)
                    {
                        CPViewPage.Message.ListMessage.Add("Thời gian phát hiện sự cố không hợp lệ.");
                        entity.ChiTiet_NgayGioPhatHien = null;
                    }
                    else
                    {
                        DateTime dt = HL.Core.Global.Convert.ToDateTime(ngayGioPhatHien);
                        entity.ChiTiet_NgayGioPhatHien = dt;
                        if (dt == DateTime.MinValue)
                        {
                            CPViewPage.Message.ListMessage.Add("Ngày phát hiện sự cố không hợp lệ.");
                            entity.ChiTiet_NgayGioPhatHien = null;
                        }
                    }
                }
            }

            //kiem tra chuyen muc
            if (entity.MenuID < 1)
            {
                CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");
            }


            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                //neu khong nhap code -> tu sinh
                if (entity.Code.Trim() == string.Empty)
                {
                    entity.Code = Data.GetCode(entity.Name);
                }

                //cap nhat state
                entity.State = GetState(model.ArrState);

                //save
                ModThongBaoSuCoService.Instance.Save(entity);

                return(true);
            }

            return(false);
        }
Пример #20
0
        public void UpdateOther(ModBaoCaoBanDauSuCoEntity entityBc, MInfoMagicModel modelInfo, MAppend append)
        {
            int userId = HL.Lib.Global.CPLogin.UserID;
            var entity = ModBaoCaoBanDauSuCoService.Instance.CreateQuery()
                         //.Where(userId > 0, o => o.UserID == userId)
                         .Where(o => o.Code == entityBc.Code)
                         .ToSingle();

            if (entity != null)
            {
                DateTime date             = DateTime.Now;
                string   ngayGioPhatHien  = append.Ngay + " " + append.GioPhut;
                string[] arr              = append.ThoiGian.Split('/');
                string   thoiGianThucHien = "";
                if (arr.Length == 5)
                {
                    thoiGianThucHien = arr[0] + "/" + arr[1] + "/" + arr[2] + " " + arr[3] + ":" + arr[4];
                }
                if (!string.IsNullOrEmpty(ngayGioPhatHien))
                {
                    entityBc.ChiTiet_NgayGioPhatHien = HL.Core.Global.Convert.ToDateTime(ngayGioPhatHien);
                }
                else
                {
                    entityBc.ChiTiet_NgayGioPhatHien = DateTime.MinValue;
                }
                if (!string.IsNullOrEmpty(thoiGianThucHien))
                {
                    entityBc.ThoiGianThucHien = HL.Core.Global.Convert.ToDateTime(thoiGianThucHien);
                }
                else
                {
                    entityBc.ThoiGianThucHien = DateTime.MinValue;
                }

                entityBc.ID         = entity.ID;
                entityBc.UserID     = entity.UserID;
                entityBc.UserID1    = userId;
                entityBc.MenuID     = entity.MenuID;
                entityBc.State      = entity.State;
                entityBc.Name       = entity.Name;
                entityBc.Code       = entity.Code;
                entityBc.Order      = entity.Order;
                entityBc.Published  = entity.Published;
                entityBc.Published1 = date;
                entityBc.Activity   = false;
                ModBaoCaoBanDauSuCoService.Instance.Save(entityBc);

                //Xoa toan bo thong tin InfoMagic cua Bao cao ban dau su co
                var lstInfoMagic = ModInfoMagicService.Instance.CreateQuery()
                                   .Where(o => o.BaoCaoBanDauSuCoID == entity.ID)
                                   .ToList();
                if (lstInfoMagic != null)
                {
                    ModInfoMagicService.Instance.Delete(lstInfoMagic);
                }

                //Cach thuc phat hien
                int num = modelInfo.chkCachThuc != null ? modelInfo.chkCachThuc.Length : 0;
                for (int i = 0; i < num; i++)
                {
                    string[] tmp = modelInfo.chkCachThuc[i].Split('_');
                    if (tmp.Length == 3)
                    {
                        ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                        {
                            BaoCaoBanDauSuCoID = entity.ID,
                            Order     = GetMaxOrder_InfoMagic(),
                            Published = date,
                            Activity  = true
                        };
                        entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                        if (tmp[0] == "1")
                        {
                            int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                            if (modelInfo.txtCachThuc != null && modelInfo.txtCachThuc.Length >= idx)
                            {
                                entityTmp.Name = modelInfo.txtCachThuc[idx];
                                entityTmp.Code = Data.GetCode(modelInfo.txtCachThuc[idx]);
                            }
                        }
                        ModInfoMagicService.Instance.Save(entityTmp);
                    }
                }

                //Da gui thong bao su co
                num = modelInfo.chkThongBao != null ? modelInfo.chkThongBao.Length : 0;
                for (int i = 0; i < num; i++)
                {
                    string[] tmp = modelInfo.chkThongBao[i].Split('_');
                    if (tmp.Length == 3)
                    {
                        ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                        {
                            BaoCaoBanDauSuCoID = entity.ID,
                            Order     = GetMaxOrder_InfoMagic(),
                            Published = date,
                            Activity  = true
                        };
                        entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                        if (tmp[0] == "1")
                        {
                            int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                            if (modelInfo.txtThongBao != null && modelInfo.txtThongBao.Length >= idx)
                            {
                                entityTmp.Name = modelInfo.txtThongBao[idx];
                                entityTmp.Code = Data.GetCode(modelInfo.txtThongBao[idx]);
                            }
                        }
                        ModInfoMagicService.Instance.Save(entityTmp);
                    }
                }

                //Dich vu
                num = modelInfo.chkDichVu != null ? modelInfo.chkDichVu.Length : 0;
                for (int i = 0; i < num; i++)
                {
                    string[] tmp = modelInfo.chkDichVu[i].Split('_');
                    if (tmp.Length == 3)
                    {
                        ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                        {
                            BaoCaoBanDauSuCoID = entity.ID,
                            Order     = GetMaxOrder_InfoMagic(),
                            Published = date,
                            Activity  = true
                        };
                        entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                        if (tmp[0] == "1")
                        {
                            int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                            if (modelInfo.txtDichVu != null && modelInfo.txtDichVu.Length >= idx)
                            {
                                entityTmp.Name = modelInfo.txtDichVu[idx];
                                entityTmp.Code = Data.GetCode(modelInfo.txtDichVu[idx]);
                            }
                        }
                        ModInfoMagicService.Instance.Save(entityTmp);
                    }
                }

                //Bien phap
                num = modelInfo.chkBienPhap != null ? modelInfo.chkBienPhap.Length : 0;
                for (int i = 0; i < num; i++)
                {
                    string[] tmp = modelInfo.chkBienPhap[i].Split('_');
                    if (tmp.Length == 3)
                    {
                        ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                        {
                            BaoCaoBanDauSuCoID = entity.ID,
                            Order     = GetMaxOrder_InfoMagic(),
                            Published = date,
                            Activity  = true
                        };
                        entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                        if (tmp[0] == "1")
                        {
                            int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                            if (modelInfo.txtBienPhap != null && modelInfo.txtBienPhap.Length >= idx)
                            {
                                entityTmp.Name = modelInfo.txtBienPhap[idx];
                                entityTmp.Code = Data.GetCode(modelInfo.txtBienPhap[idx]);
                            }
                        }
                        ModInfoMagicService.Instance.Save(entityTmp);
                    }
                }

                //Thong tin gui kem
                num = modelInfo.chkThongTinGuiKem != null ? modelInfo.chkThongTinGuiKem.Length : 0;
                for (int i = 0; i < num; i++)
                {
                    string[] tmp = modelInfo.chkThongTinGuiKem[i].Split('_');
                    if (tmp.Length == 3)
                    {
                        ModInfoMagicEntity entityTmp = new ModInfoMagicEntity()
                        {
                            BaoCaoBanDauSuCoID = entity.ID,
                            Order     = GetMaxOrder_InfoMagic(),
                            Published = date,
                            Activity  = true
                        };
                        entityTmp.MenuID = HL.Core.Global.Convert.ToInt(tmp[2]);
                        if (tmp[0] == "1")
                        {
                            int idx = HL.Core.Global.Convert.ToInt(tmp[1]);
                            if (modelInfo.txtThongTinGuiKem != null && modelInfo.txtThongTinGuiKem.Length >= idx)
                            {
                                entityTmp.Name = modelInfo.txtThongTinGuiKem[idx];
                                entityTmp.Code = Data.GetCode(modelInfo.txtThongTinGuiKem[idx]);
                            }
                        }
                        ModInfoMagicService.Instance.Save(entityTmp);
                    }
                }

                ViewBag.BaoCao = entityBc;
            }
        }
Пример #21
0
 public void ActionSave(ModHSThanhVienUCSCModel model, ModDauMoiUCSCEntity entityDm, MAppend append)
 {
     if (ValidSave(model, entityDm, append))
     {
         SaveRedirect();
     }
 }