Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MailDB Db = new MailDB();

            switch (Db.authUser(textBox1.Text, textBox2.Text))
            {
            case User.NoUser:

                MessageBox.Show("Ошибка доступа.");
                break;

            case User.Admin:
                MainForm mainForm = new MainForm(1);
                this.Hide();
                mainForm.Owner = this;
                mainForm.Show();
                break;

            case User.Operator:
                MainForm mainForm1 = new MainForm();
                this.Hide();
                mainForm1.Owner = this;
                mainForm1.Show();
                break;

            case User.User:
                Db.logAuthuser(textBox1.Text);
                UserForm userForm = new UserForm(textBox1.Text);
                userForm.Owner = this;
                this.Hide();
                userForm.Show();
                break;
            }
        }
Ejemplo n.º 2
0
        protected void dtgMail_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "editrow")
            {
                try
                {
                    int id = ConvertUtility.ToInt32(e.Item.Cells[0].Text);

                    MailInfo info      = MailDB.GetInfo(id);
                    CheckBox chkAnswer = (CheckBox)e.Item.FindControl("chkAnswer");

                    info.Mail_Answer = ConvertUtility.ToBoolean(chkAnswer.Checked);

                    MailDB.Update(info);
                    lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS;
                }
                catch (Exception ex)
                {
                    lblUpdateStatus.Text = ex.ToString();
                }
            }
            if (e.CommandName == "delete")
            {
                int id = ConvertUtility.ToInt32(e.Item.Cells[0].Text);
                try
                {
                    MailDB.Delete(id);
                    lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS;
                }
                catch
                {
                    lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR;
                }
            }
        }
Ejemplo n.º 3
0
 private void UserForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (MessageBox.Show(this, "Завершить работу?", "Выход.", MessageBoxButtons.OKCancel) != DialogResult.OK)
     {
         e.Cancel = true;
     }
     else
     {
         var db = new MailDB();
         db.logautUser(loginUser);
         this.Owner.Show();
     }
 }
Ejemplo n.º 4
0
 protected void butDellChecked_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (DataGridItem item in dtgMail.Items)
         {
             CheckBox chkSelect = (CheckBox)item.FindControl("chkSelect");
             if (chkSelect.Checked)
             {
                 int id = ConvertUtility.ToInt32(item.Cells[0].Text);
                 MailDB.Delete(id);
             }
         }
         lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS;
     }
     catch
     {
         lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; //ex.ToString();
     }
 }
Ejemplo n.º 5
0
 protected void butDelAll_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (DataGridItem item in dtgMail.Items)
         {
             //					CheckBox chkSelect = (CheckBox)item.FindControl("chkSelect");
             //					if(chkSelect.Checked)
             //					{
             int      id        = ConvertUtility.ToInt32(item.Cells[0].Text);
             MailInfo info      = MailDB.GetInfo(id);
             CheckBox chkAnswer = (CheckBox)item.FindControl("chkAnswer");
             info.Mail_Answer = ConvertUtility.ToBoolean(chkAnswer.Checked);
             MailDB.Update(info);
             //					}
         }
         lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS;
     }
     catch
     {
         lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; //ex.ToString();
     }
 }
