public Task<int> ExecuteAsync(MySqlConnection con, string sSQL)
{
return Task.Run(() =>
{
string constring = "Server = localhost; Database = jhcisdb;Port=3333; Uid = root; Pwd = 123456; AllowZeroDateTime = True;CharSet=utf8;default command timeout=100000";
jcon = new MySqlConnection(constring);
// using (var newConnection = new SqlConnection(sConnectionString))
using (var newCommand = new MySqlCommand(sSQL, con))
{
newCommand.CommandType = CommandType.Text;
con.Open();
return newCommand.ExecuteNonQuery();
}
});
}
//-------------------------------
private async Task ExecuteSomeData()
{
//Use Async method to get data
await ExecuteAsync(jcon, sqlAll);
}
//----------------------------------------------
private void BtnTest_Click(object sender, EventArgs e)
{
ExecuteSomeData();
//MessageBox.Show("OK");
}
วันอังคารที่ 16 มิถุนายน พ.ศ. 2563
วันเสาร์ที่ 6 มิถุนายน พ.ศ. 2563
วันศุกร์ที่ 5 มิถุนายน พ.ศ. 2563
การจัดการ dateTimePicker
https://www.thaicreate.com/community/windows-form-datetimepicker.html
using System.Globalization;
using System.Threading;
if (fromDate.Value.Date <= toDate.Value.Date)
{
CultureInfo _cultureEnInfo = new CultureInfo("en-US");
DateTime dateBEgin = Convert.ToDateTime(this.fromDate.Value, _cultureEnInfo);
DateTime dateEnd = Convert.ToDateTime(this.toDate.Value, _cultureEnInfo);
//this.lblEng.Text = dateEng.ToString("dd MMM yyyy", _cultureEnInfo);
this.lblEng.Text = dateBEgin.ToString("yyyy MM dd", _cultureEnInfo);
lblEndate.Text = dateEnd.ToString("yyyy MM dd", _cultureEnInfo);
lblXX.Text = getDate(fromDate);
MessageBox.Show("OK");
}
else
{
MessageBox.Show("พ่องตาย");
}
----------------------------------------------
private string getDate(DateTimePicker d)
{
string xx;
CultureInfo _cultureEnInfo = new CultureInfo("en-US");
DateTime xDate = Convert.ToDateTime(d.Value, _cultureEnInfo);
xx = xDate.ToString("yyyyMMdd", _cultureEnInfo);
return xx;
}
using System.Globalization;
using System.Threading;
if (fromDate.Value.Date <= toDate.Value.Date)
{
CultureInfo _cultureEnInfo = new CultureInfo("en-US");
DateTime dateBEgin = Convert.ToDateTime(this.fromDate.Value, _cultureEnInfo);
DateTime dateEnd = Convert.ToDateTime(this.toDate.Value, _cultureEnInfo);
//this.lblEng.Text = dateEng.ToString("dd MMM yyyy", _cultureEnInfo);
this.lblEng.Text = dateBEgin.ToString("yyyy MM dd", _cultureEnInfo);
lblEndate.Text = dateEnd.ToString("yyyy MM dd", _cultureEnInfo);
lblXX.Text = getDate(fromDate);
MessageBox.Show("OK");
}
else
{
MessageBox.Show("พ่องตาย");
}
----------------------------------------------
private string getDate(DateTimePicker d)
{
string xx;
CultureInfo _cultureEnInfo = new CultureInfo("en-US");
DateTime xDate = Convert.ToDateTime(d.Value, _cultureEnInfo);
xx = xDate.ToString("yyyyMMdd", _cultureEnInfo);
return xx;
}
สมัครสมาชิก:
บทความ (Atom)