[sourcecode language="CSharp" wraplines="false"]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CustDialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
try
{
int c = Convert.ToInt32(textBox1.Text) / Convert.ToInt32(textBox2.Text);
}
catch (Exception exa)
{
frmMessage frm = new frmMessage("Hệ thống có lỗi phát sinh, liên hệ monkey@abc.com để được giúp đỡ !", "Xác nhận", exa);
DialogResult result = frm.ShowDialog();
}
}
}
}
[/sourcecode]
[sourcecode language="CSharp" wraplines="false"]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace CustDialog
{
public partial class frmMessage : Form
{
string caption = "";
DialogResult ok = DialogResult.No;
public frmMessage(string Message, string Caption, Exception ex)
{
InitializeComponent();
label1.Text = Message;
caption = Caption;
this.Height = this.Height - 100;
this.richTextBox1.Visible = false;
this.richTextBox1.Text = ex == null ? "" : ex.ToString();
btnSend.Visible = (ex != null);
}
private void btnExp_Click(object sender, EventArgs e)
{
if (!this.richTextBox1.Visible)
{
this.richTextBox1.Visible = true;
this.Height = this.Height + 100;
this.btnExp.Text = "Thu nhỏ";
}
else
{
this.Height = this.Height - 100;
this.richTextBox1.Visible = false;
this.btnExp.Text = "Chi tiết";
}
}
private void btnSend_Click(object sender, EventArgs e)
{
this.Enabled = false;
string Sendto = "ngotuongdan01@gmail.com"; //Email Address to reciever
// tai khoan này các bạn sử đừng sử dụng để gửi tùm lum dùm tui nhe
string UserName = "ngotuongdan04@gmail.com"; //Ur Gmail address
string PassWord = "ngotuongdan"; //Gmail password
// this mail is my demo mail please not change it's password, tks alot
NetworkCredential loginInfo = new NetworkCredential(UserName, PassWord);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(UserName);
msg.To.Add(new MailAddress(Sendto.ToString()));
msg.Subject = "Error"+ DateTime.Now.ToString();
msg.Body = richTextBox1.Text;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
this.Enabled = true; ;
}
private void frmMessage_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = (ok == DialogResult.No);
}
private void button1_Click(object sender, EventArgs e)
{
ok = MessageBox.Show("Are you sure to change student information?", "Change information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
}
}
[/sourcecode]
Á e nhớ thầy rồi, thầy dạy ở trường Aptech cần thơ đúng không thầy???
ReplyDeleteđúng rồi
ReplyDeleteGiờ thầy dạy bên gì rồi thầy??? e lên kiếm mấy cái MessageBox và mà mấy cái nút showdialog mà gặp thầy hehehe. thầy có viết bên c# nữa hả thầy. e nhớ thầy dạy java mà.
ReplyDeletechuyên môn chính của tôi là .Net (chủ yếu là winform và ASP.NET) SqlServer, mạng máy tính. Hiện tại thì Java, Android và PHP.
ReplyDeleteNói chung lâu năm rồi nên cũng phải rèn nhiều thứ.
Dạ, chứ e thấy em luyện Winform không cũng đuối rồi.hiiii
ReplyDelete