Ejemplo n.º 6
0
        protected void butSend_Click(object sender, EventArgs e)
        {
            var contactEmail = AppEnv.ContactEmail;

            if (txtName.Text.Trim().Length == 0 || txtEmail.Text.Trim().Length == 0 || txtContent.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải điền tất cả các ô có dấu (*)");
                return;
            }
            //if(txtCode.Text.Trim() != FormShield1.GetText())
            //{
            //    MessageBox.Show("Bạn nhập không đúng mã bảo vệ");
            //    return;
            //}

            const string matchEmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
                                             + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
				[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
                                             + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
				[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
                                             + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

            if (Regex.IsMatch(txtEmail.Text.Trim(), matchEmailPattern) == false)
            {
                MessageBox.Show("Email không đúng !!!");
                return;
            }

            var sb = new StringBuilder();

            sb.Append("<b>Ho ten</b>: ");
            sb.Append(txtName.Text);
            sb.Append("<br><b>Email</b>: ");
            sb.Append(txtEmail.Text);
            sb.Append("<br><b>Dien thoai</b>:<br>");
            sb.Append(txtPhone.Text);
            sb.Append("<br><b>Gioi tinh</b>:<br>");
            sb.Append(rdolGender.SelectedValue);
            sb.Append("<br><b>Tieu de</b>:<br>");
            sb.Append(txtSubject.Text);
            sb.Append("<br><b>Content</b>:<br>");
            sb.Append(txtContent.Text);


            // new email solution start
            var email = new MailMessage(txtEmail.Text, contactEmail)
            {
                Subject    = "Lien he tu khach hang ghe tham website",
                IsBodyHtml = true,
                Body       = sb.ToString()
            };

            var smtp = new SmtpClient
            {
                Host = AppEnv.MailServer.Length == 0 ? "localhost" : AppEnv.MailServer,
                Port =
                    AppEnv.MailServerPort.Length == 0 ? 25 : ConvertUtility.ToInt32(AppEnv.MailServerPort)
            };



            // if authentication
            if (AppEnv.MailUsername.Length > 0 && AppEnv.MailPassword.Length > 0)
            {
                smtp.Credentials    = new NetworkCredential(AppEnv.MailUsername, AppEnv.MailPassword);
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            }
            // if authentication end

            var info = new MailInfo
            {
                Mail_Kind     = "lienhe",
                Mail_Name     = HTMLUtility.SecureHTML(txtName.Text),
                Mail_Email    = HTMLUtility.SecureHTML(txtEmail.Text),
                Mail_Phone    = HTMLUtility.SecureHTML(txtPhone.Text),
                Mail_Address  = "",
                Mail_Content  = HTMLUtility.SecureHTML(txtContent.Text),
                Pix_ID        = 0,
                Mail_Answer   = ConvertUtility.ToBoolean(false),
                Mail_Datetime = DateTime.Now
            };

            MailDB.Insert(info);

            try
            {
                smtp.Send(email);
                notice.InnerHtml = "<br><br><br><font color=red><b>Email đã được gửi tới " + contactEmail + "...</b></font>";
            }
            catch (Exception ex)
            {
                notice.InnerHtml = "<br><br><br><font color=red><b>Email đã được gửi đi... Xin chân thành cảm ơn.</b></font>";
                ErrorReportDB.NewReport(Request.RawUrl, ex.ToString());
                //notice.InnerHtml = "<br><br><br><font color=red><b>Lỗi trong quá trình gửi mail...</b></font><br>" + ex.Message;
            }
            finally
            {
                pnform.Visible = false;
                notice.Visible = true;
            }
        }
        protected void GetMailInfo()
        {
            List<MailDetail> MDList = new List<MailDetail>();
            MDList = new MailDB().SelectUnread(Session["userID"].ToString());
            if (MDList.Count == 0)  //没有邮件
            {
                uclNewMail.TitleImg = "";
                uclNewMail.PubTitleList = "&nbsp;&nbsp;&nbsp;&nbsp;<img src='/Images/loginf.gif' class='InfoList_img' />您暂时没有新邮件.";
                uclNewMail.PubURLList = "";
                uclNewMail.PubTimeList = "";
            }
            else //有新的邮件
            {
                for (int i = 0; i < MDList.Count; i++)
                {
                    if (i < MDList.Count - 1)
                    {
                        uclNewMail.PubTitleList += MDList[i].MailTitle + "★";
                        uclNewMail.PubTimeList += this.TimeType(MDList[i].OperationTime) + "★";
                        uclNewMail.PubURLList += "/Projects/ZJGEportEmail/Pages/InnerMail/ReadMail.aspx?MailGuid=" + MDList[i].MailGuid + "&RcvInfoGuid=" + MDList[i].RcvInfoGuid + "★";
                    }
                    else
                    {
                        uclNewMail.PubTitleList += MDList[i].MailTitle;
                        uclNewMail.PubTimeList += this.TimeType(MDList[i].OperationTime);
                        uclNewMail.PubURLList += "/Projects/ZJGEportEmail/Pages/InnerMail/ReadMail.aspx?MailGuid=" + MDList[i].MailGuid + "&RcvInfoGuid=" + MDList[i].RcvInfoGuid;
                    }

                }
            }
        }
Ejemplo n.º 8
0
 private void LoadComboBoxData()
 {
     MailDB          mail = new MailDB();
     List <Services> list = mail.LoadListService();
 }
Ejemplo n.º 9
0
        protected void butSend_Click(object sender, EventArgs e)
        {
            var contactEmail = AppEnv.ContactEmail;

            var hocsinhname     = txtHocsinhName.Text.Trim();
            var phuhuynhname    = txtPhuHuynh.Text.Trim();
            var emailregister   = txtEmail.Text.Trim();
            var phoneregister   = txtPhone.Text.Trim();
            var addressregister = txtAddress.Text.Trim();
            var noteregister    = txtContent.Text;


            if (hocsinhname.Length == 0 || phuhuynhname.Length == 0 || emailregister.Length == 0 || phoneregister.Length == 0 || addressregister.Length == 0)
            {
                MessageBox.Show("Bạn phải điền tất cả các ô có dấu (*)");
                return;
            }
            //if(txtCode.Text.Trim() != FormShield1.GetText())
            //{
            //    MessageBox.Show("Bạn nhập không đúng mã bảo vệ");
            //    return;
            //}

            const string matchEmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
                                             + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
				[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
                                             + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
				[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
                                             + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

            if (Regex.IsMatch(txtEmail.Text.Trim(), matchEmailPattern) == false)
            {
                MessageBox.Show("Email không đúng !!!");
                return;
            }

            //insert db
            var hocsinhinfo = new HocsinhInfo();

            hocsinhinfo.Hocsinh_Name     = hocsinhname;
            hocsinhinfo.Hocsinh_Parent   = phuhuynhname;
            hocsinhinfo.Hocsinh_Email    = emailregister;
            hocsinhinfo.Hocsinh_Tel      = phoneregister;
            hocsinhinfo.Hocsinh_Address  = addressregister;
            hocsinhinfo.Hocsinh_Birthday = dropDay.SelectedValue + "/" + dropMonth.SelectedValue + "/" +
                                           dropYear.SelectedValue;
            hocsinhinfo.Hocsinh_Note       = noteregister;
            hocsinhinfo.Hocsinh_CreateDate = DateTime.Now;
            hocsinhinfo.Hocsinh_IsLearning = true;

            int hocsinhId = HocsinhDB.Insert(hocsinhinfo);

            var i = 0;

            foreach (DataGridItem item in dtgClass.Items)
            {
                var chkSelect = (CheckBox)item.FindControl("chkSelect");
                if (chkSelect.Checked)
                {
                    var id = ConvertUtility.ToInt32(item.Cells[0].Text);

                    var registerInfo = new HocsinhRegisterInfo();
                    registerInfo.Hocsinh_ID   = hocsinhId;
                    registerInfo.Content_ID   = id;
                    registerInfo.RegisterTime = DateTime.Now;

                    HocsinhRegisterDB.Insert(registerInfo);

                    i = 1 + 1;
                }
            }

            //noi dung mail

            var contentmail = string.Empty;

            if (i == 0)
            {
                contentmail  = "Dang ky cho lop khai giang";
                contentmail += "<br /><br />" + noteregister;
            }
            else
            {
                contentmail = noteregister;
            }

            var sb = new StringBuilder();

            sb.Append("<b>Ho ten hoc sinh</b>: ");
            sb.Append(hocsinhname);
            sb.Append("<br /><b>Ten phu huynh</b>: ");
            sb.Append(phuhuynhname);
            sb.Append("<br /><b>Email</b>: ");
            sb.Append(emailregister);
            sb.Append("<br /><b>Dien thoai</b>:<br />");
            sb.Append(phoneregister);
            sb.Append("<br /><b>Dia chi</b>: ");
            sb.Append(addressregister);
            sb.Append("<br /><b>Ngay sinh</b>:<br />");
            sb.Append(dropDay.SelectedValue + "/" + dropMonth.SelectedValue + "/" + dropYear.SelectedValue);
            sb.Append("<br /><b>Thong tin them</b>:<br />");
            sb.Append(contentmail);


            // new email solution start
            var email = new MailMessage(txtEmail.Text, contactEmail)
            {
                Subject    = "Dang ky khoa hoc tu website",
                IsBodyHtml = true,
                Body       = sb.ToString()
            };

            var smtp = new SmtpClient
            {
                Host = AppEnv.MailServer.Length == 0 ? "localhost" : AppEnv.MailServer,
                Port =
                    AppEnv.MailServerPort.Length == 0 ? 25 : ConvertUtility.ToInt32(AppEnv.MailServerPort)
            };



            // if authentication
            if (AppEnv.MailUsername.Length > 0 && AppEnv.MailPassword.Length > 0)
            {
                smtp.Credentials    = new NetworkCredential(AppEnv.MailUsername, AppEnv.MailPassword);
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            }
            // if authentication end

            var info = new MailInfo
            {
                Mail_Kind     = "lienhe",
                Mail_Name     = HTMLUtility.SecureHTML(txtHocsinhName.Text),
                Mail_Email    = HTMLUtility.SecureHTML(txtEmail.Text),
                Mail_Phone    = HTMLUtility.SecureHTML(txtPhone.Text),
                Mail_Address  = HTMLUtility.SecureHTML(txtAddress.Text),
                Mail_Content  = HTMLUtility.SecureHTML(sb.ToString()),
                Pix_ID        = 0,
                Mail_Answer   = ConvertUtility.ToBoolean(false),
                Mail_Datetime = DateTime.Now
            };

            MailDB.Insert(info);

            try
            {
                smtp.Send(email);
                notice.InnerHtml = "<br><br><br><font color=red><b>Thông tin đăng ký đã được gửi tới " + contactEmail + "...<br />Chúng tôi sẽ liên hệ lại trong thời gian ngắn nhất.<br />Xin chân thành cảm ơn.</b></font>";
            }
            catch (Exception ex)
            {
                notice.InnerHtml = "<br><br><br><font color=red><b>Thông tin đăng ký đã được gửi đi...<br />Chúng tôi sẽ liên hệ lại trong thời gian ngắn nhất.<br />Xin chân thành cảm ơn.</b></font>";
                ErrorReportDB.NewReport(Request.RawUrl, ex.ToString());
                //notice.InnerHtml = "<br><br><br><font color=red><b>Lỗi trong quá trình gửi mail...</b></font><br>" + ex.Message;
            }
            finally
            {
                pnform.Visible = false;
                notice.Visible = true;
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// ��ʱ����ڲ��ʼ�
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Timer3_Tick(object sender, EventArgs e)
 {
     List<MailDetail> MDList = new List<MailDetail>();
     MDList = new MailDB().SelectUnread(Session["userID"].ToString());
     if (MDList.Count > 0)
     {
         string MailTitle = "";
         string Url = "";
         for (int i = 0; i < MDList.Count; i++)
         {
             MailTitle += "����:" + MDList[i].MailTitle + "&nbsp;&nbsp;[" + MDList[i].OperationTime.ToString("yy/MM/dd HH:mm") + "]��";
             Url += "/Projects/ZJGEportEmail/Pages/InnerMail/ReadMail.aspx?MailGuid=" + MDList[i].MailGuid + "&RcvInfoGuid=" + MDList[i].RcvInfoGuid + "��";
         }
         CallJsFun("show(250,150,'�ڲ��ʼ���ʾ��','��Ŀǰ�С�" + MDList.Count.ToString() + "�������ʼ�','" + MailTitle + "','" + Url + "')");
     }
 }