public ActionResult Index() { //check login if (!IsLogged()) { return(BackToLogin()); } DanhmucServices service = new DanhmucServices(); PhongBanModels parampb = new PhongBanModels(); List <PhongBanModels> lstResult_phongban = service.SelectRowsGDDA(parampb); StringBuilder sbphongban = new StringBuilder(); string pb = ""; string thudientu = Session["thudientu"].ToString().Trim(); if (Session["loginid"].ToString().Trim().ToLower() == "admin" || Session["grouptk"].ToString().Trim() == "1") { //var lstpban = lstResult_phongban.Where(p => p.maphongban == maphongban).ToList(); //if (lstpban.Count() > 0) // pb = "<option value=" + lstpban[0].maphongban + ">" + lstpban[0].tenphongban + "</option>"; //pb = pb + "<option value=0>Chọn phòng ban</option>"; foreach (var item in lstResult_phongban) { pb = pb + "<option value=" + item.maphongban + "> " + item.tenphongban + " </option>"; } } else { foreach (var item in lstResult_phongban.Where(p => p.email == thudientu || p.sodienthoai == thudientu || p.ghichu == thudientu || p.ghichu1 == thudientu || p.ghichu2 == thudientu)) { pb = pb + "<option value=" + item.maphongban + "> " + item.tenphongban + " </option>"; } } ViewBag.sbphongban = pb.ToString(); //foreach (var item in lstResult_phongban.Where(p=>p.phongban_congtruong=="0")) //{ // sbphongban.Append(string.Format("<option value='{0}'>{1}</option>", item.maphongban, item.tenphongban)); //} // ViewBag.sbphongban = sbphongban.ToString(); return(View()); }
public JsonResult SelectRows(PhongBanModels model) { PhongBanModels param = new PhongBanModels(); DanhmucServices service = new DanhmucServices(); List <PhongBanModels> lstResult = service.SelectRowsGDDA(param); StringBuilder sbResult = new StringBuilder(); StringBuilder sbRows = new StringBuilder(); if (lstResult.Count > 0) { string strSTT = ""; int i = 1; foreach (var item in lstResult) { strSTT = i.ToString(); if (item.madonvi == "1") { item.tendonvi = "Công ty cổ phẩn Ricons"; } sbRows.Append(PrepareDataJson(item, strSTT)); i++; } if (sbRows.Length > 0) { sbRows.Remove(sbRows.Length - 1, 1); } } sbResult.Append("{"); sbResult.Append("\"isHeader\":\"" + "111" + "\","); sbResult.Append("\"currentRow\":\"" + lstResult.Count + "\","); sbResult.Append("\"Pages\":\"" + lstResult.Count + "\","); if (model.maphongban != "0") { sbResult.Append("\"SubRow\":\"" + "true" + "\","); sbResult.Append("\"RowID\":\"" + model.maphongban + "\","); } sbResult.Append("\"data\":[" + sbRows.ToString() + "]"); sbResult.Append("}"); return(Json(sbResult.ToString(), JsonRequestBehavior.AllowGet)); }
public void MailLich(string NoiDung, string path, string filename, string maphongban, int phongban_congtruong) { string sMailGui = System.Configuration.ConfigurationManager.AppSettings["MailSend"]; string sPass = System.Configuration.ConfigurationManager.AppSettings["MailPass"]; string sHost = System.Configuration.ConfigurationManager.AppSettings["MailHost"]; string sPort = System.Configuration.ConfigurationManager.AppSettings["MailPort"]; string sTieuDe = System.Configuration.ConfigurationManager.AppSettings["ScheduleSubject"]; string sMailTo = System.Configuration.ConfigurationManager.AppSettings["schedulerman"]; // gui mail var fromAddress = new MailAddress(sMailGui); string fromPassword = sPass; string subject = sTieuDe; string body = NoiDung; DanhmucServices service = new DanhmucServices(); PhongBanModels parampb = new PhongBanModels(); List <PhongBanModels> lstResult_phongban; List <PhongBanModels> y = null; var lstcaptrentt = y; if (phongban_congtruong == 0) { lstResult_phongban = service.SelectRows(parampb); lstcaptrentt = lstResult_phongban.Where(p => p.maphongban == maphongban).ToList(); if (lstcaptrentt[0].email.ToString().Trim() == null) { sMailTo = "*****@*****.**"; } else { sMailTo = lstcaptrentt[0].email; } } else if (phongban_congtruong == 1) { lstResult_phongban = service.SelectRows2(parampb); lstcaptrentt = lstResult_phongban.Where(p => p.maphongban == maphongban).ToList(); if (lstcaptrentt[0].email.ToString().Trim() == null) { sMailTo = "*****@*****.**"; } else { sMailTo = lstcaptrentt[0].email; } } else if (phongban_congtruong == 2) { lstResult_phongban = service.SelectRowsGDDA(parampb); lstcaptrentt = lstResult_phongban.Where(p => p.maphongban == maphongban).ToList(); if (lstcaptrentt[0].email.ToString().Trim() == null) { sMailTo = "*****@*****.**"; } else { sMailTo = lstcaptrentt[0].email; } } else if (phongban_congtruong == 3) { lstResult_phongban = service.SelectRowsBCTC(parampb); lstcaptrentt = lstResult_phongban.Where(p => p.maphongban == maphongban).ToList(); if (lstcaptrentt[0].email.ToString().Trim() == null) { sMailTo = "*****@*****.**"; } else { sMailTo = lstcaptrentt[0].email; } } var toAddress = new MailAddress(sMailTo); var smtp = new SmtpClient { Host = sHost, Port = int.Parse(sPort), EnableSsl = false, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; //var smtp = new SmtpClient(); subject = "NEWTECONS PROJECT REPORT: " + lstcaptrentt[0].tenphongban; body = "<p>Kính gửi anh chị,</p><p>Đính kèm là báo cáo tuần gửi từ hệ thống của: " + lstcaptrentt[0].tenphongban + "</p>" + "<p>Trân trọng,</p>"; using (var message = new MailMessage(fromAddress, toAddress) { IsBodyHtml = true, Subject = subject, Body = body }) { try { Attachment data = new Attachment(path, MediaTypeNames.Application.Octet); message.Attachments.Add(data); if (!string.IsNullOrEmpty(lstcaptrentt[0].sodienthoai)) { message.CC.Add(lstcaptrentt[0].sodienthoai); } if (!string.IsNullOrEmpty(lstcaptrentt[0].ghichu)) { message.CC.Add(lstcaptrentt[0].ghichu); } if (!string.IsNullOrEmpty(lstcaptrentt[0].ghichu1)) { message.CC.Add(lstcaptrentt[0].ghichu1); } if (!string.IsNullOrEmpty(lstcaptrentt[0].ghichu2)) { message.CC.Add(lstcaptrentt[0].ghichu2); } smtp.Send(message); smtp.Dispose(); } catch (SmtpFailedRecipientsException ex) { for (int i = 0; i < ex.InnerExceptions.Length; i++) { SmtpStatusCode status = ex.InnerExceptions[i].StatusCode; if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable) { // Console.WriteLine("Delivery failed - retrying in 5 seconds."); System.Threading.Thread.Sleep(5000); smtp.Send(message); } else { // Console.WriteLine("Failed to deliver message to {0}", ex.InnerExceptions[i].FailedRecipient); throw ex; } } } catch (Exception ex) { // Console.WriteLine("Exception caught in RetryIfBusy(): {0}",ex.ToString()); throw ex; } finally { smtp.Dispose(); } } }
public ActionResult Edit(string macuochop) { if (!IsLogged()) { return(BackToLogin()); } Item_weedModels param = new Item_weedModels(); DanhmucServices service = new DanhmucServices(); List <Item_weedModels> lstResult_Tuan = service.SelectRows_giaovien(param); StringBuilder sbtuan = new StringBuilder(); foreach (var item in lstResult_Tuan) { item.tentuan = item.tentuan + " " + item.tungay + " - " + item.denngay; sbtuan.Append(string.Format("<option value='{0}'>{1}</option>", item.matuan, item.tentuan)); } ViewBag.sbtuan = sbtuan.ToString(); //phong ban PhongBanModels parampb = new PhongBanModels(); List <PhongBanModels> lstResult_phongban = service.SelectRowsGDDA(parampb); StringBuilder sbphongban = new StringBuilder(); string pb = ""; string maphongban = Session["maphongban"].ToString().Trim(); if (Session["loginid"].ToString().Trim().ToLower() == "admin" || Session["grouptk"].ToString().Trim() == "1") { pb = pb + "<option value=0>Chọn phòng ban</option>"; foreach (var item in lstResult_phongban) { pb = pb + "<option value=" + item.maphongban + "> " + item.tenphongban + " </option>"; } } else { foreach (var item in lstResult_phongban.Where(p => p.maphongban == maphongban)) { pb = pb + "<option value=" + item.maphongban + "> " + item.tenphongban + " </option>"; } } ViewBag.sbphongban = pb.ToString(); StringBuilder sbphonghop = new StringBuilder(); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "0", "Lựa chọn Phòng họp")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "1", "Tầng 3 - Phòng họp 1")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "2", "Tầng 3 - Phòng họp 2")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "3", "Tầng 3 - Phòng họp lớn")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "4", "Tầng 3A - Phòng họp nhỏ")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "5", "Tầng 3A - Phòng họp lớn")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "6", "Khác")); ViewBag.sbphonghop = sbphonghop.ToString(); FunctionXML function = new FunctionXML(Functions.MapPath("~/Xml/Config/encryptionkeyEncodeLink.config")); macuochop = AES.DecryptText(macuochop, function.ReadXMLGetKeyEncrypt()); DaotaoServices servicevpp = new DaotaoServices(); List <WeedMeetingModels> lstResult = new List <WeedMeetingModels>(); lstResult = servicevpp.SelectRows_WeedMeeting_hieuchinh(macuochop); if (lstResult.Count > 0) { //replace(/'/g, "daunhaydon").replace(/"/g, '').replace(/&/g, 'daukytuva') + "',"; lstResult[0].lydobuoihop = lstResult[0].lydobuoihop.Replace("daunhaydon", "'").Replace("daukytuva", "&"); lstResult[0].thanhphanthamdu = lstResult[0].thanhphanthamdu.Replace("daunhaydon", "'").Replace("daukytuva", "&"); //System.Text.RegularExpressions.Regex.Replace(json["noidungcuochop"].ToString().Trim(), @"\n", "\\n").Replace("'", ""); string chuoinoidungs = ""; string chuoinoidung = System.Text.RegularExpressions.Regex.Replace(lstResult[0].noidungcuochop, @"\\n", "\n"); string[] noisungcuochop = chuoinoidung.Split(new char[] { '\n' }); for (int i = 0; i < noisungcuochop.Length; i++) { chuoinoidungs = chuoinoidungs + noisungcuochop[i].Replace("daunhaydon", "'").Replace("daukytuva", "&") + Environment.NewLine; } lstResult[0].noidungcuochop = chuoinoidungs; return(View(lstResult[0])); } return(View()); }
///Thêm mới lịch họp tuần public ActionResult Create() { if (!IsLogged()) { return(BackToLogin()); } Item_weedModels param = new Item_weedModels(); DanhmucServices service = new DanhmucServices(); List <Item_weedModels> lstResult_Tuan = service.SelectRows_giaovien(param); StringBuilder sbtuan = new StringBuilder(); foreach (var item in lstResult_Tuan) { item.tentuan = item.tentuan + " " + item.tungay + " - " + item.denngay; sbtuan.Append(string.Format("<option value='{0}'>{1}</option>", item.matuan, item.tentuan)); } ViewBag.sbtuan = sbtuan.ToString(); //phong ban PhongBanModels parampb = new PhongBanModels(); List <PhongBanModels> lstResult_phongban = service.SelectRowsGDDA(parampb); StringBuilder sbphongban = new StringBuilder(); string pb = ""; string maphongban = Session["maphongban"].ToString().Trim(); if (Session["loginid"].ToString().Trim().ToLower() == "admin" || Session["grouptk"].ToString().Trim() == "1") { pb = pb + "<option value=0>Chọn phòng ban</option>"; foreach (var item in lstResult_phongban) { pb = pb + "<option value=" + item.maphongban + "> " + item.tenphongban + " </option>"; } } else { foreach (var item in lstResult_phongban.Where(p => p.maphongban == maphongban)) { pb = pb + "<option value=" + item.maphongban + "> " + item.tenphongban + " </option>"; } } ViewBag.sbphongban = pb.ToString(); StringBuilder sbphonghop = new StringBuilder(); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "0", "Lựa chọn Phòng họp")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "1", "Tầng 3 - Phòng họp 1")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "2", "Tầng 3 - Phòng họp 2")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "3", "Tầng 3 - Phòng họp lớn")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "4", "Tầng 3A - Phòng họp nhỏ")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "5", "Tầng 3A - Phòng họp lớn")); sbphonghop.Append(string.Format("<option value={0}>{1}</option>", "6", "Khác")); ViewBag.sbphonghop = sbphonghop.ToString(); StringBuilder sbloaibaocao = new StringBuilder(); sbloaibaocao.Append(string.Format("<option value={0}>{1}</option>", "1", "Báo cáo tuần CHT/TPB")); //sbloaibaocao.Append(string.Format("<option value={0}>{1}</option>", "2", "Báo cáo tuần Thiết Bị")); //sbloaibaocao.Append(string.Format("<option value={0}>{1}</option>", "3", "Báo cáo tuần HSSE")); //sbloaibaocao.Append(string.Format("<option value={0}>{1}</option>", "4", "Báo cáo tuần QAQC")); //sbloaibaocao.Append(string.Format("<option value={0}>{1}</option>", "5", "Báo cáo tuần MEP")); ViewBag.sbloaibaocao = sbloaibaocao.ToString(); return(View()); }