コード例 #1
0
 protected void btnSendEmail_Click(object sender, DirectEventArgs e)
 {
     try
     {
         string mailto = e.ExtraParams["Email"];
         if (string.IsNullOrEmpty(mailto))
         {
             X.Msg.Alert(GlobalResourceManager.GetInstance().GetLanguageValue("warning"), GlobalResourceManager.GetInstance().GetDesktopValue("email_not_found")).Show();
             return;
         }
         HeThongController htController = new HeThongController();
         SendMail1.SetEmailTo(htController.GetValueByName(SystemConfigParameter.EMAIL, Session["MaDonVi"].ToString()), htController.GetValueByName(SystemConfigParameter.PASSWORD_EMAIL, Session["MaDonVi"].ToString()), mailto);
         SendMail1.Show();
     }
     catch (Exception ex)
     {
         X.Msg.Alert("Cảnh báo", ex.Message).Show();
     }
 }
コード例 #2
0
    protected void btn_SentEmail_HappyBirthDay_Click(object sender, DirectEventArgs e)
    {
        try
        {
            SelectedRowCollection selecteds = RowSelectionModel3.SelectedRows;
            string    mailto = string.Empty;
            string    error  = "";
            DataTable dt     = DataController.DataHandler.GetInstance().ExecuteDataTable("sp_GetAllEmailHappyBirthDayMonth");
            if (e.ExtraParams["All"] == "True")
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[i]["Email"].ToString()))
                    {
                        mailto += dt.Rows[i]["Email"].ToString() + ", ";
                    }
                    else if (!string.IsNullOrEmpty(dt.Rows[i]["EMAIL_RIENG"].ToString()))
                    {
                        mailto += dt.Rows[i]["EMAIL_RIENG"].ToString() + ", ";
                    }
                    else
                    {
                        error += dt.Rows[i]["HO_TEN2"].ToString() + " ";
                    }
                }
            }
            else
            {
                foreach (var item in selecteds)
                {
                    string ma_CB = item.RecordID;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["Ma_CB"].ToString() == ma_CB)
                        {
                            if (!string.IsNullOrEmpty(dt.Rows[i]["Email"].ToString()))
                            {
                                mailto += dt.Rows[i]["Email"].ToString() + ", ";
                            }
                            else if (!string.IsNullOrEmpty(dt.Rows[i]["EMAIL_RIENG"].ToString()))
                            {
                                mailto += dt.Rows[i]["EMAIL_RIENG"].ToString() + ", ";
                            }
                            else
                            {
                                Dialog.ShowError(GlobalResourceManager.GetInstance().GetDesktopValue("email_not_found"));
                                return;
                            }
                        }
                    }
                }
            }
            string mail = "";
            for (int i = 0; i < mailto.Length - 2; i++)
            {
                mail += mailto[i];
            }
            HeThongController htController = new HeThongController();
            SendMail1.SetEmailTo(htController.GetValueByName(SystemConfigParameter.EMAIL, Session["MaDonVi"].ToString()), htController.GetValueByName(SystemConfigParameter.PASSWORD_EMAIL, Session["MaDonVi"].ToString()), mail);

            SendMail1.Show();
            if (!string.IsNullOrEmpty(error.Trim()))
            {
                Dialog.ShowError("Một số nhân viên không có email :" + error);
            }
        }
        catch (Exception ex)
        {
            Dialog.ShowError("Lỗi xảy ra " + ex.Message);
        }
    }