private void btnSua_Click(object sender, EventArgs e)
        {
            bool       st = false;
            Connection cn = new Connection();

            cn.OpenConn();
            string macb     = txtmacb.Text;
            string makhoa   = cbmakhoa.SelectedValue.ToString();
            string hoten    = txthoten.Text;
            string ngaysinh = dpngaysinh.Value.ToString("yyyy/MM/dd");

            string nam = radioNam.Text;
            string nu  = radioNu.Text;

            string chucvu  = txtchucvu.Text;
            string email   = txtemail.Text;
            string matkhau = txtmk.Text;
            string quyen   = cbquyen.Text;


            //else
            cm = new SqlCommand("select MACB from CANBO where MACB='" + macb + "'", cn.con);
            string ma = cm.ExecuteScalar() as string;

            if (macb == ma)
            {
                //cm = new SqlCommand("select Count(QUYENHAN)  from CANBO where QUYENHAN= 'admin'  ", cn.con);
                //int qh = (int)cm.ExecuteScalar();
                //if (qh == 0)
                //{
                //    errorProvider1.SetError(cbquyen, "Không thể thay đổi quyền hạn");
                //    return;
                //}
                //else
                //{
                DialogResult dlr = MessageBox.Show("Bạn có chắc muốn sửa?", "THÔNG BÁO", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (DialogResult.OK == dlr)
                {
                    if (radioNam.Checked == true)
                    {
                        radioNam.Text = "Nam";
                        string     sqlsua = "update CANBO set MACB='" + macb + "',MAKHOA=N'" + makhoa + "',HOTEN=N'" + hoten + "',NGAYSINH='" + ngaysinh + "',GIOITINH='" + nam + "',CHUCVU=N'" + chucvu + "',EMAIL='" + email + "',MATKHAU='" + matkhau + "',QUYENHAN='" + quyen + "' where  MACB='" + macb + "'";
                        SqlCommand cmd    = new SqlCommand(sqlsua, cn.con);
                        try
                        {
                            cmd.ExecuteNonQuery();
                            cmd.Dispose();
                            cn.CloseConn();
                            MessageBox.Show("Sửa thành công");
                            lbChuy.Text = " ";
                            //frmQuan_tri_nguoi_dung_Load(sender, e);
                            //Reset();
                            st = true;
                        }
                        catch
                        {
                            cmd.Dispose();
                            cn.CloseConn();
                            MessageBox.Show("Sửa thất bại!");
                        }
                    }
                    else
                    {
                        if (radioNu.Checked == true)
                        {
                            radioNu.Text = "Nu";
                        }
                        string     sqlsua = "update CANBO set MACB='" + macb + "',MAKHOA=N'" + makhoa + "',HOTEN=N'" + hoten + "',NGAYSINH='" + ngaysinh + "',GIOITINH='" + nu + "',CHUCVU=N'" + chucvu + "',EMAIL='" + email + "',MATKHAU='" + matkhau + "',QUYENHAN='" + quyen + "' where  MACB='" + macb + "' ";
                        SqlCommand cmd    = new SqlCommand(sqlsua, cn.con);
                        try
                        {
                            cmd.ExecuteNonQuery();
                            cmd.Dispose();
                            cn.CloseConn();
                            MessageBox.Show("Sửa thành công");
                            lbChuy.Text = " ";
                            //frmQuan_tri_nguoi_dung_Load(sender, e);
                            //Reset();
                            st = true;
                        }
                        catch
                        {
                            cmd.Dispose();
                            cn.CloseConn();
                            MessageBox.Show("Sửa thất bại!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Không trùng mã cán bộ!");
                }
                hienthi();
                // dgvthongtin.DataSource = danhsachCB();
                //}
            }
            string query = "SELECT MACB, HOTEN, CHUCVU FROM CANBO WHERE MACB = '" + txtmacb.Text.Trim() + "'";



            SqlCommand     cmdd = new SqlCommand(query, cn.con);
            SqlDataAdapter da   = new SqlDataAdapter(cmdd);
            DataSet        ds   = new DataSet();

            da.Fill(ds);
            DataTable dt = ds.Tables[0];
            // gui mil
            Email mail = new Email();

            foreach (DataRow dr in dt.Rows)
            {
                string a = @"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  <meta name='viewport' content='width=320, initial-scale=1' />
  <title>Airmail Confirm</title>
  <style type='text/css'>

    /* ----- Client Fixes ----- */

    /* Force Outlook to provide a 'view in browser' message */
    #outlook a {
      padding: 0;
    }

    /* Force Hotmail to display emails at full width */
    .ReadMsgBody {
      width: 100%;
    }

    .ExternalClass {
      width: 100%;
    }

    /* Force Hotmail to display normal line spacing */
    .ExternalClass,
    .ExternalClass p,
    .ExternalClass span,
    .ExternalClass font,
    .ExternalClass td,
    .ExternalClass div {
      line-height: 100%;
    }


     /* Prevent WebKit and Windows mobile changing default text sizes */
    body, table, td, p, a, li, blockquote {
      -webkit-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
    }

    /* Remove spacing between tables in Outlook 2007 and up */
    table, td {
      mso-table-lspace: 0pt;
      mso-table-rspace: 0pt;
    }

    /* Allow smoother rendering of resized image in Internet Explorer */
    img {
      -ms-interpolation-mode: bicubic;
    }

     /* ----- Reset ----- */

    html,
    body,
    .body-wrap,
    .body-wrap-cell {
      margin: 0;
      padding: 0;
      background: #ffffff;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #464646;
      text-align: left;
    }

    img {
      border: 0;
      line-height: 100%;
      outline: none;
      text-decoration: none;
    }

    table {
      border-collapse: collapse !important;
    }

    td, th {
      text-align: left;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #464646;
      line-height:1.5em;
    }

    b a,
    .footer a {
      text-decoration: none;
      color: #464646;
    }

    a.blue-link {
      color: blue;
      text-decoration: underline;
    }

    /* ----- General ----- */

    td.center {
      text-align: center;
    }

    .left {
      text-align: left;
    }

    .body-padding {
      padding: 24px 40px 40px;
    }

    .border-bottom {
      border-bottom: 1px solid #D8D8D8;
    }

    table.full-width-gmail-android {
      width: 100% !important;
    }


    /* ----- Header ----- */
    .header {
      font-weight: bold;
      font-size: 16px;
      line-height: 16px;
      height: 16px;
      padding-top: 19px;
      padding-bottom: 7px;
    }

    .header a {
      color: #464646;
      text-decoration: none;
    }

    /* ----- Footer ----- */

    .footer a {
      font-size: 12px;
    }
  </style>

  <style type='text/css' media='only screen and (max-width: 650px)'>
    @media only screen and (max-width: 650px) {
      * {
        font-size: 16px !important;
      }

      table[class*='w320'] {
        width: 320px !important;
      }

      td[class='mobile-center'],
      div[class='mobile-center'] {
        text-align: center !important;
      }

      td[class*='body-padding'] {
        padding: 20px !important;
      }

      td[class='mobile'] {
        text-align: right;
        vertical-align: top;
      }
    }
  </style>

</head>
<body style='padding:0; margin:0; display:block; background:#ffffff; -webkit-text-size-adjust:none'>
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr>
 <td valign='top' align='left' width='100%' style='background:repeat-x url(https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2) #f9f8f8;'>
 <center>

   <table class='w320 full-width-gmail-android' bgcolor='#f9f8f8' background='https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2' style='background-color:transparent' cellpadding='0' cellspacing='0' border='0' width='100%'>
      <tr>
        <td width='100%' height='48' valign='top'>
            <!--[if gte mso 9]>
            <v:rect xmlns:v='urn:schemas-microsoft-com:vml' fill='true' stroke='false' style='mso-width-percent:1000;height:49px;'>
              <v:fill type='tile' src='https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2' color='#ffffff' />
              <v:textbox inset='0,0,0,0'>
            <![endif]-->
              <table class='full-width-gmail-android' cellspacing='0' cellpadding='0' border='0' width='100%'>
                <tr>
                  <td class='header center' width='100%'>
                    <a href='#'>
                      Hệ thống quản lý lớp chuyên ngành theo học chế tín chỉ của Trường DHSPKTVL
                    </a>
                  </td>
                </tr>
              </table>
            <!--[if gte mso 9]>
              </v:textbox>
            </v:rect>
            <![endif]-->
        </td>
      </tr>
    </table>

    <table cellspacing='0' cellpadding='0' width='100%' bgcolor='#ffffff'>
      <tr>
        <td align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500'>
              <tr>
                <td class='body-padding mobile-padding'>

                <table cellpadding='0' cellspacing='0' width='100%'>
                  <tr>
                    <td style='text-align:center; font-size:30px; padding-bottom:20px;'>
                      Quyền hạn của bạn đã được thay đổi!
                    </td>
                  </tr>
                  <tr>
                    <td style='padding-bottom:20px;'>
                      Xin chào {0}, <br>
                      <br>
                     Admin đã thay đổi quyền hạn của bạn thành {1}.<br>
                      <br>
                    </td>
                  </tr>
                </table>

                <table cellspacing='0' cellpadding='0' width='100%'>
                  <tr>
                    <td class='left' style='padding-bottom:20px; text-align:left;'>
                      <b>Lưu ý:</b> Thư này được gửi từ địa chỉ email chỉ để thông báo và không chấp nhận email đến. Vui lòng không trả lời thư này.!

                    </td>
                  </tr>
                </table>

           

           

                <table cellspacing='0' cellpadding='0' width='100%'>
                  <tr>
                    <td class='left' style='text-align:left;'>
                      Thanks so much,
                    </td>
                  </tr>
                  <tr>
                    <td class='left' width='129' height='20' style='padding-top:10px; text-align:left;'>
                      <img class='left' width='129' height='20' src='https://www.filepicker.io/api/file/2R9HpqboTPaB4NyF35xt' alt='Company Name'>
                    </td>
                  </tr>
                </table>

                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
    </table>

    <table class='w320' bgcolor='#E5E5E5' cellpadding='0' cellspacing='0' border='0' width='100%'>
      <tr>
        <td style='border-top:1px solid #B3B3B3;' align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500' bgcolor='#E5E5E5'>
              <tr>
                <td>
                  <table cellpadding='0' cellspacing='0' width='100%' bgcolor='#E5E5E5'>
                    <tr>
                      <td class='center' style='padding:25px; text-align:center;'>
                        <b><a href='#'>Get in touch</a></b> if you have any questions or feedback
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
      <tr>
        <td style='border-top:1px solid #B3B3B3; border-bottom:1px solid #B3B3B3;' align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500' bgcolor='#E5E5E5'>
              <tr>
                <td align='center' style='padding:25px; text-align:center'>
                  <table cellspacing='0' cellpadding='0' width='100%' bgcolor='#E5E5E5'>
                    <tr>
                      <td class='center footer' style='font-size:12px;'>
                        <a href='#'>Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <span class='footer-group'>
                          <a href='#'>Facebook</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                          <a href='#'>Twitter</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                          <a href='#'>Support</a>
                        </span>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
    </table>

  </center>
  </td>
</tr>
</table>
</body>
</html>";
                a = a.Replace("{0}", dr["HOTEN"].ToString());
                a = a.Replace("{1}", dr["CHUCVU"].ToString());

                mail.GuiEmail(txtemail.Text, "Cập nhật quyền hạn", a);
                MessageBox.Show("Đã gửi mail thông báo");
            }
        }
Ejemplo n.º 2
0
        public void guiMail()
        {
            Connection cn = new Connection();

            cn.OpenConn();

            string         query = @"select CANBO.MACB, HOTEN, EMAIL, THOIGIANBD, THOIGIANKT, MALOP from COVAN,CANBO 
                                where COVAN.MACB = CANBO.MACB and THOIGIANKT < GETDATE() AND DAGOIMAIL = 0";
            SqlCommand     cmd   = new SqlCommand(query, cn.con);
            SqlDataAdapter da    = new SqlDataAdapter(cmd);
            DataSet        ds    = new DataSet();

            da.Fill(ds);
            DataTable dt = ds.Tables[0];

            // Gửi mail
            Email email = new Email();

            foreach (DataRow dr in dt.Rows)
            {
                string b = @"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  <meta name='viewport' content='width=320, initial-scale=1' />
  <title>Airmail Invoice</title>
  <style type='text/css'>

    /* ----- Client Fixes ----- */

    /* Force Outlook to provide a 'view in browser' message */
    #outlook a {
      padding: 0;
    }

    /* Force Hotmail to display emails at full width */
    .ReadMsgBody {
      width: 100%;
    }

    .ExternalClass {
      width: 100%;
    }

    /* Force Hotmail to display normal line spacing */
    .ExternalClass,
    .ExternalClass p,
    .ExternalClass span,
    .ExternalClass font,
    .ExternalClass td,
    .ExternalClass div {
      line-height: 100%;
    }


     /* Prevent WebKit and Windows mobile changing default text sizes */
    body, table, td, p, a, li, blockquote {
      -webkit-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
    }

    /* Remove spacing between tables in Outlook 2007 and up */
    table, td {
      mso-table-lspace: 0pt;
      mso-table-rspace: 0pt;
    }

    /* Allow smoother rendering of resized image in Internet Explorer */
    img {
      -ms-interpolation-mode: bicubic;
    }

     /* ----- Reset ----- */

    html,
    body,
    .body-wrap,
    .body-wrap-cell {
      margin: 0;
      padding: 0;
      background: #ffffff;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #464646;
      text-align: left;
    }

    img {
      border: 0;
      line-height: 100%;
      outline: none;
      text-decoration: none;
    }

    table {
      border-collapse: collapse !important;
    }

    td, th {
      text-align: left;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #464646;
      line-height:1.5em;
    }

    b a,
    .footer a {
      text-decoration: none;
      color: #464646;
    }

    a.blue-link {
      color: blue;
      text-decoration: underline;
    }

    /* ----- General ----- */

    td.center {
      text-align: center;
    }

    .left {
      text-align: left;
    }

    .body-padding {
      padding: 24px 40px 40px;
    }

    .border-bottom {
      border-bottom: 1px solid #D8D8D8;
    }

    table.full-width-gmail-android {
      width: 100% !important;
    }


    /* ----- Header ----- */
    .header {
      font-weight: bold;
      font-size: 16px;
      line-height: 16px;
      height: 16px;
      padding-top: 19px;
      padding-bottom: 7px;
    }

    .header a {
      color: #464646;
      text-decoration: none;
    }

    /* ----- Footer ----- */

    .footer a {
      font-size: 12px;
    }
  </style>

  <style type='text/css' media='only screen and (max-width: 650px)'>
    @media only screen and (max-width: 650px) {
      * {
        font-size: 16px !important;
      }

      table[class*='w320'] {
        width: 320px !important;
      }

      td[class='mobile-center'],
      div[class='mobile-center'] {
        text-align: center !important;
      }

      td[class*='body-padding'] {
        padding: 20px !important;
      }

      td[class='mobile'] {
        text-align: right;
        vertical-align: top;
      }
    }
  </style>

</head>
<body style='padding:0; margin:0; display:block; background:#ffffff; -webkit-text-size-adjust:none'>
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr>
 <td valign='top' align='left' width='100%' style='background:repeat-x url(https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2) #f9f8f8;'>
 <center>

   <table class='w320 full-width-gmail-android' bgcolor='#f9f8f8' background='https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2' style='background-color:transparent' cellpadding='0' cellspacing='0' border='0' width='100%'>
      <tr>
        <td width='100%' height='48' valign='top'>
            <!--[if gte mso 9]>
            <v:rect xmlns:v='urn:schemas-microsoft-com:vml' fill='true' stroke='false' style='mso-width-percent:1000;height:49px;'>
              <v:fill type='tile' src='https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2' color='#ffffff' />
              <v:textbox inset='0,0,0,0'>
            <![endif]-->
              <table class='full-width-gmail-android' cellspacing='0' cellpadding='0' border='0' width='100%'>
                <tr>
                  <td class='header center' width='100%'>
                    <a href='#'>
                      Hệ thống quản lý lớp chuyên ngành theo học chế tín chỉ của Trường DHSPKTVL
                    </a>
                  </td>
                </tr>
              </table>
            <!--[if gte mso 9]>
              </v:textbox>
            </v:rect>
            <![endif]-->
        </td>
      </tr>
    </table>

    <table cellspacing='0' cellpadding='0' width='100%' bgcolor='#ffffff'>
      <tr>
        <td align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500'>
              <tr>
                <td class='body-padding mobile-padding'>

                <table cellspacing='0' cellpadding='0' width='100%'>
                  <tr>
                    <td class='left' style='padding-bottom:40px; text-align:left;'>
                    Hi {0},<br>
                    Lớp học phần của bạn phụ trách đã kết thúc:
                    </td>
                  </tr>
                </table>

                <table border='1' cellspacing='1' cellpadding='0' width='100%'>
                  <tr>
                    <td>
                      <b>Mã lớp</b>
                    </td>
                    <td>
                      <b>Thời gian</b>
                    </td>
                    <td>
                      <b>Trạng thái</b>
                    </td>
                  </tr>
                  <tr>
                    <td class='border-bottom' height='5'></td>
                    <td class='border-bottom' height='5'></td>
                    <td class='border-bottom' height='5'></td>
                  </tr>
                  <tr>
                    <td style='padding-top:5px;'>
                      {1}
                    </td>
                    <td style='padding-top:5px;'>
                      {2} - {3}
                    </td>
                    <td style='padding-top:5px;' class='mobile'>
                      Kết thúc
                    </td>
                  </tr>
                </table>

                <table cellspacing='0' cellpadding='0' width='100%'>
                  <tr>
                    <td class='left' style='text-align:left;'>
                      Thanks so much,
                    </td>
                  </tr>
                  <tr>
                    <td class='left' width='129' height='20' style='padding-top:10px; text-align:left;'>
                      <img class='left' width='129' height='20' src='https://www.filepicker.io/api/file/2R9HpqboTPaB4NyF35xt' alt='Company Name'>
                    </td>
                  </tr>
                </table>

                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
    </table>

    <table class='w320' bgcolor='#E5E5E5' cellpadding='0' cellspacing='0' border='0' width='100%'>
      <tr>
        <td style='border-top:1px solid #B3B3B3;' align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500' bgcolor='#E5E5E5'>
              <tr>
                <td>
                  <table cellpadding='0' cellspacing='0' width='100%' bgcolor='#E5E5E5'>
                    <tr>
                      <td class='center' style='padding:25px; text-align:center;'>
                        <b><a href='#'>Get in touch</a></b> if you have any questions or feedback
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
      <tr>
        <td style='border-top:1px solid #B3B3B3; border-bottom:1px solid #B3B3B3;' align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500' bgcolor='#E5E5E5'>
              <tr>
                <td align='center' style='padding:25px; text-align:center'>
                  <table cellspacing='0' cellpadding='0' width='100%' bgcolor='#E5E5E5'>
                    <tr>
                      <td class='center footer' style='font-size:12px;'>
                        <a href='#'>Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <span class='footer-group'>
                          <a href='#'>Facebook</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                          <a href='#'>Twitter</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                          <a href='#'>Support</a>
                        </span>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
    </table>

  </center>
  </td>
</tr>
</table>
</body>
</html>";
                b = b.Replace("{0}", dr["HOTEN"].ToString());
                b = b.Replace("{1}", dr["MALOP"].ToString());
                b = b.Replace("{2}", dr["THOIGIANBD"].ToString());
                b = b.Replace("{3}", dr["THOIGIANKT"].ToString());


                email.GuiEmail(dr["EMAIL"].ToString(), "Lớp học phần hết hạn", b);

                // Cập nhật trang thái
                query = String.Format(@"UPDATE COVAN set DAGOIMAIL = 1 WHERE MACB = '{0}'", dr["MACB"].ToString());
                cmd   = new SqlCommand(query, cn.con);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                cn.CloseConn();

                //MessageBox.Show("Đã gởi email thông báo");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Connection cn = new Connection();

            cn.OpenConn();
            cm = new SqlCommand("select MACB from CANBO where MACB='" + textBox1.Text + "' ", cn.con);
            string ma = cm.ExecuteScalar() as string;

            if (textBox1.Text != ma)
            {
                MessageBox.Show("Tên đăng nhập này không tồn tại!");
            }
            else
            {
                string query = "SELECT EMAIL, MACB, HOTEN FROM CANBO WHERE MACB = '" + textBox1.Text.Trim() + "'";

                //Connection cn = new Connection();
                cn.OpenConn();

                SqlCommand     cmd = new SqlCommand(query, cn.con);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                DataSet        ds  = new DataSet();
                da.Fill(ds);
                DataTable dt = ds.Tables[0];

                string a = CreatePassword(10);

                // Gửi mail
                Email email = new Email();
                foreach (DataRow dr in dt.Rows)
                {
                    string b = @"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  <meta name='viewport' content='width=320, initial-scale=1' />
  <title>Airmail Invitation</title>
  <style type='text/css'>

    /* ----- Client Fixes ----- */

    /* Force Outlook to provide a 'view in browser' message */
    #outlook a {
      padding: 0;
    }

    /* Force Hotmail to display emails at full width */
    .ReadMsgBody {
      width: 100%;
    }

    .ExternalClass {
      width: 100%;
    }

    /* Force Hotmail to display normal line spacing */
    .ExternalClass,
    .ExternalClass p,
    .ExternalClass span,
    .ExternalClass font,
    .ExternalClass td,
    .ExternalClass div {
      line-height: 100%;
    }


     /* Prevent WebKit and Windows mobile changing default text sizes */
    body, table, td, p, a, li, blockquote {
      -webkit-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
    }

    /* Remove spacing between tables in Outlook 2007 and up */
    table, td {
      mso-table-lspace: 0pt;
      mso-table-rspace: 0pt;
    }

    /* Allow smoother rendering of resized image in Internet Explorer */
    img {
      -ms-interpolation-mode: bicubic;
    }

     /* ----- Reset ----- */

    html,
    body,
    .body-wrap,
    .body-wrap-cell {
      margin: 0;
      padding: 0;
      background: #ffffff;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #464646;
      text-align: left;
    }

    img {
      border: 0;
      line-height: 100%;
      outline: none;
      text-decoration: none;
    }

    table {
      border-collapse: collapse !important;
    }

    td, th {
      text-align: left;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #464646;
      line-height:1.5em;
    }

    b a,
    .footer a {
      text-decoration: none;
      color: #464646;
    }

    a.blue-link {
      color: blue;
      text-decoration: underline;
    }

    /* ----- General ----- */

    td.center {
      text-align: center;
    }

    .left {
      text-align: left;
    }

    .body-padding {
      padding: 24px 40px 40px;
    }

    .border-bottom {
      border-bottom: 1px solid #D8D8D8;
    }

    table.full-width-gmail-android {
      width: 100% !important;
    }


    /* ----- Header ----- */
    .header {
      font-weight: bold;
      font-size: 16px;
      line-height: 16px;
      height: 16px;
      padding-top: 19px;
      padding-bottom: 7px;
    }

    .header a {
      color: #464646;
      text-decoration: none;
    }

    /* ----- Body ----- */

    .body .body-padded {
      padding-top: 34px;
    }

    .body-thanks-cell {
      padding: 25px 0 10px;
    }

    .body-signature-cell {
      padding: 0 0 30px;
    }

    /* ----- Footer ----- */

    .footer a {
      font-size: 12px;
    }


    /* ----- Soapbox ----- */

    .soapbox .soapbox-title {
      text-align: center;
      font-size: 30px;
      padding-bottom: 20px;
      color: #464646;
    }

    /* ----- Status ----- */

    .status {
      border-collapse: collapse;
      margin-left: 15px;
      color: #656565;
    }

    .status .status-cell {
      border: 1px solid #b3b3b3;
      height: 50px;
      text-align: center;
      font-size: 15px;
      padding: 0 40px;
    }

    .status .status-cell.success,
    .status .status-cell.active {
      height: 65px;
    }

    .status .status-cell.success {
      background: #f2ffeb;
      color: #51da42;
    }

    .status .status-cell.active {
      background: #fffde0;
      width: 135px;
    }

    .status .status-title {
      font-size: 16px;
      font-weight: bold;
      line-height: 23px;
    }

    .status .status-image {
      vertical-align: text-bottom;
    }
  </style>

  <style type='text/css' media='only screen'>
    @media only screen and (max-width: 505px) {

      *[class*='w320'] {
        width: 320px !important;
      }

      table[class='status'] td[class*='status-cell'],
      table[class='status'] td[class*='status-cell'].active {
        display: block !important;
        width: auto !important;
      }

      table[class='status-container single'] table[class='status'] {
        width: 270px !important;
        margin-left: 0;
      }

      table[class='status'] td[class*='status-cell'],
      table[class='status'] td[class*='status-cell'].active,
      table[class='status'] td[class*='status-cell'] [class*='status-title'] {
        line-height: 65px !important;
        font-size: 18px !important;
        padding: 0 15px !important;
      }

      table[class='status-container single'] table[class='status'] td[class*='status-cell'],
      table[class='status-container single'] table[class='status'] td[class*='status-cell'].active,
      table[class='status-container single'] table[class='status'] td[class*='status-cell'] [class*='status-title'] {
        line-height: 51px !important;
      }

      table[class='status'] td[class*='status-cell'].active [class*='status-title'] {
        display: inline !important;
      }

    }
  </style>

  <style type='text/css' media='only screen and (max-width: 650px)'>
    @media only screen and (max-width: 650px) {
      * {
        font-size: 16px !important;
      }

      table[class*='w320'] {
        width: 320px !important;
      }

      td[class='mobile-center'],
      div[class='mobile-center'] {
        text-align: center !important;
      }

      td[class*='body-padding'] {
        padding: 20px !important;
      }

      td[class='mobile'] {
        text-align: right;
        vertical-align: top;
      }
    }
  </style>

</head>
<body style='padding:0; margin:0; display:block; background:#ffffff; -webkit-text-size-adjust:none'>
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr>
 <td valign='top' align='left' width='100%' style='background:repeat-x url(https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2) #f9f8f8;'>
 <center>

   <table class='w320 full-width-gmail-android' bgcolor='#f9f8f8' background='https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2' style='background-color:transparent' cellpadding='0' cellspacing='0' border='0' width='100%'>
      <tr>
        <td width='100%' height='48' valign='top'>
            <!--[if gte mso 9]>
            <v:rect xmlns:v='urn:schemas-microsoft-com:vml' fill='true' stroke='false' style='mso-width-percent:1000;height:49px;'>
              <v:fill type='tile' src='https://www.filepicker.io/api/file/al80sTOMSEi5bKdmCgp2' color='#ffffff' />
              <v:textbox inset='0,0,0,0'>
            <![endif]-->
              <table class='full-width-gmail-android' cellspacing='0' cellpadding='0' border='0' width='100%'>
                <tr>
                  <td class='header center' width='100%'>
                    <a href='#'>
                      Hệ thống quản lý lớp chuyên ngành theo học chế tín chỉ của Trường DHSPKTVL
                    </a>
                  </td>
                </tr>
              </table>
            <!--[if gte mso 9]>
              </v:textbox>
            </v:rect>
            <![endif]-->
        </td>
      </tr>
    </table>

    <table cellspacing='0' cellpadding='0' width='100%' bgcolor='#ffffff'>
      <tr>
        <td align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500'>
              <tr>
                <td class='body-padding mobile-padding'>

                <table class='soapbox' cellpadding='0' cellspacing='0' width='100%'>
                  <tr>
                    <td class='soapbox-title'>
                      Vui lòng đăng nhập lại với mật khẩu mới được cấp bên dưới
                    </td>
                  </tr>
                </table>

                <table class='status-container single' cellpadding='0' cellspacing='0' width='100%'>
                  <tr>
                    <td>
                      <center>
                        <table class='status' bgcolor='#fffeea' cellspacing='0'>
                          <tr>
                            <td class='status-cell'>
                              MẬT KHẨU MỚI: <b>{1}</b>
                            </td>
                          </tr>
                        </table>
                      </center>
                    </td>
                  </tr>
                </table>



                <table class='body'>
                  <tr>
                    <td class='body-padded'>
                      <table class='body-text'>
                        <tr>
                          <td style='vertical-align:middle; padding-bottom:10px; padding-right:20px'>
                            <table cellspacing='0' cellpadding='0' width='100%'>
                              <tr>
                                <td>
                                  <table cellpadding='0' cellspacing='0'>
                                    <tr>
                                      <td width='80' height='80' style='text-align:left;border: 1px solid #888888;'>
                                        <a href=''><img style='display:block' width='80' height='80' src='https://www.filepicker.io/api/file/OqRXT4JuRbmXSgbxccgK'></a>
                                      </td>
                                    </tr>
                                  </table>
                                </td>
                              </tr>
                              <tr>
                                <td style='font-size:12px; padding-top:5px; text-align:left;'>
                                  User: <a style='color:blue;' href=''>{0}</a>
                                </td>
                              </tr>
                            </table>
                          </td>
                          <td class='body-text-cell' width='300' style='padding-bottom:4px;'>
                            <b>Hi {0},</b><br>
                            <br>
                            Hệ thống đã tạo mật khẩu mới cho bạn, vui lòng sử dụng mật khẩu đã cấp sau đó hãy thay đổi mật khẩu bạn mong muốn!<br>
                          </td>
                        </tr>
                      </table>
                      <table class='body-text' cellspacing='0' cellpadding='0' width='100%'>
                        <tr>
                          <td class='body-text-cell' style='text-align:left; padding-bottom:30px;' >
                            Thư này được gửi từ địa chỉ email chỉ để thông báo và không chấp nhận email đến. Vui lòng không trả lời thư này.!
                          </td>
                        </tr>
                      </table>

                   
                      <table class='body-signature-block'>
                        <tr>
                          <td class='body-thanks-cell'>
                            Thanks so much,
                          </td>
                        </tr>
                        <tr>
                          <td class='body-signature-cell'>
                            <img src='https://www.filepicker.io/api/file/2R9HpqboTPaB4NyF35xt' alt='Company Name'>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>



                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
    </table>

    <table class='w320' bgcolor='#E5E5E5' cellpadding='0' cellspacing='0' border='0' width='100%'>
      <tr>
        <td style='border-top:1px solid #B3B3B3;' align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500' bgcolor='#E5E5E5'>
              <tr>
                <td>
                  <table cellpadding='0' cellspacing='0' width='100%' bgcolor='#E5E5E5'>
                    <tr>
                      <td class='center' style='padding:25px; text-align:center;'>
                        <b><a href='#'>Get in touch</a></b> if you have any questions or feedback
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
      <tr>
        <td style='border-top:1px solid #B3B3B3; border-bottom:1px solid #B3B3B3;' align='center'>
          <center>
            <table class='w320' cellspacing='0' cellpadding='0' width='500' bgcolor='#E5E5E5'>
              <tr>
                <td align='center' style='padding:25px; text-align:center'>
                  <table cellspacing='0' cellpadding='0' width='100%' bgcolor='#E5E5E5'>
                    <tr>
                      <td class='center footer' style='font-size:12px;'>
                        <a href='#'>Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <span class='footer-group'>
                          <a href='#'>Facebook</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                          <a href='#'>Twitter</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                          <a href='#'>Support</a>
                        </span>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </center>
        </td>
      </tr>
    </table>

  </center>
  </td>
</tr>
</table>
</body>
</html>";
                    b = b.Replace("{0}", dr["HOTEN"].ToString());

                    b = b.Replace("{1}", a);


                    email.GuiEmail(dr["EMAIL"].ToString(), "Mật khẩu mới", b);

                    // Cập nhật trang thái
                    query = String.Format(@"UPDATE CANBO set MATKHAU = '{0}' WHERE MACB = '{1}'", a, dr["MACB"].ToString());
                    cmd   = new SqlCommand(query, cn.con);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                    cn.CloseConn();

                    MessageBox.Show("Mật khẩu mới đã được cấp vui lòng check mail của bạn");
                }
            }
        }