public void ActionAdd(FormBaoCaoTongHopModel model) { if (model.RecordID > 0) { entity = ModBaoCaoTongHopService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update entity.UserID1 = Lib.Global.CPLogin.UserID; ViewBag.SuCo = ModSoLuongSuCoService.Instance.CreateQuery().Where(o => o.Activity == true && o.BaoCaoTongHopID == entity.ID).ToList(); } else { entity = new ModBaoCaoTongHopEntity(); // khoi tao gia tri mac dinh khi insert entity.MenuID = model.MenuID; entity.UserID = Lib.Global.CPLogin.UserID; DateTime d = DateTime.Now; entity.TuNgay = d; entity.DenNgay = d; entity.Published = d; entity.Activity = CPViewPage.UserPermissions.Approve; entity.Order = GetMaxOrder(model); } ViewBag.Data = entity; ViewBag.Model = model; }
public void ActionUpdateBaoCaoUCSC(ModBaoCaoTongHopEntity entityBc, MSoLuongSuCoModel entitySuCo, string endCode) { int userId = HL.Lib.Global.CPLogin.UserID; var entity = ModBaoCaoTongHopService.Instance.CreateQuery() .Where(userId > 0, o => o.UserID == userId) .Where(o => o.Code == endCode) .ToSingle(); if (entity != null) { DateTime date = DateTime.Now; 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; var lstSuCo = ModSoLuongSuCoService.Instance.CreateQuery().Where(o => o.BaoCaoTongHopID == entity.ID).ToList(); if (lstSuCo != null) ModSoLuongSuCoService.Instance.Delete(lstSuCo); int c = entitySuCo.MN.Length; for (int i = 0; i < c; i++) { var suCo = new ModSoLuongSuCoEntity(); bool flag = false; if (entitySuCo.SoLuong[i] > 0) { suCo.SoLuong = entitySuCo.SoLuong[i]; flag = true; } if (entitySuCo.TuXuLy[i] > 0) { suCo.TuXuLy = entitySuCo.TuXuLy[i]; flag = true; } if (entitySuCo.ToChucHoTro[i] > 0) { suCo.ToChucHoTro = entitySuCo.ToChucHoTro[i]; flag = true; } if (entitySuCo.ToChucNuocNgoaiHoTro[i] > 0) { suCo.ToChucNuocNgoaiHoTro = entitySuCo.ToChucNuocNgoaiHoTro[i]; flag = true; } if (entitySuCo.DeNghi[i] > 0) { suCo.DeNghi = entitySuCo.DeNghi[i]; flag = true; } if (entitySuCo.ThietHaiUocTinh[i] > 0) { suCo.ThietHaiUocTinh = entitySuCo.ThietHaiUocTinh[i]; flag = true; } if (flag == true) { int id = ModBaoCaoTongHopService.Instance.Save(entityBc); suCo.BaoCaoTongHopID = id; suCo.MenuID = entitySuCo.MN[i]; suCo.Published = date; suCo.Order = GetMaxOrder_SoSuCo(); suCo.Activity = true; ModSoLuongSuCoService.Instance.Save(suCo); } } ViewBag.BaoCao = entityBc; ViewPage.Alert("Cập nhật 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-tong-hop-su-co.aspx"); } }
public void UpdateOther(ModBaoCaoTongHopEntity entityBc, MSoLuongSuCoModelForm entitySuCo) { int userId = HL.Lib.Global.CPLogin.UserID; var entity = ModBaoCaoTongHopService.Instance.CreateQuery() //.Where(userId > 0, o => o.UserID == userId) .Where(o => o.Code == entityBc.Code) .ToSingle(); if (entity != null) { DateTime date = DateTime.Now; 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; var lstSuCo = ModSoLuongSuCoService.Instance.CreateQuery().Where(o => o.BaoCaoTongHopID == entity.ID).ToList(); if (lstSuCo != null) { ModSoLuongSuCoService.Instance.Delete(lstSuCo); } int c = entitySuCo.MN.Length; for (int i = 0; i < c; i++) { var suCo = new ModSoLuongSuCoEntity(); bool flag = false; if (entitySuCo.SoLuong[i] > 0) { suCo.SoLuong = entitySuCo.SoLuong[i]; flag = true; } if (entitySuCo.TuXuLy[i] > 0) { suCo.TuXuLy = entitySuCo.TuXuLy[i]; flag = true; } if (entitySuCo.ToChucHoTro[i] > 0) { suCo.ToChucHoTro = entitySuCo.ToChucHoTro[i]; flag = true; } if (entitySuCo.ToChucNuocNgoaiHoTro[i] > 0) { suCo.ToChucNuocNgoaiHoTro = entitySuCo.ToChucNuocNgoaiHoTro[i]; flag = true; } if (entitySuCo.DeNghi[i] > 0) { suCo.DeNghi = entitySuCo.DeNghi[i]; flag = true; } if (entitySuCo.ThietHaiUocTinh[i] > 0) { suCo.ThietHaiUocTinh = entitySuCo.ThietHaiUocTinh[i]; flag = true; } if (flag == true) { int id = ModBaoCaoTongHopService.Instance.Save(entityBc); suCo.BaoCaoTongHopID = id; suCo.MenuID = entitySuCo.MN[i]; suCo.Published = date; suCo.Order = GetMaxOrder_SoSuCo(); suCo.Activity = true; ModSoLuongSuCoService.Instance.Save(suCo); } } ViewBag.BaoCao = entityBc; } }
public void ActionAddBCTongHopUCSC(ModBaoCaoTongHopEntity entity, MSoLuongSuCoModel entitySuCo) { ViewBag.BaoCao = entity; DateTime date = DateTime.Now; string code = "BCTHSC" + ModBaoCaoTongHopService.Instance.GetMaxID(); entity.Name = code; entity.Code = Data.GetCode(code); entity.UserID = Lib.Global.CPLogin.UserID; entity.Order = GetMaxOrder_BCTongHop(); entity.Published = date; entity.Activity = false; int c = entitySuCo.MN.Length; for (int i = 0; i < c; i++) { var suCo = new ModSoLuongSuCoEntity(); bool flag = false; if (entitySuCo.SoLuong[i] > 0) { suCo.SoLuong = entitySuCo.SoLuong[i]; flag = true; } if (entitySuCo.TuXuLy[i] > 0) { suCo.TuXuLy = entitySuCo.TuXuLy[i]; flag = true; } if (entitySuCo.ToChucHoTro[i] > 0) { suCo.ToChucHoTro = entitySuCo.ToChucHoTro[i]; flag = true; } if (entitySuCo.ToChucNuocNgoaiHoTro[i] > 0) { suCo.ToChucNuocNgoaiHoTro = entitySuCo.ToChucNuocNgoaiHoTro[i]; flag = true; } if (entitySuCo.DeNghi[i] > 0) { suCo.DeNghi = entitySuCo.DeNghi[i]; flag = true; } if (entitySuCo.ThietHaiUocTinh[i] > 0) { suCo.ThietHaiUocTinh = entitySuCo.ThietHaiUocTinh[i]; flag = true; } if (flag == true) { int id = ModBaoCaoTongHopService.Instance.Save(entity); suCo.BaoCaoTongHopID = id; suCo.MenuID = entitySuCo.MN[i]; suCo.Published = date; suCo.Order = GetMaxOrder_SoSuCo(); suCo.Activity = true; ModSoLuongSuCoService.Instance.Save(suCo); } } 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-tong-hop-su-co.aspx"); }