// GET: Login public ActionResult Index(AccountLogin account) { if (!string.IsNullOrEmpty(account.PassWord) && !string.IsNullOrEmpty(account.UserName)) { tongcuclamnghiepEntities dataBase = new tongcuclamnghiepEntities(); var acc = dataBase.m_account.Where(a => a.password == account.PassWord && (a.username == account.UserName || a.email == account.UserName) && a.status == true).FirstOrDefault(); if (acc != null) { Session["AccountCookie"] = new AccountCookie() { Id = acc.id, UserName = acc.username != null ? acc.username : acc.email, Role_Id = acc.role_id, FullName = acc.fullname }; return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "This account does not exist"); return(View("~/Views/Login/Index.cshtml")); } } else { return(View()); } }
public JsonResult GetThongTinUnit() { AccountCookie accountCookie = (AccountCookie)Session["AccountCookie"]; tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id).FirstOrDefault(); if (_Unit != null) { var Vesion = tongcuclamnghiep.m_unitversion.Where(a => a.status == true && a.unit_id == _Unit.id).FirstOrDefault(); if (Vesion != null) { return(Json(new { _Unit.address, _Unit.dientich1, _Unit.dientich2, _Unit.ngansachnhannuoc1, _Unit.ngansachnhanuoc2, _Unit.ngaythanhlap, _Unit.tongcanbo1, _Unit.tongcanbo2, _Unit.unitname, Vesion = new { Vesion.datatext } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { _Unit.address, _Unit.dientich1, _Unit.dientich2, _Unit.ngansachnhannuoc1, _Unit.ngansachnhanuoc2, _Unit.ngaythanhlap, _Unit.tongcanbo1, _Unit.tongcanbo2, _Unit.unitname }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { _Unit.address, _Unit.dientich1, _Unit.dientich2, _Unit.ngansachnhannuoc1, _Unit.ngansachnhanuoc2, _Unit.ngaythanhlap, _Unit.tongcanbo1, _Unit.tongcanbo2, _Unit.unitname }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetPreciousTable(int start, int length, int draw) { string search = Request["search[value]"]; AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new baocaovuonquocgia.Models.Report.MReportlistunit().GetPreciousTable(start, length, draw, search, accountCookie), JsonRequestBehavior.AllowGet)); }
public JsonResult GetAccountTable(int start, int length, int draw) { string search = Request["search[value]"]; AccountCookie accountCookie = (AccountCookie)Session["AccountCookie"]; return(Json(new baocaovuonquocgia.Models.Manager.MAccount().GetAccountTable(start, length, draw, search, accountCookie), JsonRequestBehavior.AllowGet)); }
public ActionResult ThongTinCaNhan(ResetPass resetPass) { if (resetPass != null && resetPass.MatKhauCu != null && resetPass.MatKhauCu.Length > 0 && resetPass.MatKhauMoi.Length > 0 && resetPass.ReMatKhauMoi.Length > 0) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); AccountCookie accountCookie = (AccountCookie)Session["AccountCookie"]; ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Account = tongcuclamnghiep.m_account.Where(a => a.id == accountCookie.Id && a.password == resetPass.MatKhauCu).FirstOrDefault(); if (_Account == null) { resSubmit = new ResSubmit(false, "Không có tài khoản này"); } if (resSubmit.success && !(resetPass.MatKhauMoi == resetPass.ReMatKhauMoi && (resetPass.MatKhauMoi.Length >= 12 && resetPass.MatKhauMoi.Length <= 50))) { resSubmit = new ResSubmit(false, "Mật khẩu mới không hợp lệ"); } if (resSubmit.success) { _Account.password = resetPass.MatKhauMoi; if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { string body = string.Format(@"<table width='100%' cellspacing='0' cellpadding='0' border='0' style='width:100%;min-width:100%'> <tbody> <tr> <td align='left' style='padding:0;font-size:20px;line-height:26px;letter-spacing:-0.32px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#0078d6'> Tóm tắt tài khoản </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Tên Tài khoản:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{0}</a> </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Mật khẩu:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{1}</a> </td> </tr> <tr> <td align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#6e6e6e'> <a href='http://baocaolamnghiep.quantriwebhanoi.com' style='color:#6e6e6e;text-decoration:underline' target='_blank' ><strong style='font-weight:normal'>Tài khoản của Tôi</strong></a> </td> </tr> </tbody></table>" , _Account.username, _Account.password); FuncExtend.SendMail(_Account.email, body, "Thông tin tài khoản"); } } ModelState.AddModelError("", resSubmit.message); return(View()); } else { return(View()); } }
public List <TableComponent> GetTableReportAutoRow(int IdBaoCao, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); List <TableComponent> tableComponents = new List <TableComponent>(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id && a.status == true).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); var _ReportTable = tongcuclamnghiep.m_reporttable.Where(a => a.status == true && a.autorow == true && a.id == IdBaoCao).FirstOrDefault(); if (!(_Unit == null || _Precious == null || _ReportTable == null)) { var _UnitReport = tongcuclamnghiep.m_unit_precious.Where(a => a.precious_id == _Precious.id && a.unit_id == _Unit.id).FirstOrDefault(); bool CheckView = true; if (_UnitReport == null) { CheckView = false; } else { if (_UnitReport.completedate != null) { CheckView = false; } } if (CheckView == true) { tongcuclamnghiep.m_unit_datereport_autorows.Where(a => a.reporttable_id == IdBaoCao && a.unit_precious_id == _UnitReport.id).GroupBy(a => a.orderrow).ToList().ForEach(a => { TableComponent tableComponent = new TableComponent(); tableComponent.RowId = a.Key.Value; List <HeaderComponent> headerComponents = new List <HeaderComponent>(); _ReportTable.m_header.OrderBy(b => b.level).OrderBy(b => b.order).ToList().ForEach(b => { var datahead = a.Where(c => c.header_id == b.id).FirstOrDefault(); if (datahead != null) { HeaderComponent headerComponent = new HeaderComponent(); headerComponent.Id = datahead.id; headerComponent.OrderHeader = b.order.Value; headerComponent.TextAlign = b.valuetextalign; headerComponent.TextBold = b.is_valuebold.Value; headerComponent.TextUpper = b.is_valueupper.Value; headerComponent.TextValue = datahead.datatext; headerComponent.HeaderId = b.id; headerComponents.Add(headerComponent); } }); tableComponent.headers = headerComponents; tableComponents.Add(tableComponent); }); } } return(tableComponents); }
public ResSubmit ThemMoiTaiKhoan(AccountAdd accountNew, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit respons = new ResSubmit(true, "Thêm mới thành công"); var regex = new Regex(@"^[a-zA-Z0-9]+$"); if (!regex.IsMatch(accountNew.UserName)) { respons = new ResSubmit(false, "Username không đúng định dạng"); } regex = new Regex(@"^((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$"); if (respons.success == true && !regex.IsMatch(accountNew.Email)) { respons = new ResSubmit(false, "Email không đúng định dạng"); } if (respons.success == true) { string password = Membership.GeneratePassword(12, 1); if (tongcuclamnghiep.m_account.Any(a => a.email == accountNew.Email)) { respons = new ResSubmit(false, "Email đã tồn tại trong hệ thống"); } if (tongcuclamnghiep.m_account.Any(a => a.username == accountNew.UserName)) { respons = new ResSubmit(false, "Username đã tồn tại trong hệ thống"); } if (!tongcuclamnghiep.m_role.Any(a => a.id == accountNew.Role && a.status == true)) { respons = new ResSubmit(false, "Quyền không tồn tại trong hệ thống"); } if (respons.success == true) { m_account _Account = new m_account(); _Account.createdate = DateTime.Now; _Account.email = accountNew.Email; _Account.fullname = accountNew.FullName; _Account.gender = accountNew.Gender == 1; _Account.role_id = accountNew.Role; _Account.password = password; _Account.status = true; _Account.username = accountNew.UserName; tongcuclamnghiep.m_account.Add(_Account); if (tongcuclamnghiep.SaveChanges() != 1) { respons = new ResSubmit(false, "Thêm mới thất bại"); } } } return(respons); }
public ResSubmit ThemMoiQuy(PreciousAdd preciousAdd, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Thêm mới thành công"); if (tongcuclamnghiep.m_precious.Any(a => a.precious_name == preciousAdd.precious_name)) { resSubmit = new ResSubmit(false, "Tên đã tồn tại"); } //if(resSubmit.success && tongcuclamnghiep.m_precious.Any(a => a.status == false)) //{ // resSubmit = new ResSubmit(false, "Chưa kết thúc kỳ báo cáo trước"); //} if (resSubmit.success && !((preciousAdd.startdate < preciousAdd.enddate) && preciousAdd.completedate > preciousAdd.enddate)) { resSubmit = new ResSubmit(false, "Ngày bắt đầu, kết thúc, hoàn thành nhập không hợp lệ"); } if (resSubmit.success && !(preciousAdd.completedate > DateTime.Now)) { resSubmit = new ResSubmit(false, "Ngày hoàn thành không phù hợp"); } if (resSubmit.success && !(preciousAdd.slowday < preciousAdd.completedate && preciousAdd.slowday > preciousAdd.enddate)) { resSubmit = new ResSubmit(false, "Ngày báo chậm không phù hợp"); } if (resSubmit.success) { m_precious _Precious = new m_precious(); _Precious.account_id = accountCookie.Id; _Precious.completedate = preciousAdd.completedate; _Precious.enddate = preciousAdd.enddate; _Precious.startdate = preciousAdd.startdate; _Precious.precious_name = preciousAdd.precious_name; _Precious.slowday = preciousAdd.slowday; _Precious.status = false; tongcuclamnghiep.m_precious.Add(_Precious); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Thêm mới thất bại"); } else { tongcuclamnghiep.m_precious.Where(a => a.id != _Precious.id && a.status == false).ToList().All(a => { a.status = true; return(true); }); tongcuclamnghiep.SaveChanges(); } } return(resSubmit); }
public ResSubmit GuiMatKhau(int IdAccount, AccountCookie accountCookie) { ResSubmit resSubmit = new ResSubmit(true, "Gửi email thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Account = tongcuclamnghiep.m_account.Where(a => a.id == IdAccount).FirstOrDefault(); if (accountCookie.Role_Id != 1) { resSubmit = new ResSubmit(false, "Bạn không có quyền này"); } if (resSubmit.success && _Account == null) { resSubmit = new ResSubmit(false, "Không có tài khoản này"); } if (resSubmit.success) { string body = string.Format(@"<table width='100%' cellspacing='0' cellpadding='0' border='0' style='width:100%;min-width:100%'> <tbody> <tr> <td align='left' style='padding:0;font-size:20px;line-height:26px;letter-spacing:-0.32px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#0078d6'> Tóm tắt tài khoản </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Tên Tài khoản:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{0}</a> </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Mật khẩu:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{1}</a> </td> </tr> <tr> <td align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#6e6e6e'> <a href='http://baocaolamnghiep.quantriwebhanoi.com' style='color:#6e6e6e;text-decoration:underline' target='_blank' ><strong style='font-weight:normal'>Tài khoản của Tôi</strong></a> </td> </tr> </tbody></table>" , _Account.username, _Account.password); if (!FuncExtend.SendMail(_Account.email, body, "Thông tin tài khoản")) { resSubmit = new ResSubmit(false, "Gửi email thất bại"); } } return(resSubmit); }
public AccountCookie getAccount() { AccountCookie sc = new AccountCookie(); if (User.Identity.IsAuthenticated) { if (Request.Cookies["accCookie"] != null) { sc.AccountID = Convert.ToInt32(Request.Cookies["accCookie"]["AccountID"]); sc.Role = Request.Cookies["accCookie"]["Role"]; } else { fillcookie(); sc.AccountID = Convert.ToInt32(Request.Cookies["accCookie"]["AccountID"]); sc.Role = Request.Cookies["accCookie"]["Role"]; } } return(sc); }
public ResSubmit XoaDuLieuBaoCaoUnitAuto(int RowId, int IdBaoCao, AccountCookie accountCookie) { ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id && a.status == true).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); var _BaoCao = tongcuclamnghiep.m_reporttable.Where(a => a.id == IdBaoCao && a.status == true).FirstOrDefault(); if (_Unit == null || _Precious == null || _BaoCao == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } if (resSubmit.success) { var _UnitPrecious = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == _Precious.id && a.completedate == null).FirstOrDefault(); if (_UnitPrecious == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } if (resSubmit.success) { var _RowData = tongcuclamnghiep.m_unit_datereport_autorows.Where(a => a.orderrow == RowId && a.unit_precious_id == _UnitPrecious.id && a.reporttable_id == _BaoCao.id).ToList(); if (_RowData.Count() > 0) { _RowData.All(a => { tongcuclamnghiep.m_unit_datereport_autorows.Remove(a); return(true); }); if (tongcuclamnghiep.SaveChanges() <= 0) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } } return(resSubmit); }
public ResSubmit HoanThanhBaoCaoUnit(AccountCookie accountCookie) { ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id && a.status == true).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); if (_Unit == null || _Precious == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } if (resSubmit.success) { var _UnitPrecious = tongcuclamnghiep.m_unit_precious.Where(a => a.precious_id == _Precious.id && a.unit_id == _Unit.id).FirstOrDefault(); if (_UnitPrecious == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { if (_UnitPrecious.completedate != null) { resSubmit = new ResSubmit(false, "Bạn đã hoàn thành rồi"); } else { _UnitPrecious.completedate = DateTime.Now; if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } } } return(resSubmit); }
public ResSubmit CapNhatNguoiQuanLy(int UnitId, int AccountId, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Account = tongcuclamnghiep.m_account.Where(a => a.id == AccountId && a.status == true && !tongcuclamnghiep.m_unit.Any(b => b.account_id == a.id) && a.role_id == 2).FirstOrDefault(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.id == UnitId).FirstOrDefault(); if (accountCookie.Role_Id != 1) { resSubmit = new ResSubmit(false, "Bạn không có quyền"); } if (resSubmit.success && _Account == null && (AccountId != 0)) { resSubmit = new ResSubmit(false, "Tài khoản không hợp lệ"); } if (resSubmit.success && _Unit == null) { resSubmit = new ResSubmit(false, "Không tồn tại đơn vị này"); } if (resSubmit.success) { if (AccountId == 0) { _Unit.account_id = null; } else { _Unit.account_id = AccountId; } if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } return(resSubmit); }
public JsonResult XoaDuLieuBaoCaoUnitAuto(int RowId, int IdBaoCao) { AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new Models.Report.MReportnew().XoaDuLieuBaoCaoUnitAuto(RowId, IdBaoCao, accountCookie), JsonRequestBehavior.AllowGet)); }
public string getAccountRole() { AccountCookie mc = getAccount(); return(mc.Role); }
public int getAccountId() { AccountCookie sc = getAccount(); return(sc.AccountID); }
public JsonResult GetDanhSachBaoCaoUnit(int IdPrecious) { AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new baocaovuonquocgia.Models.Report.MReportlistunit().GetDanhSachBaoCao(IdPrecious, accountCookie), JsonRequestBehavior.AllowGet)); }
public List <BangBaoCao> GetDanhSachBaoCaoUnitNew(AccountCookie accountCookie) { List <BangBaoCao> bangBaoCaos = new List <BangBaoCao>(); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id).FirstOrDefault(); if (_Precious != null && _Unit != null) { bool CheckView = true; var _UnitPrecious = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == _Precious.id).FirstOrDefault(); if (_UnitPrecious != null) { if (_UnitPrecious.completedate != null) { CheckView = false; } } if (CheckView) { int Precious_Id_Before = 0; int UnitPrecious_Id = 0; if (tongcuclamnghiep.m_precious.Any(a => a.status == false && a.id != _Precious.id)) { Precious_Id_Before = tongcuclamnghiep.m_precious.Where(a => a.status == true && a.id != _Precious.id).OrderByDescending(a => a.completedate).Select(a => a.id).FirstOrDefault(); } if (_UnitPrecious != null) { UnitPrecious_Id = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == Precious_Id_Before).Select(a => a.id).FirstOrDefault(); } tongcuclamnghiep.m_reporttable.Where(a => a.status == true).OrderBy(a => a.order).ToList().ForEach(a => { BangBaoCao bangBaoCao = new BangBaoCao(); bangBaoCao.Loai = a.autorow == true ? 1 : 0; bangBaoCao.SapXep = a.order.Value; bangBaoCao.Id = a.id; bangBaoCao.TieuDe = a.title; bangBaoCao.DanhSachTieuDeCol = GetDanhSachTieuDeHienThi(1, 0, a.id); List <TieuDeBaoCao> tieuDeBaoCaos = new List <TieuDeBaoCao>(); a.m_header.OrderBy(b => b.level).ThenBy(b => b.order).ToList().ForEach(b => { TieuDeBaoCao tieuDeBaoCao = new TieuDeBaoCao(); tieuDeBaoCao.Bold = b.is_bold.Value; tieuDeBaoCao.ColSpan = b.colspan.Value; tieuDeBaoCao.HeaderId = b.header_id; tieuDeBaoCao.Id = b.id; tieuDeBaoCao.IsComponent = b.is_component.Value; tieuDeBaoCao.IsNo = b.is_no.Value; tieuDeBaoCao.Level = b.level.Value; tieuDeBaoCao.Order = b.order.Value; tieuDeBaoCao.RowSpan = b.rowspan.Value; tieuDeBaoCao.TextAlignValue = b.valuetextalign; tieuDeBaoCao.TextBoldValue = b.is_valuebold.Value; tieuDeBaoCao.TextUpperValue = b.is_valueupper.Value; tieuDeBaoCao.TieuDe = b.headername; tieuDeBaoCao.Upper = b.is_upper.Value; tieuDeBaoCaos.Add(tieuDeBaoCao); }); bangBaoCao.DanhSachTieuDe = tieuDeBaoCaos; List <DongBaoCao> dongBaoCaos = new List <DongBaoCao>(); if (a.autorow == false) { a.m_component.OrderBy(b => b.orderrow).GroupBy(b => b.orderrow).ToList().ForEach(b => { DongBaoCao dongBaoCao = new DongBaoCao(); dongBaoCao.RowId = b.Key.Value; List <DuLieuCot> duLieuCots = new List <DuLieuCot>(); bangBaoCao.DanhSachTieuDeCol.ToList().ForEach(c => { DuLieuCot duLieuCot = new DuLieuCot(); var TieuDeCot = tieuDeBaoCaos.Where(d => d.Id == c.Id).FirstOrDefault(); duLieuCot.TieuDeCot = TieuDeCot; var DataCell = b.Where(d => d.header_id == TieuDeCot.Id).FirstOrDefault(); if (DataCell != null) { duLieuCot.Id = DataCell.id; duLieuCot.DuLieuText = DataCell.componentname; duLieuCot.TypeValue = DataCell.typevalue.Value; if (!(TieuDeCot.IsComponent == true || TieuDeCot.IsNo == true) && _UnitPrecious != null) { var DataCellUnit = DataCell.m_unit_datareport.Where(d => d.unit_precious_id == _UnitPrecious.id).FirstOrDefault(); if (DataCellUnit != null) { duLieuCot.DuLieuText = DataCellUnit.data_text; duLieuCot.Save = true; } } if (!(TieuDeCot.IsComponent == true || TieuDeCot.IsNo == true) && _UnitPrecious == null) { if (Precious_Id_Before > 0 && tongcuclamnghiep.m_unit_precious.Any(d => d.precious_id == Precious_Id_Before && d.unit_id == _Unit.id)) { int IdUnitPreciousBF = tongcuclamnghiep.m_unit_precious.Where(d => d.precious_id == Precious_Id_Before && d.unit_id == _Unit.id).Select(d => d.id).FirstOrDefault(); var DataCellUnit = tongcuclamnghiep.m_unit_datareport.Where(d => d.unit_precious_id == IdUnitPreciousBF && d.component_id == DataCell.id).FirstOrDefault(); if (DataCellUnit != null) { duLieuCot.DuLieuText = DataCellUnit.data_text; } } } } duLieuCots.Add(duLieuCot); }); dongBaoCao.DanhSachCot = duLieuCots; dongBaoCaos.Add(dongBaoCao); }); } else { if (_UnitPrecious != null) { tongcuclamnghiep.m_unit_datereport_autorows.Where(b => b.reporttable_id == a.id && b.unit_precious_id == _UnitPrecious.id).GroupBy(b => b.orderrow).ToList().ForEach(b => { DongBaoCao dongBaoCao = new DongBaoCao(); dongBaoCao.RowId = b.Key.Value; List <DuLieuCot> duLieuCots = new List <DuLieuCot>(); bangBaoCao.DanhSachTieuDeCol.ToList().ForEach(c => { DuLieuCot duLieuCot = new DuLieuCot(); duLieuCot.TieuDeCot = c; var DataCell = b.Where(d => d.header_id == c.Id).FirstOrDefault(); if (DataCell != null) { duLieuCot.Id = DataCell.id; duLieuCot.DuLieuText = DataCell.datatext; } duLieuCots.Add(duLieuCot); }); dongBaoCao.DanhSachCot = duLieuCots; dongBaoCaos.Add(dongBaoCao); }); } } bangBaoCao.DanhSachDong = dongBaoCaos; bangBaoCaos.Add(bangBaoCao); }); } } return(bangBaoCaos); }
public JsonResult ThemMoiQuy(Models.Manager.MPrecious.PreciousAdd preciousAdd) { AccountCookie accountCookie = (AccountCookie)Session["AccountCookie"]; return(Json(new Models.Manager.MPrecious().ThemMoiQuy(preciousAdd, accountCookie), JsonRequestBehavior.AllowGet)); }
public ResSubmit CapNhatDataComponentReportUnit(int IdComponent, string TextValue, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id && a.status == true).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); var _Component = tongcuclamnghiep.m_component.Where(a => a.id == IdComponent && a.status == true).FirstOrDefault(); if (_Unit == null || _Precious == null || _Component == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } if (resSubmit.success) { if (_Component.typevalue == 2 || _Component.typevalue == 3) { double Numb = 0; if (!double.TryParse(TextValue, out Numb)) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } if (resSubmit.success) { int IdUnitPrecious = 0; var _UnitReport = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == _Precious.id).FirstOrDefault(); if (_UnitReport != null) { if (_UnitReport.completedate == null) { IdUnitPrecious = _UnitReport.id; } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } else { m_unit_precious _Unit_Precious = new m_unit_precious(); _Unit_Precious.precious_id = _Precious.id; _Unit_Precious.unit_id = _Unit.id; _Unit_Precious.createdate = DateTime.Now; tongcuclamnghiep.m_unit_precious.Add(_Unit_Precious); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { IdUnitPrecious = _Unit_Precious.id; } } if (resSubmit.success) { int IdData = 0; var _UnitDataReport = tongcuclamnghiep.m_unit_datareport.Where(a => a.component_id == IdComponent && a.unit_precious_id == IdUnitPrecious).FirstOrDefault(); if (_UnitDataReport == null) { m_unit_datareport _Unit_DatareportNew = new m_unit_datareport(); _Unit_DatareportNew.component_id = IdComponent; _Unit_DatareportNew.editlasttime = DateTime.Now; _Unit_DatareportNew.createdate = DateTime.Now; _Unit_DatareportNew.data_text = TextValue; _Unit_DatareportNew.unit_precious_id = IdUnitPrecious; tongcuclamnghiep.m_unit_datareport.Add(_Unit_DatareportNew); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { IdData = _Unit_DatareportNew.id; } } else { IdData = _UnitDataReport.id; _UnitDataReport.data_text = TextValue; _UnitDataReport.editlasttime = DateTime.Now; if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } } } } return(resSubmit); }
public JsonResult ThemMoiThanhPhanAuto(int IdBaoCao, int RowId) { AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new Models.Report.MReportnew().ThemMoiThanhPhanAuto(IdBaoCao, RowId, accountCookie), JsonRequestBehavior.AllowGet)); }
public JsonResult GetTableReportAutoRow(int IdBaoCao) { AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new Models.Report.MReportnew().GetTableReportAutoRow(IdBaoCao, accountCookie), JsonRequestBehavior.AllowGet)); }
public JsonResult GetDanhSachBaoCaoUnitNew() { AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new Models.Report.MReportnew().GetDanhSachBaoCaoUnitNew(accountCookie), JsonRequestBehavior.AllowGet)); }
public ResSubmit CapNhatDataComponentAutoReportUnit(int RowHeaderId, string TextValue, AccountCookie accountCookie) { ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id && a.status == true).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); if (_Unit == null || _Precious == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } if (resSubmit.success) { var _UnitPrecious = tongcuclamnghiep.m_unit_precious.Where(a => a.precious_id == _Precious.id && a.unit_id == _Unit.id && a.completedate == null).FirstOrDefault(); if (_UnitPrecious != null) { var _UnitReportDataAuto = tongcuclamnghiep.m_unit_datereport_autorows.Where(a => a.id == RowHeaderId && a.unit_precious_id == _UnitPrecious.id).FirstOrDefault(); if (_UnitReportDataAuto != null) { _UnitReportDataAuto.datatext = TextValue; _UnitReportDataAuto.editdate = DateTime.Now; if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } return(resSubmit); }
public ResSubmit ThemMoiThanhPhanAuto(int IdBaoCao, int RowId, AccountCookie accountCookie) { ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id && a.status == true).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); var _TableReport = tongcuclamnghiep.m_reporttable.Where(a => a.id == IdBaoCao && a.status == true && a.autorow == true).FirstOrDefault(); if (_Unit == null || _Precious == null || _TableReport == null) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } if (resSubmit.success) { int IdUnitBaoCao = 0; var _UnitBaoCao = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == _Precious.id).FirstOrDefault(); if (_UnitBaoCao != null) { if (_UnitBaoCao.completedate == null) { IdUnitBaoCao = _UnitBaoCao.id; } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } else { m_unit_precious _Unit_Precious = new m_unit_precious(); _Unit_Precious.createdate = DateTime.Now; _Unit_Precious.precious_id = _Precious.id; _Unit_Precious.unit_id = _Unit.id; tongcuclamnghiep.m_unit_precious.Add(_Unit_Precious); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { IdUnitBaoCao = _Unit_Precious.id; } } if (resSubmit.success) { if (!tongcuclamnghiep.m_unit_datereport_autorows.Any(a => a.orderrow == RowId && a.reporttable_id == IdBaoCao && a.unit_precious_id == IdUnitBaoCao)) { _TableReport.m_header.Where(a => a.status == true && a.colspan <= 1).ToList().ForEach(a => { m_unit_datereport_autorows _Unit_Datereport_Autorows = new m_unit_datereport_autorows(); _Unit_Datereport_Autorows.createdate = DateTime.Now; _Unit_Datereport_Autorows.datatext = ""; _Unit_Datereport_Autorows.editdate = DateTime.Now; _Unit_Datereport_Autorows.header_id = a.id; _Unit_Datereport_Autorows.orderrow = RowId; _Unit_Datereport_Autorows.reporttable_id = IdBaoCao; _Unit_Datereport_Autorows.unit_precious_id = IdUnitBaoCao; tongcuclamnghiep.m_unit_datereport_autorows.Add(_Unit_Datereport_Autorows); }); if (tongcuclamnghiep.SaveChanges() > 0) { List <TieuDeBaoCao> DanhSachTieuDeCol = GetDanhSachTieuDeHienThi(1, 0, IdBaoCao); DongBaoCao dongBaoCao = new DongBaoCao(); dongBaoCao.RowId = RowId; List <DuLieuCot> duLieuCots = new List <DuLieuCot>(); DanhSachTieuDeCol.ToList().ForEach(c => { DuLieuCot duLieuCot = new DuLieuCot(); duLieuCot.TieuDeCot = c; var DataCell = tongcuclamnghiep.m_unit_datereport_autorows.Where(d => d.reporttable_id == IdBaoCao && d.orderrow == RowId && d.header_id == c.Id).FirstOrDefault(); if (DataCell != null) { duLieuCot.Id = DataCell.id; duLieuCot.DuLieuText = DataCell.datatext; } duLieuCots.Add(duLieuCot); }); dongBaoCao.DanhSachCot = duLieuCots; resSubmit.extend = dongBaoCao; } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } else { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } } return(resSubmit); }
public ResTableData GetPreciousTable(int start, int length, int draw, string search, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.account_id == accountCookie.Id).FirstOrDefault(); var dataAll = tongcuclamnghiep.m_precious.Where(a => (search.Length > 0 ? (a.precious_name.Contains(search)) : true)); var data = dataAll.ToList().Skip((start)).Take(length).Select(a => new { a.id, a.precious_name, createdate = a.createdate.Value.ToString("dd/MM/yyyy"), completedate = a.completedate.Value.ToString("dd/MM/yyyy"), a.status, startend = string.Format("{0:dd/MM/yyyy} - {1:dd/MM/yyyy}", a.startdate, a.enddate), isCreate = a.m_unit_precious.Any(b => b.unit_id == _Unit.id) }); return(new ResTableData() { data = data, draw = (draw + 1), recordsFiltered = dataAll.Count(), recordsTotal = dataAll.Count() }); }
public JsonResult CapNhatDataComponentAutoReportUnit(int RowHeaderId, string TextValue) { AccountCookie accountCookie = (AccountCookie)Session["accountCookie"]; return(Json(new Models.Report.MReportnew().CapNhatDataComponentAutoReportUnit(RowHeaderId, TextValue, accountCookie), JsonRequestBehavior.AllowGet)); }
public JsonResult ChinhSuaUnit(Models.Category.MUnit.UnitAdd unitEdit) { AccountCookie accountCookie = (AccountCookie)Session["AccountCookie"]; tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.id == unitEdit.id && a.account_id == accountCookie.Id).FirstOrDefault(); if (_Unit == null) { resSubmit = new ResSubmit(false, "Không tồn tại đơn vị này"); } if (resSubmit.success && !(unitEdit.unitname.Length >= 10 && unitEdit.unitname.Length <= 4000)) { resSubmit = new ResSubmit(false, "Tên đơn vị không hợp lệ"); } if (resSubmit.success && tongcuclamnghiep.m_unit.Any(a => a.id != unitEdit.id && a.unitname == unitEdit.unitname)) { resSubmit = new ResSubmit(false, "Tên đơn vị đã tồn tại"); } if (resSubmit.success) { HttpRequestBase request = HttpContext.Request; string UnitVersionText = request.Unvalidated.Form.Get("UnitVersionTextData"); unitEdit.UnitVersionText = UnitVersionText; _Unit.address = unitEdit.address; _Unit.unitname = unitEdit.unitname; _Unit.dientich1 = unitEdit.dientich1; _Unit.dientich2 = unitEdit.dientich2; _Unit.ngansachnhannuoc1 = unitEdit.ngansachnhannuoc1; _Unit.ngansachnhanuoc2 = unitEdit.ngansachnhanuoc2; _Unit.ngaythanhlap = unitEdit.ngaythanhlap; _Unit.tongcanbo1 = unitEdit.tongcanbo1; _Unit.tongcanbo2 = unitEdit.tongcanbo2; tongcuclamnghiep.SaveChanges(); int version = 1; var _UnitVS = tongcuclamnghiep.m_unitversion.Where(a => a.unit_id == _Unit.id && a.status == true).FirstOrDefault(); if (_UnitVS != null) { version = _UnitVS.version.Value + 1; } m_unitversion _Unitversion = new m_unitversion(); _Unitversion.createdate = DateTime.Now; _Unitversion.datatext = unitEdit.UnitVersionText; _Unitversion.unit_id = _Unit.id; _Unitversion.status = true; _Unitversion.version = version; _Unitversion.dientich1 = unitEdit.dientich1; _Unitversion.dientich2 = unitEdit.dientich2; _Unitversion.ngansachnhannuoc1 = unitEdit.ngansachnhannuoc1; _Unitversion.ngansachnhanuoc2 = unitEdit.ngansachnhanuoc2; _Unitversion.ngaythanhlap = unitEdit.ngaythanhlap; _Unitversion.tongcanbo1 = unitEdit.tongcanbo1; _Unitversion.tongcanbo2 = unitEdit.tongcanbo2; tongcuclamnghiep.m_unitversion.Add(_Unitversion); if (tongcuclamnghiep.SaveChanges() == 1) { tongcuclamnghiep.m_unitversion.Where(a => a.unit_id == _Unit.id && a.status == true && a.id != _Unitversion.id).ToList().All(a => { a.status = false; return(true); }); tongcuclamnghiep.SaveChanges(); } } return(Json(resSubmit, JsonRequestBehavior.AllowGet)); }
public List <TableReport> GetDataReport(AccountCookie accountCookie) { List <TableReport> tableReports = new List <TableReport>(); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Unit = tongcuclamnghiep.m_unit.Where(a => a.status == true && a.account_id == accountCookie.Id).FirstOrDefault(); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.status == false).FirstOrDefault(); if (_Precious != null && _Unit != null) { bool CheckView = true; var _UnitPrecious = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == _Precious.id).FirstOrDefault(); if (_UnitPrecious != null) { if (_UnitPrecious.completedate != null) { CheckView = false; } } if (CheckView == true) { int Precious_Id_Before = 0; int UnitPrecious_Id = 0; if (tongcuclamnghiep.m_precious.Any(a => a.status == false && a.id != _Precious.id)) { Precious_Id_Before = tongcuclamnghiep.m_precious.Where(a => a.status == true && a.id != _Precious.id).OrderByDescending(a => a.completedate).Select(a => a.id).FirstOrDefault(); } if (_UnitPrecious != null) { UnitPrecious_Id = tongcuclamnghiep.m_unit_precious.Where(a => a.unit_id == _Unit.id && a.precious_id == Precious_Id_Before).Select(a => a.id).FirstOrDefault(); } tongcuclamnghiep.m_reporttable.Where(a => a.status == true).OrderBy(a => a.order).ToList().ForEach(a => { TableReport tableReport = new TableReport(); tableReport.IdBaoCao = a.id; tableReport.Title = a.title; tableReport.Order = a.order.Value; tableReport.AutoRow = a.autorow.Value; List <HeaderComponent> headers = new List <HeaderComponent>(); tongcuclamnghiep.m_header.Where(b => a.status == true && b.reporttable_id == a.id).OrderBy(b => b.order).ToList().ForEach(b => { HeaderComponent header = new HeaderComponent(); header.Id = b.id; header.Title = b.headername; header.RowSpan = b.rowspan.Value; header.ColSpan = b.colspan.Value; header.HeaderId = b.header_id; header.Level = b.level; header.Is_No = b.is_no; header.Is_Component = b.is_component; header.OrderHeader = b.order.Value; headers.Add(header); }); tableReport.headers = headers.OrderBy(b => b.Level).ThenBy(b => b.OrderHeader).ToList(); List <TableComponent> tableComponents = new List <TableComponent>(); a.m_component.Where(b => b.status == true).GroupBy(b => b.orderrow).ToList().ForEach(b => { TableComponent tableComponent = new TableComponent(); tableComponent.RowId = b.Key.Value; List <HeaderComponent> headerComponents = new List <HeaderComponent>(); tableReport.headers.ForEach(c => { var _CPM = tongcuclamnghiep.m_component.Where(d => d.header_id == c.Id && d.orderrow == b.Key).FirstOrDefault(); if (_CPM != null) { HeaderComponent header = new HeaderComponent(); header.Id = _CPM.id; header.OrderHeader = c.OrderHeader; header.HeaderId = _CPM.header_id; header.TextAlign = _CPM.m_header.valuetextalign; header.TextBold = _CPM.m_header.is_valuebold.Value; header.TextUpper = _CPM.m_header.is_valueupper.Value; header.TextValue = _CPM.componentname; header.Title = _CPM.m_header.headername; header.TypeValue = _CPM.typevalue.Value; header.Is_No = _CPM.m_header.is_no; if (_UnitPrecious == null) { header.Save = false; if (Precious_Id_Before > 0 && UnitPrecious_Id > 0) { var _dataUnitReportBefore = tongcuclamnghiep.m_unit_datareport.Where(d => d.component_id == _CPM.id && d.unit_precious_id == UnitPrecious_Id).FirstOrDefault(); if (_dataUnitReportBefore == null) { header.TextUnit = ""; } else { header.TextUnit = _dataUnitReportBefore.data_text; } } else { header.TextUnit = ""; } } else { var _dataUnitReport = _CPM.m_unit_datareport.Where(d => d.unit_precious_id == _UnitPrecious.id).FirstOrDefault(); if (_dataUnitReport == null) { header.Save = false; if (Precious_Id_Before > 0 && UnitPrecious_Id > 0) { var _dataUnitReportBefore = tongcuclamnghiep.m_unit_datareport.Where(d => d.component_id == _CPM.id && d.unit_precious_id == UnitPrecious_Id).FirstOrDefault(); if (_dataUnitReportBefore == null) { header.TextUnit = ""; } else { header.TextUnit = _dataUnitReportBefore.data_text; } } else { header.TextUnit = ""; } } else { header.Save = true; header.TextUnit = _dataUnitReport.data_text; } } header.Is_Component = _CPM.m_header.is_component; headerComponents.Add(header); } }); tableComponent.headers = headerComponents; tableComponents.Add(tableComponent); }); tableReport.tableComponents = tableComponents; tableReports.Add(tableReport); }); } } return(tableReports); }
public ResTableData GetAccountTable(int start, int length, int draw, string search, AccountCookie accountCookie) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var dataAll = tongcuclamnghiep.m_account.Where(a => a.id != accountCookie.Id && (search.Length > 0 ? (a.username.Contains(search) || a.email.Contains(search) || a.fullname.Contains(search)) : true)) .Select(a => new { a.id, a.username, a.email, a.createdate, a.gender, a.fullname, a.status, rolename = a.m_role.rolename }); var data = dataAll.ToList().Skip((start)).Take(length); return(new ResTableData() { data = data, draw = (draw + 1), recordsFiltered = dataAll.Count(), recordsTotal = dataAll.Count() }); }