private void SaveMail_Send() { try { var mail = new MAIL_SEND(); mail.Id = mailSendId; mail.Address = txtAddress.Text; mail.IsActive = chkIsActive.Checked; mail.PassWord = txtPassword.Text; var mailTypeSelect = ((MAIL_TYPE)cbbMailTypeSend.SelectedItem); mail.MailTypeId = mailTypeSelect != null ? mailTypeSelect.id : 0; mail.Note = txtNote.Text; var result = BLLMailSend.CreateOrUpdate(mail); MessageBox.Show(result.Messages[0].msg, result.Messages[0].Title); if (result.IsSuccess) { ResetMailSendForm(); LoadListMailSendToGridView(); } } catch (Exception ex) { MessageBox.Show("Lỗi :" + ex.Message); } }
private void LoadListMailSendToGridView() { try { dgvListMailSend.DataSource = BLLMailSend.GetAll(); } catch (Exception ex) { throw ex; } }
private void LoadDataForCbbMailSend() { try { var listMail = BLLMailSend.GetAll();// mailSendDAO.GetListSelectItem(); if (listMail != null && listMail.Count > 0) { cbbMailSend.DataSource = listMail.ToList(); cbbMailSend.DisplayMember = "Address"; cbbMailSend.ValueMember = "Id"; cbbMailSend.SelectedIndex = 0; } } catch (Exception ex) { throw ex; } }
private void btnDelete_s_Click(object sender, EventArgs e) { try { if (mailSendId > 0) { if (MessageBox.Show("Bạn có muốn xoá?", "Xoá Mail", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BLLMailSend.Delete(mailSendId); ResetMailSendForm(); LoadListMailSendToGridView(); } } else { MessageBox.Show("Lỗi: Bạn chưa chọn đối tượng để xoá."); } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message); } }
private void SendMails(int mailTemplateId) { try { // GhiFileLog(DateTime.Now + "SendMails "); error = string.Empty; var mailTemplateInfo = BLLMailTemplate.GetById(mailTemplateId); //mailTemplateFileDAO.GetIrnfoById(mailTemplateId); if (mailTemplateInfo != null) { var mSend = BLLMailSend.GetById(mailTemplateInfo.MailSendId); if (mSend != null) { strType = mSend.MailTypeName; strHost = mSend.Host.Trim(); intPort = int.Parse(mSend.Port); strFrom = mSend.Address; strDisplayName = mSend.Note; strPassword = mSend.PassWord; strSubject = mailTemplateInfo.Subject; strBody = mailTemplateInfo.Content; strTo = string.Empty; if (!string.IsNullOrEmpty(mailTemplateInfo.MailReceiveIds)) { var mRecives = BLLMailReceive.GetAll(mailTemplateInfo.MailReceiveIds.Split('|').Select(x => Convert.ToInt32(x)).ToList()); if (mRecives != null && mRecives.Count > 0) { foreach (var email in mRecives) { strTo += (strTo.Length == 0 ? email.Address : ", " + email.Address); } } if (!string.IsNullOrEmpty(mailTemplateInfo.MailFileIds)) { var mFiles = BLLMailFile.GetAll(mailTemplateInfo.MailFileIds.Split('|').Select(x => Convert.ToInt32(x)).ToList()); if (mFiles != null && mFiles.Count > 0) { if (listFileAttactment == null) { listFileAttactment = new List <string>(); } DateTime dtTo = DateTime.Now; foreach (var file in mFiles) { string path = Application.StartupPath + @file.Path; string tieuDe = file.Name; string fileName = file.Code.Trim() + dtTo.ToString("dd_MM_yyyy_hh_mm") + ".xlsx"; List <string> files; switch (file.SystemName.Trim().ToUpper()) { case eFile.NSCHUYEN: listFileAttactment.AddRange(LoadDataNSChuyenExportToExcel(tieuDe, path, fileName)); break; case eFile.NSCCUM: listFileAttactment.AddRange(LoadDataNSCum(tieuDe, path, fileName)); break; case eFile.NS_CHUYEN_THEO_GIO_MrTri: listFileAttactment.AddRange(LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.MrTri)); break; case eFile.NS_CHUYEN_THEO_GIO_MDG: listFileAttactment.AddRange(LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.MDG)); break; case eFile.NS_CHUYEN_THEO_GIO_THIENSON: files = LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.ThienSon); listFileAttactment.AddRange(files); break; case eFile.NS_CHUYEN_THEO_GIO_SONHA: files = LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.SonHa); listFileAttactment.AddRange(files); break; case eFile.NSCHUYEN_HOANGGIA: // MessageBox.Show("eFile.NSCHUYEN_HOANGGIA"); files = LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.HoangGia); listFileAttactment.AddRange(files); break; case eFile.Chart_KCSInHour: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, true, true, (int)eGetType.KCS)); break; case eFile.Chart_TCInHour: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, false, true, (int)eGetType.TC)); break; case eFile.Chart_ERRORInHour: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, true, false, true, (int)eGetType.Error)); break; case eFile.Chart_KCSInDay: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, true, false, (int)eGetType.KCS)); break; case eFile.Chart_TCInDay: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, false, false, (int)eGetType.TC)); break; case eFile.Chart_ERRORInDay: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, true, true, false, (int)eGetType.Error)); break; } } } } isSendMail = true; } else { error = "Lỗi: Không có địa chỉ nhận mail."; } } else { error = "Lỗi: Không tìm thấy thông tin mail gửi."; } } else { error = "Lỗi: Không tìm thấy cấu hình mail."; } if (!string.IsNullOrEmpty(error)) { MessageBox.Show(error); } } catch (Exception ex) { } }