public ResSubmit XoaComponent(int RowId, int IdBaoCao) { ResSubmit resSubmit = new ResSubmit(true, "Xóa thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); if (tongcuclamnghiep.m_reporttable.Any(a => a.id == IdBaoCao)) { if (!tongcuclamnghiep.m_component.Any(a => a.orderrow == RowId && a.reporttable_id == IdBaoCao && a.m_unit_datareport.Any())) { resSubmit = new ResSubmit(true, "Xóa thành công"); resSubmit.extend = tongcuclamnghiep.m_component.ToList().Select(a => new { a.id, a.orderrow }); tongcuclamnghiep.m_component.Where(a => a.orderrow == RowId && a.reporttable_id == IdBaoCao).ToList().All(a => { tongcuclamnghiep.m_component.Remove(a); return(true); }); tongcuclamnghiep.SaveChanges(); } else { resSubmit = new ResSubmit(true, "Đã có dữ liệu, không được xóa!"); } } else { resSubmit = new ResSubmit(true, "Không có báo cáo này!"); } return(resSubmit); }
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 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() }); }
public ResSubmit ThemMoiHeader(HeaderAdd headerAdd) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Thêm mới thành công"); var _HeaderCha = tongcuclamnghiep.m_header.Where(a => a.id == headerAdd.HeaderId).FirstOrDefault(); var _BaoCao = tongcuclamnghiep.m_reporttable.Where(a => a.id == headerAdd.IdBaoCao).FirstOrDefault(); if (_BaoCao == null) { resSubmit = new ResSubmit(false, "Không có báo cáo này"); } if (resSubmit.success && _HeaderCha == null && headerAdd.HeaderId != 0) { resSubmit = new ResSubmit(false, "Không có tiêu đề cha này"); } if (resSubmit.success && (tongcuclamnghiep.m_header.Any(a => a.headername == headerAdd.headername && a.reporttable_id == headerAdd.IdBaoCao && (headerAdd.HeaderId == 0 ? a.level == 1 : (a.header_id == headerAdd.HeaderId))))) { resSubmit = new ResSubmit(false, "Tên cột đã tồn tại"); } if (resSubmit.success) { m_header _Header = new m_header(); _Header.colspan = ((headerAdd.colspan == 0 || headerAdd.colspan == null) ? 1 : headerAdd.colspan); _Header.headername = headerAdd.headername; _Header.header_id = (headerAdd.HeaderId == 0 ? (int?)null : headerAdd.HeaderId); _Header.is_bold = headerAdd.is_bold; if (headerAdd.is_no == true && headerAdd.is_component == true) { _Header.is_no = true; _Header.is_component = false; } else { _Header.is_no = headerAdd.is_no == true; _Header.is_component = headerAdd.is_component == true; } if (tongcuclamnghiep.m_header.Any(a => a.header_id == headerAdd.HeaderId)) { _Header.order = tongcuclamnghiep.m_header.Max(a => a.order.Value); } else { _Header.order = 1; } _Header.is_upper = headerAdd.is_upper; _Header.is_valuebold = headerAdd.is_valuebold; _Header.is_valueupper = headerAdd.is_valueupper; _Header.level = (_HeaderCha == null ? 1 : _HeaderCha.level + 1); _Header.reporttable_id = headerAdd.IdBaoCao; _Header.rowspan = ((headerAdd.rowspan == 0 || headerAdd.rowspan == null) ? 1 : headerAdd.rowspan); _Header.status = headerAdd.status; _Header.valuetextalign = (headerAdd.valuetextalign == "right" ? "right" : (headerAdd.valuetextalign == "center" ? "center" : "left")); tongcuclamnghiep.m_header.Add(_Header); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Thêm mới thất bại"); } } return(resSubmit); }
List <TableReport> getByLevel(int level, int IdBaoCao) { List <TableReport> tableReports = new List <TableReport>(); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); tongcuclamnghiep.m_header.Where(a => a.reporttable_id == IdBaoCao && a.level == level && a.status == true).OrderBy(a => a.order).ToList().ForEach(a => { tableReports.Add(new TableReport() { colspan = a.colspan.Value, level = a.level.Value, order = a.order.Value, rowspan = a.rowspan.Value, title = a.headername, extend = new { a.id, a.is_bold, a.header_id, a.is_component, a.is_no, } }); }); if (tongcuclamnghiep.m_header.Any(b => b.reporttable_id == IdBaoCao && b.status == true && b.level == level + 1)) { List <TableReport> tableReportTemp = getByLevel(level + 1, IdBaoCao); tableReportTemp.ForEach(b => { tableReports.Add(b); }); } return(tableReports); }
// 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 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 List <TableComponent> GetTableComponentReport(int IdBaoCao) { List <TableComponent> tableComponents = new List <TableComponent>(); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); tongcuclamnghiep.m_component.Where(a => a.reporttable_id == IdBaoCao).GroupBy(a => a.orderrow).ToList().ForEach(a => { TableComponent tableComponent = new TableComponent(); tableComponent.RowId = a.Key.Value; List <HeaderComponent> headers = new List <HeaderComponent>(); a.ToList().ForEach(b => { headers.Add(new HeaderComponent() { Id = b.header_id.Value, Title = b.componentname, TypeValue = b.typevalue.Value, TextAlign = b.m_header.valuetextalign, TextBold = b.m_header.is_valuebold.Value, TextUpper = b.m_header.is_valueupper.Value }); }); tableComponent.headers = headers; tableComponents.Add(tableComponent); }); return(tableComponents); }
public ResSubmit ThemMoiUnit(UnitAdd unitAdd) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Thêm mới thành công"); if (!(unitAdd.unitname.Length >= 10 && unitAdd.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.unitname == unitAdd.unitname)) { resSubmit = new ResSubmit(false, "Tên đơn vị đã tồn tại"); } if (resSubmit.success && (unitAdd.account_id != 0 && unitAdd.account_id != null) && !tongcuclamnghiep.m_account.Where(a => a.role_id == 2 && a.id == unitAdd.account_id && a.status == true).ToList().Any(a => !tongcuclamnghiep.m_unit.Any(c => c.account_id == a.id))) { resSubmit = new ResSubmit(false, "Tài khoản quản lý không hợp lệ"); } if (resSubmit.success) { m_unit _Unit = new m_unit(); _Unit.account_id = ((unitAdd.account_id != 0 && unitAdd.account_id != null) ? unitAdd.account_id : null); _Unit.address = unitAdd.address; _Unit.status = true; _Unit.unitname = unitAdd.unitname; _Unit.dientich1 = (unitAdd.dientich1 != null ? unitAdd.dientich1 : 0); _Unit.dientich2 = (unitAdd.dientich2 != null ? unitAdd.dientich2 : 0); _Unit.ngansachnhannuoc1 = (unitAdd.ngansachnhannuoc1 != null ? unitAdd.ngansachnhannuoc1 : 0); _Unit.ngansachnhanuoc2 = (unitAdd.ngansachnhanuoc2 != null ? unitAdd.ngansachnhanuoc2 : 0); _Unit.ngaythanhlap = unitAdd.ngaythanhlap; _Unit.tongcanbo1 = (unitAdd.tongcanbo1 != null ? unitAdd.tongcanbo1 : 0); _Unit.tongcanbo2 = (unitAdd.tongcanbo2 != null ? unitAdd.tongcanbo2 : 0); tongcuclamnghiep.m_unit.Add(_Unit); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Thêm mới thất bại"); } else { m_unitversion _Unitversion = new m_unitversion(); _Unitversion.createdate = DateTime.Now; _Unitversion.datatext = unitAdd.UnitVersionText; _Unitversion.unit_id = _Unit.id; _Unitversion.status = true; _Unitversion.version = 1; _Unitversion.dientich1 = _Unit.dientich1; _Unitversion.dientich2 = _Unit.dientich2; _Unitversion.ngansachnhannuoc1 = _Unit.ngansachnhannuoc1; _Unitversion.ngansachnhanuoc2 = _Unit.ngansachnhanuoc2; _Unitversion.ngaythanhlap = _Unit.ngaythanhlap; _Unitversion.tongcanbo1 = _Unit.tongcanbo1; _Unitversion.tongcanbo2 = _Unit.tongcanbo2; tongcuclamnghiep.m_unitversion.Add(_Unitversion); tongcuclamnghiep.SaveChanges(); } } return(resSubmit); }
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 ResSubmit ThemMoiThanhPhan(int IdBaoCao, int RowId) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Thêm mới thành công"); if (!tongcuclamnghiep.m_reporttable.Any(a => a.id == IdBaoCao)) { resSubmit = new ResSubmit(false, "Không có báo cáo này"); } if (resSubmit.success && tongcuclamnghiep.m_component.Any(a => a.reporttable_id == IdBaoCao && a.orderrow == RowId)) { resSubmit = new ResSubmit(false, "Dòng này đã thêm"); } if (resSubmit.success) { tongcuclamnghiep.m_header.Where(a => a.reporttable_id == IdBaoCao).ToList().ForEach(a => { if (!tongcuclamnghiep.m_header.Any(b => b.header_id == a.id)) { m_component _Component = new m_component(); if (a.is_component == true || a.is_no == true) { _Component.componentname = ""; } _Component.typevalue = 1; _Component.header_id = a.id; _Component.orderrow = RowId; _Component.reporttable_id = IdBaoCao; _Component.status = true; tongcuclamnghiep.m_component.Add(_Component); } }); if (tongcuclamnghiep.SaveChanges() < 1) { resSubmit = new ResSubmit(false, "Thêm mới thất bại"); } else { TableComponent tableComponent = new TableComponent(); tableComponent.RowId = RowId; List <HeaderComponent> headers = new List <HeaderComponent>(); tongcuclamnghiep.m_component.Where(a => a.orderrow == RowId && a.reporttable_id == IdBaoCao).ToList().ForEach(b => { headers.Add(new HeaderComponent() { Id = b.header_id.Value, Title = b.componentname, TypeValue = b.typevalue.Value, TextAlign = b.m_header.valuetextalign, TextBold = b.m_header.is_valuebold.Value, TextUpper = b.m_header.is_valueupper.Value }); }); tableComponent.headers = headers; resSubmit.extend = tableComponent; } } return(resSubmit); }
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 List <TreeBaoCao> GetTreeBaoCao(int IdBaoCao, int IdHeaderCha, bool isFirst) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); List <TreeBaoCao> treeBaoCaos = new List <TreeBaoCao>(); var _ReportTable = tongcuclamnghiep.m_reporttable.Where(a => a.id == IdBaoCao).FirstOrDefault(); if (_ReportTable != null) { if (isFirst) { treeBaoCaos.Add(new TreeBaoCao() { key = "_1", title = _ReportTable.title, lazy = tongcuclamnghiep.m_header.Any(a => a.reporttable_id == IdBaoCao), folder = tongcuclamnghiep.m_header.Any(a => a.reporttable_id == IdBaoCao) }); } else { treeBaoCaos = tongcuclamnghiep.m_header.Where(a => a.reporttable_id == IdBaoCao && (IdHeaderCha <= 0 ? (a.level == 1) : (a.header_id == IdHeaderCha))).ToList() .Select(a => new TreeBaoCao() { key = string.Format("{0}", a.id), title = a.headername, lazy = tongcuclamnghiep.m_header.Any(b => b.header_id == a.id), folder = tongcuclamnghiep.m_header.Any(b => b.header_id == a.id), dataSource = new { a.colspan, a.createdate, a.headername, a.header_id, a.id, a.is_bold, a.is_upper, a.is_valuebold, a.is_valueupper, a.level, a.order, a.reporttable_id, a.rowspan, a.status, a.valuetextalign, a.is_no, a.is_component } }).ToList(); } } return(treeBaoCaos); }
public List <TieuDeBaoCao> GetDanhSachTieuDeHienThi(int Level, int IdHeader, int IdBaoCao) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); List <TieuDeBaoCao> tieuDeBaosNew = new List <TieuDeBaoCao>(); if (IdHeader == 0) { tongcuclamnghiep.m_header.Where(a => a.reporttable_id == IdBaoCao && a.level == Level && a.header_id == null).OrderBy(a => a.order).ToList().ForEach(a => { if (a.colspan > 1) { List <TieuDeBaoCao> tieuDeBaosNewTemp = GetDanhSachTieuDeHienThi((Level + 1), a.id, IdBaoCao); foreach (var item in tieuDeBaosNewTemp) { tieuDeBaosNew.Add(item); } } else { tieuDeBaosNew.Add(new TieuDeBaoCao() { Id = a.id, TieuDe = a.headername }); } }); } else { tongcuclamnghiep.m_header.Where(a => a.reporttable_id == IdBaoCao && a.level == Level && a.header_id == IdHeader).OrderBy(a => a.order).ToList().ForEach(a => { if (a.colspan > 1) { List <TieuDeBaoCao> tieuDeBaosNewTemp = GetDanhSachTieuDeHienThi((Level + 1), a.id, IdBaoCao); foreach (var item in tieuDeBaosNewTemp) { tieuDeBaosNew.Add(item); } } else { tieuDeBaosNew.Add(new TieuDeBaoCao() { Id = a.id, TieuDe = a.headername }); } }); } return(tieuDeBaosNew); }
public ActionResult ResetMatKhau(AccountLogin account) { if (!string.IsNullOrEmpty(account.UserName)) { tongcuclamnghiepEntities dataBase = new tongcuclamnghiepEntities(); var acc = dataBase.m_account.Where(a => (a.email == account.UserName) && a.status == true).FirstOrDefault(); if (acc != null) { 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>" , acc.username, acc.password); if (FuncExtend.SendMail(acc.email, body, "Thông tin tài khoản")) { ModelState.AddModelError("", "Gửi email thành công"); } else { ModelState.AddModelError("", "Gửi email thất bại"); } return(View("~/Views/Login/ResetMatKhau.cshtml")); } else { ModelState.AddModelError("", "Email tài khoản không tồn tại"); return(View("~/Views/Login/ResetMatKhau.cshtml")); } } else { return(View()); } }
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 CapNhatThanhPhanDataType(ComponentUpdate componentUpdate) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Component = tongcuclamnghiep.m_component.Where(a => a.header_id == componentUpdate.HeaderId && a.reporttable_id == componentUpdate.IdBaoCao && a.orderrow == componentUpdate.RowId).FirstOrDefault(); if (!tongcuclamnghiep.m_reporttable.Any(a => a.id == componentUpdate.IdBaoCao)) { resSubmit = new ResSubmit(false, "Không có báo cáo này"); } if (resSubmit.success && _Component == null) { resSubmit = new ResSubmit(false, "Không có thành phần này"); } if (resSubmit.success) { if (_Component.m_header.is_no == true || _Component.m_header.is_component == true) { _Component.componentname = componentUpdate.Title; _Component.typevalue = 1; } else { _Component.typevalue = componentUpdate.TypeValue; } if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { TableComponent tableComponent = new TableComponent(); tableComponent.RowId = componentUpdate.RowId; List <HeaderComponent> headers = new List <HeaderComponent>(); tongcuclamnghiep.m_component.Where(a => a.orderrow == componentUpdate.RowId && a.reporttable_id == componentUpdate.IdBaoCao).ToList().ForEach(b => { headers.Add(new HeaderComponent() { Id = b.header_id.Value, Title = b.componentname, TypeValue = b.typevalue.Value, TextAlign = b.m_header.valuetextalign, TextBold = b.m_header.is_valuebold.Value, TextUpper = b.m_header.is_valueupper.Value }); }); tableComponent.headers = headers; resSubmit.extend = tableComponent; } } return(resSubmit); }
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 CapNhatHeader(HeaderAdd headerEdit) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Header = tongcuclamnghiep.m_header.Where(a => a.id == headerEdit.id && a.reporttable_id == headerEdit.IdBaoCao).FirstOrDefault(); var _BaoCao = tongcuclamnghiep.m_reporttable.Where(a => a.id == headerEdit.IdBaoCao).FirstOrDefault(); if (_BaoCao == null) { resSubmit = new ResSubmit(false, "Không có báo cáo này"); } if (resSubmit.success && _Header == null) { resSubmit = new ResSubmit(false, "Không có tiêu đề cột này"); } if (resSubmit.success && tongcuclamnghiep.m_header.Any(a => a.id != headerEdit.id && a.reporttable_id == headerEdit.IdBaoCao && a.headername == headerEdit.headername)) { resSubmit = new ResSubmit(false, "Tên tiêu đề cột này đã tồn tại trong báo cáo"); } if (resSubmit.success) { _Header.colspan = ((headerEdit.colspan == 0 || headerEdit.colspan == null) ? 1 : headerEdit.colspan); _Header.headername = headerEdit.headername; _Header.is_bold = headerEdit.is_bold; _Header.is_upper = headerEdit.is_upper; _Header.is_valuebold = headerEdit.is_valuebold; _Header.is_valueupper = headerEdit.is_valueupper; if (headerEdit.is_no == true && headerEdit.is_component == true) { _Header.is_no = true; _Header.is_component = false; } else { _Header.is_no = headerEdit.is_no.Value == true; _Header.is_component = headerEdit.is_component.Value == true; } _Header.rowspan = ((headerEdit.rowspan == 0 || headerEdit.rowspan == null) ? 1 : headerEdit.rowspan); _Header.valuetextalign = (headerEdit.valuetextalign == "right" ? "right" : (headerEdit.valuetextalign == "center" ? "center" : "left")); if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } 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 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 CapNhatSapXepBaoCao(List <listBaoCao> listBaoCaos) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); tongcuclamnghiep.m_reporttable.ToList().All(a => { if (listBaoCaos.Any(b => b.id == a.id)) { var sapxep = listBaoCaos.Where(b => b.id == a.id).FirstOrDefault(); a.order = sapxep.sapxep; } else { a.order = null; } return(true); }); tongcuclamnghiep.SaveChanges(); return(resSubmit); }
public ResSubmit ChinhSuaQuy(PreciousAdd preciousEdit) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Precious = tongcuclamnghiep.m_precious.Where(a => a.id == preciousEdit.id && a.status == false).FirstOrDefault(); if (_Precious == null) { resSubmit = new ResSubmit(false, "Không có quý này"); } if (resSubmit.success && tongcuclamnghiep.m_precious.Any(a => a.id != preciousEdit.id && a.precious_name == preciousEdit.precious_name)) { resSubmit = new ResSubmit(false, "Tên này đã tồn tại"); } if (resSubmit.success && !((preciousEdit.startdate < preciousEdit.enddate) && preciousEdit.completedate > preciousEdit.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 && !(preciousEdit.completedate > DateTime.Now)) { resSubmit = new ResSubmit(false, "Ngày hoàn thành không phù hợp"); } if (resSubmit.success && !(preciousEdit.slowday < preciousEdit.completedate && preciousEdit.slowday > preciousEdit.enddate)) { resSubmit = new ResSubmit(false, "Ngày báo chậm không phù hợp"); } if (resSubmit.success) { _Precious.completedate = preciousEdit.completedate; _Precious.enddate = preciousEdit.enddate; _Precious.precious_name = preciousEdit.precious_name; _Precious.startdate = preciousEdit.startdate; _Precious.slowday = preciousEdit.slowday; if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } } return(resSubmit); }
public ResTableData GetPreciousTableAll(int start, int length, int draw, string search) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); 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) }); return(new ResTableData() { data = data, draw = (draw + 1), recordsFiltered = dataAll.Count(), recordsTotal = dataAll.Count() }); }
public ResTableData GetUnitTable(int start, int length, int draw, string search) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var dataAll = tongcuclamnghiep.m_unit.Where(a => (search.Length > 0 ? (a.unitname.Contains(search) || a.address.Contains(search)) : true)); var data = dataAll.ToList().Skip((start)).Take(length).Select(a => new { a.id, a.unitname, createdate = a.createdate.Value.ToString("dd/MM/yyyy"), account = tongcuclamnghiep.m_account.Where(b => (b.id == a.account_id) || (b.role_id == 2 && b.status == true && !tongcuclamnghiep.m_unit.Any(c => c.account_id == b.id))).Select(b => new { b.id, b.fullname, selected = (a.account_id != null ? (bool?)(b.id == a.account_id) : false) }), a.status, a.address }); return(new ResTableData() { data = data, draw = (draw + 1), recordsFiltered = dataAll.Count(), recordsTotal = dataAll.Count() }); }
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 override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.Session["AccountCookie"] == null) { filterContext.Result = new RedirectResult("/Login/Index"); } else { AccountCookie accountCookie = (AccountCookie)filterContext.HttpContext.Session["AccountCookie"]; string actionName = filterContext.ActionDescriptor.ActionName; string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; string menu_url = string.Format("/{0}/{1}", controllerName, actionName); if (controllerName != "Home") { tongcuclamnghiepEntities dataBase = new tongcuclamnghiepEntities(); var acmenu = dataBase.m_controller_role.Where(a => a.role_id == accountCookie.Role_Id && a.m_controller.controllerurl == menu_url).FirstOrDefault(); if (acmenu == null) { //if (accountCookie.Role_Id == 1) //{ // filterContext.Result = new RedirectResult("/Report/Reportlist"); //} //else //{ // filterContext.Result = new RedirectResult("/Home/Index"); //} filterContext.Result = new RedirectResult("/Home/Index"); } } //else //{ // if (accountCookie.Role_Id == 1) // { // filterContext.Result = new RedirectResult("/Report/Reportlist"); // } //} } }
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 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 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); }