private void btnGuiMail_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateEmailKhiGui();
                int          _CauHinhId = O2S_Common.TypeConvert.Parse.ToInt32(cboEmailGui.SelectedValue.ToString());
                CAUHINHEMAIL _cauhinh   = CauHinhEmailLogic.SelectSingle(_CauHinhId);
                if (_cauhinh == null)
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao _frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.VUI_LONG_NHAP_DAY_DU_THONG_TIN);
                    _frmthongbao.Show();
                    return;
                }

                SmtpClient mailclient = new SmtpClient(_cauhinh.SMTPServer, _cauhinh.Port ?? 0);
                mailclient.EnableSsl   = true;
                mailclient.Credentials = new NetworkCredential(_cauhinh.TaiKhoan, O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Decrypt(_cauhinh.MatKhau, true));

                MailMessage message = new MailMessage(_cauhinh.TaiKhoan, txtEmailNhan.Text);
                message.Subject    = txtTieuDeMail.Text;
                message.Body       = txtNoiDungMail.HtmlText;
                message.IsBodyHtml = true;

                mailclient.Send(message);
                MessageBox.Show(Base.ThongBaoLable.GUI_MAIL_THANH_CONG, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.GUI_MAIL_THANH_CONG);
                //frmthongbao.Show();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                O2S_Common.Logging.LogSystem.Error(ex);
                //O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.GUI_MAIL_THAT_BAI);
                //frmthongbao.Show();
            }
        }
Beispiel #2
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             var rowHandle = gridViewEmail.FocusedRowHandle;
             int _caHocId  = O2S_Common.TypeConvert.Parse.ToInt32(gridViewEmail.GetRowCellValue(rowHandle, "CauHinhEmailId").ToString());
             if (CauHinhEmailLogic.Delete(_caHocId))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                 frmthongbao.Show();
                 LoadGridCauHinhEmail();
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
Beispiel #3
0
 private void LoadGridCauHinhEmail()
 {
     try
     {
         CauHinhEmailFilter _filter = new CauHinhEmailFilter();
         _filter.CoSoId = GlobalSettings.CoSoId;
         List <CAUHINHEMAIL> _lstCauHinhEmail = CauHinhEmailLogic.Select(_filter);
         if (_lstCauHinhEmail != null && _lstCauHinhEmail.Count > 0)
         {
             gridControlEmail.DataSource = _lstCauHinhEmail;
         }
         else
         {
             gridControlEmail.DataSource = null;
         }
         lblTongCong.Text = string.Format("Tổng cộng: {0}", gridViewEmail.RowCount);
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
Beispiel #4
0
        private void gridViewCauHinhEmail_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridViewEmail.RowCount > 0)
                {
                    var rowHandle       = gridViewEmail.FocusedRowHandle;
                    int _CauHinhEmailId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewEmail.GetRowCellValue(rowHandle, "CauHinhEmailId").ToString());

                    this.CauHinhEmailSelect = CauHinhEmailLogic.SelectSingle(_CauHinhEmailId);
                    if (this.CauHinhEmailSelect != null)
                    {
                        CauHinhEmail_ClickData(this.CauHinhEmailSelect);
                        LockAndUnLookPanelControl(false);
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }
Beispiel #5
0
 private void btnLuuThongTin_Click(object sender, EventArgs e)
 {
     try
     {
         if (isInsert)
         {
             int _khoaHocId = 0;
             if (CauHinhEmailLogic.Insert(LoadCauHinhEmail(), ref _khoaHocId))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                 frmthongbao.Show();
             }
             else
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THAT_BAI);
                 frmthongbao.Show();
             }
         }
         else
         {
             if (CauHinhEmailLogic.Update(LoadCauHinhEmail()))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                 frmthongbao.Show();
             }
             else
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                 frmthongbao.Show();
             }
         }
         LoadGridCauHinhEmail();
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
        private void frmHocVienTiemNang_GuiMail_Load(object sender, EventArgs e)
        {
            try
            {
                //Load ds nguoi gui.
                CauHinhEmailFilter _filter = new CauHinhEmailFilter();
                _filter.CoSoId            = GlobalSettings.CoSoId;
                cboEmailGui.DataSource    = CauHinhEmailLogic.Select(_filter);
                cboEmailGui.DisplayMember = "TaiKhoan";
                cboEmailGui.ValueMember   = "CauHinhEmailId";

                HOCVIEN _hocvien = HocVienLogic.SelectSingle(this.HocVienId_Select);
                lblMaHocVien.Text  = _hocvien.MaHocVien;
                lblTenHocVien.Text = _hocvien.TenHocVien;
                txtEmailNhan.Text  = _hocvien.Email;

                txtTieuDeMail.Focus();
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }