Exemplo n.º 1
0
 private void Mail_SendBtn_Click(object sender, EventArgs e)
 {
     SendMail = new Server_SendMail();
     Regex regExpireTime = new Regex("[^\\d]");
     Int64 Expiretime = new long();
     Int64 Delivertime = new long();
     int Expiretime_days = 0;
     int Expiretime_hours = 0;
     int Expiretime_minuets = 0;
     int Expiretime_seconds = 0;
     DataSet ReceiversSet = new DataSet();
     ReceiversSet.Tables.Add("Receivers");
     ReceiversSet.Tables[0].Columns.Add("AccountID", typeof(int));
     ReceiversSet.Tables[0].Columns.Add("AccountName", typeof(string));
     ReceiversSet.Tables[0].Columns.Add("CharactersID", typeof(int));
     ReceiversSet.Tables[0].Columns.Add("CharactersName", typeof(string));
     DataSet ItemsSet = new DataSet();
     ItemsSet.Tables.Add("Items");
     ItemsSet.Tables[0].Columns.Add("entry", typeof(string));
     ItemsSet.Tables[0].Columns.Add("count", typeof(int));
     if (Mail_ReceiverDataGridView.Rows.Count == 0)
     {
         toolTip1.Show("点击此标签添加收件人", this, 105, 70);
         return;
     }
     else if (Mail_TittleTextBox.Text.Trim().Length == 0)
     {
         toolTip1.Show("邮件标题不能为空", this, 50, 70);
         return;
     }
     else if (Mail_ContentTextBox.Text.Trim().Length == 0)
     {
         toolTip1.Show("邮件内容不能为空", this, 50, 70);
         return;
     }
     else if (regExpireTime.Match(ExpireTime_Days_TextBox.Text).Success || regExpireTime.Match(ExpireTime_Hours_TextBox.Text).Success || regExpireTime.Match(ExpireTime_Minuets_TextBox.Text).Success || regExpireTime.Match(ExpireTime_Seconds_TextBox.Text).Success)
     {
         toolTip1.Show("日期填写不正确", this, 130, 70);
         return;
     }
     foreach (DataGridViewRow dr in Mail_ItemDataGridView.Rows)
     {
         Regex CheckItemsCountReg = new Regex("[^0-9]");
         if (CheckItemsCountReg.Match(dr.Cells[3].Value.ToString()).Success)
         {
             toolTip1.Show("物品["+dr.Cells[1].Value.ToString()+"]的数量填写不正确,无法发送。", this, 130, 70);
             ItemsSet.Tables[0].Rows.Clear();
             return;
         }
         ItemsSet.Tables[0].Rows.Add(new object[] { dr.Cells[1].Value, dr.Cells[3].Value });
     }
     foreach (DataGridViewRow dr in Mail_ReceiverDataGridView.Rows)
     {
         ReceiversSet.Tables[0].Rows.Add(new object[] { dr.Cells[1].Value, dr.Cells[2].Value, dr.Cells[3].Value, dr.Cells[4].Value });
     }
     if (radioButton1.Checked)
     {
         TimeSpan ts = new TimeSpan();
         ts = DateTime.Now - Convert.ToDateTime("1970/01/01 0:00:00");
         Int64 expireDays = Convert.ToInt64(ExpireTime_Days_TextBox.Text);
         long expireHours = Convert.ToInt64(ExpireTime_Hours_TextBox.Text);
         long expireMinuets = Convert.ToInt64(ExpireTime_Minuets_TextBox.Text);
         long expireSeconds = Convert.ToInt64(ExpireTime_Seconds_TextBox.Text);
         Expiretime = DateTime.Now.ToFileTimeUtc() - Convert.ToDateTime("1970/01/01 0:00:00").ToFileTimeUtc() + expireDays * 3600 * 24 + expireHours * 3600 + expireMinuets * 60 + expireSeconds;
     }
     else if (radioButton2.Checked)
     {
         TimeSpan ts = new TimeSpan();
         ts = dateTimePicker1.Value - Convert.ToDateTime("1970/01/01 0:00:00");
         Expiretime = dateTimePicker1.Value.ToFileTimeUtc() - Convert.ToDateTime("1970/01/01 0:00:00").ToFileTimeUtc();
     }
     Delivertime = dateTimePicker2.Value.ToFileTimeUtc() - Convert.ToDateTime("1970/01/01 0:00:00").ToFileTimeUtc();
     SendMail.MailTittle = Mail_TittleTextBox.Text;
     SendMail.MailText = Mail_ContentTextBox.Text;
     SendMail.ExpireTime = Expiretime;
     SendMail.DeliverTime = Delivertime;
     SendMail.ReceiversSet = ReceiversSet;
     SendMail.ItemsSet = ItemsSet;
     SendMail.ShowDialog();
     SendMailResault = new Server_SendMailResault();
     SendMailResault.SendMailResault = SendMail.SendMailResault;
     SendMailResault.ResaultMsg1 = SendMail.ResaultInfo1;
     SendMailResault.ResaultMsg2 = SendMail.ResaultInfo2;
     SendMailResault.ShowDialog();
 }
