public void ActionAdd(ModInfoMagicModel model) { if (model.RecordID > 0) { entity = ModInfoMagicService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { entity = new ModInfoMagicEntity(); // khoi tao gia tri mac dinh khi insert entity.MenuID = model.MenuID; entity.Activity = CPViewPage.UserPermissions.Approve; entity.Order = GetMaxOrder(model); } ViewBag.Data = entity; ViewBag.Model = model; }
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; } }
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; }
public void ActionAddBCBanDauUCSC(ModBaoCaoBanDauSuCoEntity entity, MInfoMagicModel modelInfo, MAppend append) { DateTime date = DateTime.Now; string ngayGioPhatHien = append.Ngay + " " + append.Gio + ":" + append.Phut; 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(); entity.Name = code; entity.Code = Data.GetCode(code); entity.UserID = Lib.Global.CPLogin.UserID; if (!string.IsNullOrEmpty(ngayGioPhatHien)) { entity.ChiTiet_NgayGioPhatHien = HL.Core.Global.Convert.ToDateTime(ngayGioPhatHien); } else { entity.ChiTiet_NgayGioPhatHien = DateTime.MinValue; } if (!string.IsNullOrEmpty(thoiGianThucHien)) { entity.ThoiGianThucHien = HL.Core.Global.Convert.ToDateTime(thoiGianThucHien); } else { entity.ThoiGianThucHien = DateTime.MinValue; } entity.Order = GetMaxOrder_BCBanDau(); entity.Published = date; entity.Activity = false; int id = ModBaoCaoBanDauSuCoService.Instance.Save(entity); //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; ViewPage.Alert("Tạo mới báo cáo thành công! Chúng tôi sẽ xem xét và phê duyệt báo cáo của bạn sớm nhất có thể."); ViewPage.Navigate("/vn/Thanh-vien/DS-bc-ban-dau-su-co.aspx"); }