I want to Show messages with MessageBox.Show() Method.
If txt_Phone.TextLength >= 3 AND dtp_StartDate.Value < dtp_EndDate.Value they do same thing. But I want to show different messages. For textlength I will show 'Enter more than 3 characters.' For if startdate greater than stopdate I will show ' Start Date can not bigger than Stop Date'
if (txt_Phone.TextLength >= 3 & dtp_StartDate.Value < dtp_EndDate.Value)
{
DataTable dt = new DataTable();
SqlConnection myConn = new SqlConnection("Data Source=***;Initial Catalog=ViasesTest;User Id=sa;Password=****;MultipleActiveResultSets=true;");
myConn.Open();
SqlCommand myCmd = new SqlCommand("sp_GetData", myConn);
myCmd.Parameters.AddWithValue("@StartDate", dtp_StartDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
myCmd.Parameters.AddWithValue("@EndDate", dtp_EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
myCmd.Parameters.AddWithValue("@Phone", txt_Phone.Text.ToString().Trim());
myCmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(myCmd);
da.Fill(dt);
dataGridView1.DataSource = dt;
}
else
{
MessageBox.Show("Hata!");
}
Aucun commentaire:
Enregistrer un commentaire