Exemplo n.º 2
0
        private void Mail_SendBtn_Click(object sender, EventArgs e)
        {
            SendMail = new Server_SendMail();
            Regex   regExpireTime      = new Regex("[^\\d]");
            Int64   Expiretime         = new long();
            Int64   Delivertime        = new long();
            int     Expiretime_days    = 0;
            int     Expiretime_hours   = 0;
            int     Expiretime_minuets = 0;
            int     Expiretime_seconds = 0;
            DataSet ReceiversSet       = new DataSet();

            ReceiversSet.Tables.Add("Receivers");
            ReceiversSet.Tables[0].Columns.Add("AccountID", typeof(int));
            ReceiversSet.Tables[0].Columns.Add("AccountName", typeof(string));
            ReceiversSet.Tables[0].Columns.Add("CharactersID", typeof(int));
            ReceiversSet.Tables[0].Columns.Add("CharactersName", typeof(string));
            DataSet ItemsSet = new DataSet();

            ItemsSet.Tables.Add("Items");
            ItemsSet.Tables[0].Columns.Add("entry", typeof(string));
            ItemsSet.Tables[0].Columns.Add("count", typeof(int));
            if (Mail_ReceiverDataGridView.Rows.Count == 0)
            {
                toolTip1.Show("点击此标签添加收件人", this, 105, 70);
                return;
            }
            else if (Mail_TittleTextBox.Text.Trim().Length == 0)
            {
                toolTip1.Show("邮件标题不能为空", this, 50, 70);
                return;
            }
            else if (Mail_ContentTextBox.Text.Trim().Length == 0)
            {
                toolTip1.Show("邮件内容不能为空", this, 50, 70);
                return;
            }
            else if (regExpireTime.Match(ExpireTime_Days_TextBox.Text).Success || regExpireTime.Match(ExpireTime_Hours_TextBox.Text).Success || regExpireTime.Match(ExpireTime_Minuets_TextBox.Text).Success || regExpireTime.Match(ExpireTime_Seconds_TextBox.Text).Success)
            {
                toolTip1.Show("日期填写不正确", this, 130, 70);
                return;
            }
            foreach (DataGridViewRow dr in Mail_ItemDataGridView.Rows)
            {
                Regex CheckItemsCountReg = new Regex("[^0-9]");
                if (CheckItemsCountReg.Match(dr.Cells[3].Value.ToString()).Success)
                {
                    toolTip1.Show("物品[" + dr.Cells[1].Value.ToString() + "]的数量填写不正确,无法发送。", this, 130, 70);
                    ItemsSet.Tables[0].Rows.Clear();
                    return;
                }
                ItemsSet.Tables[0].Rows.Add(new object[] { dr.Cells[1].Value, dr.Cells[3].Value });
            }
            foreach (DataGridViewRow dr in Mail_ReceiverDataGridView.Rows)
            {
                ReceiversSet.Tables[0].Rows.Add(new object[] { dr.Cells[1].Value, dr.Cells[2].Value, dr.Cells[3].Value, dr.Cells[4].Value });
            }
            if (radioButton1.Checked)
            {
                TimeSpan ts = new TimeSpan();
                ts = DateTime.Now - Convert.ToDateTime("1970/01/01 0:00:00");
                Int64 expireDays    = Convert.ToInt64(ExpireTime_Days_TextBox.Text);
                long  expireHours   = Convert.ToInt64(ExpireTime_Hours_TextBox.Text);
                long  expireMinuets = Convert.ToInt64(ExpireTime_Minuets_TextBox.Text);
                long  expireSeconds = Convert.ToInt64(ExpireTime_Seconds_TextBox.Text);
                Expiretime = DateTime.Now.ToFileTimeUtc() - Convert.ToDateTime("1970/01/01 0:00:00").ToFileTimeUtc() + expireDays * 3600 * 24 + expireHours * 3600 + expireMinuets * 60 + expireSeconds;
            }
            else if (radioButton2.Checked)
            {
                TimeSpan ts = new TimeSpan();
                ts         = dateTimePicker1.Value - Convert.ToDateTime("1970/01/01 0:00:00");
                Expiretime = dateTimePicker1.Value.ToFileTimeUtc() - Convert.ToDateTime("1970/01/01 0:00:00").ToFileTimeUtc();
            }
            Delivertime           = dateTimePicker2.Value.ToFileTimeUtc() - Convert.ToDateTime("1970/01/01 0:00:00").ToFileTimeUtc();
            SendMail.MailTittle   = Mail_TittleTextBox.Text;
            SendMail.MailText     = Mail_ContentTextBox.Text;
            SendMail.ExpireTime   = Expiretime;
            SendMail.DeliverTime  = Delivertime;
            SendMail.ReceiversSet = ReceiversSet;
            SendMail.ItemsSet     = ItemsSet;
            SendMail.ShowDialog();
            SendMailResault = new Server_SendMailResault();
            SendMailResault.SendMailResault = SendMail.SendMailResault;
            SendMailResault.ResaultMsg1     = SendMail.ResaultInfo1;
            SendMailResault.ResaultMsg2     = SendMail.ResaultInfo2;
            SendMailResault.ShowDialog();
        }