public string InsertRow(MucTieuCongViecModels clParam, string maNhanSu) { logger.Start("InsertRow"); string strResult = ""; try { Hashtable param = new Hashtable(); param["seqname"] = "seq_cv_kehoach"; string strid = sqlMap.ExecuteQueryForObject("Common.GetNextVal", param).ToString(); int iID = -1; int.TryParse(strid, out iID); if (iID == -1) { return(string.Empty); } //tao ma makehoach param["makehoach"] = string.Format(Functiontring.ReturnStringFormatID("makehoach"), maNhanSu, DateTime.Now.Year, DateTime.Now.Month, iID.ToString("00000000")); clParam.makehoach = param["makehoach"].ToString(); base.InsertData(clParam, "cv_kehoach"); strResult = param["makehoach"].ToString(); } catch (Exception ex) { strResult = "-1"; logger.Error(ex.Message); } logger.End("InsertRow"); return(strResult); }
/// <summary> /// Them cong viec /// </summary> /// <param name="clParam">CongViecModels</param> /// <returns></returns> public string InsertRow(CongViecModels clParam) { logger.Start("InsertRow"); string strResult = ""; try { sqlMap.BeginTransaction(); //chuyen doi models cong viec sang param Hashtable param = new Hashtable(); param = base.SetDataToHashtable(false, clParam); //lay gia tri seqnam m_congviec param["seqname"] = "seq_m_congviec"; string strid = sqlMap.ExecuteQueryForObject("Common.GetNextVal", param).ToString(); int iID = -1; int.TryParse(strid, out iID); if (iID == -1) { return(string.Empty); } //tao ma cong viec param["macongviec"] = string.Format(Functiontring.ReturnStringFormatID("macongviec"), clParam.tenviettat, DateTime.Now.Year, DateTime.Now.Month, iID.ToString("0000000000")); sqlMap.Insert("cv_congviec.InsertRow", param); sqlMap.CommitTransaction(); //return macong strResult = param["macongviec"].ToString(); } catch (Exception ex) { sqlMap.RollbackTransaction(); strResult = string.Empty; logger.Error(ex.Message); } logger.End("InsertRow"); return(strResult); }
public string InsertRow(M_ThongBao clParam) { logger.Start("InsertRow"); string strResult = ""; try { sqlMap.BeginTransaction(); Hashtable param = new Hashtable(); param = base.SetDataToHashtable(false, clParam); param["seqname"] = "seq_m_thongbao"; string strid = sqlMap.ExecuteQueryForObject("Common.GetNextVal", param).ToString(); int iID = -1; int.TryParse(strid, out iID); if (iID == -1) { return(string.Empty); } //tao ma cong viec param["mathongbao"] = string.Format(Functiontring.ReturnStringFormatID("mathongbao"), clParam.manhansu, DateTime.Now.Year, DateTime.Now.Month, iID.ToString("000000")); sqlMap.Insert("m_thongbao.InsertRow", param); sqlMap.CommitTransaction(); strResult = param["mathongbao"].ToString(); } catch (Exception ex) { sqlMap.RollbackTransaction(); strResult = "-1"; logger.Error(ex.Message); } logger.End("InsertRow"); return(strResult); }
public ActionResult Editforleave(string madangky, AbsentModels model, string luu) { if (!IsLogged()) { return(BackToLogin()); } if (model.nghiphep == "on") { model.nghiphep = "1"; } else { model.nghikhac = "0"; } if (model.nghikhongluong == "on") { model.nghikhongluong = "1"; } else { model.nghikhac = "0"; } if (model.nghithaisan == "on") { model.nghithaisan = "1"; } else { model.nghikhac = "0"; } if (model.conkh == "on") { model.conkh = "1"; } else { model.conkh = "0"; } if (model.canhankh == "on") { model.canhankh = "1"; } else { model.canhankh = "0"; } if (model.chame_mat == "on") { model.chame_mat = "1"; } else { model.chame_mat = "0"; } if (model.ongba_mat == "on") { model.ongba_mat = "1"; } else { model.ongba_mat = "0"; } if (model.thangsinh.ToString() != "") { model.ngaysinh = model.ngaysinh + "/" + model.thangsinh.ToString(); } if (model.namsinh.ToString() != "") { model.ngaysinh = model.ngaysinh + "/" + model.namsinh.ToString(); } model.xoa = "0"; model.nguoitao = int.Parse(Session["userid"].ToString()); model.ngaytao = "GETDATE()"; model.manghiphep = MaDangKyNP; AbsentServices service = new AbsentServices(); model.manghiphep = service.Insert_Donxinnghiphep(model); DanhmucServices service_pb = new DanhmucServices(); PhongBanModels parampb = new PhongBanModels(); parampb.maphongban = model.maphongban.ToString().Trim(); List <PhongBanModels> lstResult_phongban = service_pb.SelectRows(parampb); if (lstResult_phongban.Count > 0) { string hotento = ""; if (lstResult_phongban[0].hovaten.ToString() != "") { hotento = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(lstResult_phongban[0].hovaten.ToString().Trim().ToLower()); } if (lstResult_phongban[0].email.ToString().Trim() != "") { #region string mailto = lstResult_phongban[0].email.ToString().Trim(); model.tenphongban = lstResult_phongban[0].tenphongban.ToString().Trim(); string strEncryptCode = MaDangKyNP + "0070pXQSeNsQRuzoCmUYfuX/vA==6"; string mailcapquanly = ""; if (model.machucdanh == "1" && double.Parse(model.songayxinnghi) > 2) { if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "1") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("1")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "2") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("2")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "3") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("3")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "4") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("4")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "5") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("5")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "6") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("6")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "7") { mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("7")); } string[] chuoitach = mailcapquanly.Split('/'); strEncryptCode = strEncryptCode + "&emailto=" + chuoitach[0] + "&hotento=" + chuoitach[1]; } else if (model.machucdanh == "2") { if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "1") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("1")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "2") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("2")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "3") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("3")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "4") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("4")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "5") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("5")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "6") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("6")); } else if (lstResult_phongban[0].thuocquanly.ToString().Trim() == "7") { mailto = string.Format(Functiontring.ReturnStringFormatEmail("7")); } string[] chuoicap1 = mailto.Split('/'); mailto = chuoicap1[0].Trim(); hotento = chuoicap1[1].Trim(); mailcapquanly = string.Format(Functiontring.ReturnStringFormatEmail("1")); /// Goi cho tong giam doc string[] chuoitach = mailcapquanly.Split('/'); strEncryptCode = strEncryptCode + "&emailto=" + chuoitach[0] + "&hotento=" + chuoitach[1]; } #endregion send_Mail(strEncryptCode, mailto, "Đơn xin nghỉ phép", "Nội dung", model, hotento); } return(RedirectToAction("Vacationlist", "Absent")); } else { return(RedirectToAction("Editforleave")); } //return View(); }
public string send_Mail(string strEncryptCode, string mailto, string Subject, string Contents, AbsentModels model, string hotento) { _logger.Start("send_Mail"); try { string linkname = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("linkname")); strEncryptCode = linkname.Trim() + strEncryptCode + "&mailcanhan=" + mailto; if ((model.machucdanh == "1" && double.Parse(model.songayxinnghi) > 2) || model.machucdanh == "2") { strEncryptCode = strEncryptCode + "&hovaten=" + model.hovaten + "&tenphongban=" + model.tenphongban + "&songayxinnghi=" + model.songayxinnghi + "&ngayxinnghitu=" + model.ngayxinnghitu + "&ngayxinnghiden=" + model.ngayxinnghiden + "&lydoxinnghi=" + model.lydoxinnghi + "&sodienthoai=" + model.sodienthoai + "&mailcanhan=" + model.email; } //string smtp_port = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_port")); string smtp_host = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_host")); string smtp_user = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_user")); #region StringBuilder sb = new StringBuilder(); sb.Append("<html><head>"); sb.Append("<link rel='stylesheet' type='text/css' href='theme.css' />"); sb.Append("</head>"); sb.Append("<body style='margin-top: 20px; padding: 0; width: 650px; font-size: 1em;color:black;'>"); //margin: 0 auto; de canh giua sb.Append("<table cellpadding='0' cellspacing='0' width='650px' >"); sb.Append("<tbody>"); sb.Append("<tr>"); sb.Append("<td height='76px' width='650px' >"); sb.Append("<table cellpadding='0' cellspacing='0' width='100%'>"); sb.Append("<tbody>"); sb.Append("<tr>"); sb.Append("<td>"); sb.Append("<div style='width:150px;float:left;height :45px; line-height:45px; padding-top:10px;'>"); sb.Append("<img src='http://i.imgur.com/yKqNNy2.png' alt='ddd' style='width:100px; height:45px;'/>"); sb.Append("</div>"); sb.Append("</td>"); sb.Append("<td>"); sb.Append("<div style='width:400px; text-align:center;font-weight: bold;float:left;line-height:45px'>"); sb.Append("<p style= 'width:400px;text-align:center;font-size:18px;font-weight:bold;line-height:45px;padding-left:80px;float:left;'> ĐƠN XIN NGHỈ PHÉP</p>"); sb.Append("</div>"); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("</tbody>"); sb.Append("</table>"); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("</tbody>"); sb.Append("</table>"); sb.Append("<hr style=border: 1px solid #000; width: 100% />"); sb.Append("<table style='width:650px; font-size:14px;'>"); sb.Append("<tr><td style='padding-left:10px;'><p><strong><em><u>Kính gửi Anh/Chị:</u></em> " + hotento + "</strong></p></td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Họ và tên: " + model.hovaten + "" + "</td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Công tác tại: " + model.tenphongban + "" + "</td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Số ngày xin nghỉ: " + model.songayxinnghi + "" + "</td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Từ ngày: " + model.ngayxinnghitu + " đến ngày: " + model.ngayxinnghiden + "" + "</td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Lý do xin nghỉ: " + model.lydoxinnghi + "" + "</td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Số điện thoại: " + model.sodienthoai + "" + "</td></tr>"); sb.Append("<tr><td style='float:left;height :22px; line-height:22px; padding-left:10px;'>" + "Email: " + model.email + "" + "</td></tr>"); //style='background-color:blue;color:white' sb.Append("<tr><td style='float:left; padding-left:10px; padding-top:10px;'><a href='" + strEncryptCode + "&dongy=1'> Đồng ý</a> <a href='" + strEncryptCode + "&dongy=3'>Không đồng ý</a></td></tr>"); sb.Append("</table>"); sb.Append("</body>"); sb.Append("</html>"); #endregion System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(smtp_user, mailto.Trim()); message.From = new MailAddress(mailto.Trim(), Subject, System.Text.Encoding.UTF8); message.Subject = Subject; message.Body = sb.ToString(); message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; message.Priority = MailPriority.High; SmtpClient client = new SmtpClient(smtp_host); client.UseDefaultCredentials = true; try { client.Send(message); } catch (Exception ex) { Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString()); } return("Successfull!"); } catch (Exception ms) { _logger.Error(ms); return(ms.Message); } _logger.End("send_Mail"); }
public ActionResult CollaborateEdit(CollaborateEditModel model) { model.NguoiDi = int.Parse(Session["userid"].ToString()); var collaborate = _dataService.CollaborateCommand(model); if (model.SendMail) { var sModel = new SendMailModel(); var domain = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("domain")); sModel.TieuDe = model.TieuDe; sModel.TuNgay = model.TuNgay; sModel.DenNgay = model.DenNgay; sModel.MoTa = model.MoTa; string chuoicongtruong = ""; string[] macongtruong = model.NoiCongTac.Split(','); for (int i = 0; i < macongtruong.Length; i++) { var congtruong = _dataService.GetListAllPhongbanCongtruongbyID(macongtruong[i].ToString()); if (congtruong.Count > 0 && i < (macongtruong.Length - 1)) { chuoicongtruong = chuoicongtruong + congtruong[0].tenphongban + ", "; } if (congtruong.Count > 0 && i == (macongtruong.Length - 1)) { chuoicongtruong = chuoicongtruong + congtruong[0].tenphongban; } } sModel.phongbancongtruongten = chuoicongtruong; // Call Array.Sort method. sModel.AgreeLink = domain + "/Collaborate/ApprovalCollaborate/?" + "id=" + collaborate.Id + "&status=" + 2; sModel.DisagreeLink = domain + "/Collaborate/ApprovalCollaborate/?" + "id=" + collaborate.Id + "&status=" + 3; string content = RenderPartialToString("~/Views/Collaborate/Emails/MailCongTac.cshtml", sModel); var mail = new EmailComponent(); var result = mail.Send(new MailObj() { To = collaborate.EmailNguoiDuyet.Trim(), Subject = "ĐĂNG KÝ Đi CÔNG TÁC", Body = content }); _dataService.ApprovalCollaborate(collaborate.Id, 1); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public bool Send(MailObj email) { //var message = ""; var status = 0; //string smtp_host = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_host")); //string smtp_user_mailgui = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_user")); MailMessage mailMessage = new MailMessage(); //mailMessage.To.Add(email.To); //mailMessage.From = new MailAddress("*****@*****.**", email.SenderName, Encoding.UTF8); //mailMessage.Subject = email.Subject; //mailMessage.Body = email.Body; //mailMessage.IsBodyHtml = true; //mailMessage.SubjectEncoding = Encoding.UTF8; //try //{ // using (SmtpClient smtpClient = new SmtpClient()) // { // smtpClient.EnableSsl = true; // smtpClient.Host = "smtp.gmail.com"; // smtpClient.Port = 25; // smtpClient.UseDefaultCredentials = true; // smtpClient.Credentials = new NetworkCredential("*****@*****.**", "hongson123"); // smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; // smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); // smtpClient.Send(mailMessage); // } // return true; //} //catch (Exception e) //{ // return false; //} string smtp_host = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_host")); string smtp_user_mailgui = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("smtp_user")); MailMessage message = new System.Net.Mail.MailMessage(smtp_user_mailgui, email.To); message.From = new MailAddress(smtp_user_mailgui.Trim(), "ĐĂNG KÝ Đi CÔNG TÁC", System.Text.Encoding.UTF8); message.Subject = email.Subject; message.Body = email.Body.ToString(); message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; message.Priority = MailPriority.High; SmtpClient client = new SmtpClient(smtp_host); client.UseDefaultCredentials = true; try { client.Send(message); return(true); } catch (Exception ex) { Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString()); return(false); } }