public IList <DescripcionEquipo> GetEquipos() { IList <DescripcionEquipo> Res = new List <DescripcionEquipo>(); string InsertSQL = string.Format("SELECT id, ip, nombre FROM `00equipos`"); MySql.Data.MySqlClient.MySqlCommand MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(InsertSQL, MySQLConn); try { MySql.Data.MySqlClient.MySqlDataReader MyReader = MySQLComm.ExecuteReader(); if (MyReader.HasRows) { while (MyReader.Read()) { Res.Add( new DescripcionEquipo( MyReader.GetString("id"), MyReader.GetString("ip"), MyReader.IsDBNull(2) ? "Sin Nombre" : MyReader.GetString("nombre"))); } } MyReader.Close(); } catch (MySql.Data.MySqlClient.MySqlException MyEx) { ErrLogger.LogError(MyEx.ToString(), System.Diagnostics.EventLogEntryType.Error); Res = new List <DescripcionEquipo>(); } return(Res); }
public IList <string> GetCurrent() { IList <string> Res = new List <string>(); string sSQL = "SELECT `00current`.fecha, `00equipos`.nombre, `00current`.temperatura, `00current`.humedad, `00current`.co, `00current`.consumo" + "\n" + "FROM `00current` INNER JOIN `00equipos` ON `00current`.equipo = `00equipos`.ip"; MySql.Data.MySqlClient.MySqlCommand MyComm = new MySql.Data.MySqlClient.MySqlCommand(sSQL, MySQLConn); try { MySql.Data.MySqlClient.MySqlDataReader MyReader = MyComm.ExecuteReader(); if (MyReader.HasRows) { while (MyReader.Read()) { Res.Add(new Lectura(MyReader.GetDateTime("fecha"), MyReader.GetString("nombre"), MyReader.GetDouble("temperatura"), MyReader.GetDouble("humedad"), MyReader.GetDouble("co"), MyReader.GetDouble("consumo")).ToString()); } } MyReader.Close(); } catch (MySql.Data.MySqlClient.MySqlException MyEx) { ErrLogger.LogError(MyEx.ToString(), System.Diagnostics.EventLogEntryType.Error); Res = new List <string>(); } return(Res); }
private void menuItem2_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "位图(*.bmp)|*.bmp|JPEG(*.jpg)|*.jpg;*.jpeg;*,jpe|Gif(*.gif)|*.gif|Png(*.png)|*.png|所有文件(*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { try { Bitmap bm = tendencyChart1.CreateBitmap(); if (saveFileDialog1.FilterIndex == 1) { bm.Save(saveFileDialog1.FileName, ImageFormat.Bmp); } if (saveFileDialog1.FilterIndex == 2) { bm.Save(saveFileDialog1.FileName, ImageFormat.Jpeg); } if (saveFileDialog1.FilterIndex == 3) { bm.Save(saveFileDialog1.FileName, ImageFormat.Gif); } if (saveFileDialog1.FilterIndex == 5) { bm.Save(saveFileDialog1.FileName, ImageFormat.Png); } } catch (Exception MyEx) { MessageBox.Show(MyEx.ToString(), "错误提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); } } }
public IList <string> GetLecturas(string IdEquipo, Periodicidad Periodicidad, DateTime FechaInicio, DateTime FechaFin) { //Obtiene la lista de las lecturas IList <string> Res = new List <string>(); string TablaPeriodicidad = ""; switch (Periodicidad) { case Periodicidad.TiempoReal: TablaPeriodicidad = "`01input`"; break; case Periodicidad.Diario: TablaPeriodicidad = "`02diario`"; break; case Periodicidad.Mensual: default: TablaPeriodicidad = "`03mensual`"; break; } string sSQL = "SELECT T2.ip, T1.fecha, T1.temperatura, T1.humedad, T1.co, T1.consumo" + "\n" + "FROM " + TablaPeriodicidad + " T1" + " INNER JOIN" + "\n" + "`00equipos` T2 ON T1.equipo = T2.ip" + "\n" + "WHERE (fecha BETWEEN '" + FechaInicio.ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + FechaFin.ToString("yyyy-MM-dd HH:mm:ss") + "') AND (T2.id = '" + IdEquipo + "')"; MySql.Data.MySqlClient.MySqlCommand MyComm = new MySql.Data.MySqlClient.MySqlCommand(sSQL, MySQLConn); try { MySql.Data.MySqlClient.MySqlDataReader MyReader = MyComm.ExecuteReader(); if (MyReader.HasRows) { while (MyReader.Read()) { Res.Add(new Lectura(MyReader.GetDateTime("fecha"), MyReader.GetString("ip"), MyReader.GetDouble("temperatura"), MyReader.GetDouble("humedad"), MyReader.GetDouble("co"), MyReader.GetDouble("consumo")).ToString()); } } MyReader.Close(); } catch (MySql.Data.MySqlClient.MySqlException MyEx) { ErrLogger.LogError(MyEx.ToString(), System.Diagnostics.EventLogEntryType.Error); Res = new List <string>(); } return(Res); }
private void btn_Multibook_Click(object sender, EventArgs e) { if (lbl_ClientNoTextBook.Text != "") { drclient = dsNWRC_HairBeauty.Tables["Client"].Rows.Find(lbl_ClientNoTextBook.Text); if (btn_Multibook.Text == "Edit Client") { //enable Form Entries formEnable(true); btn_CancelBook.Visible = true; btn_Multibook.Text = "Save Client"; } else { MyClient myClient = new MyClient(); bool ok = true; errP.Clear(); try { myClient.ClientNo = Convert.ToInt32(lbl_ClientNoTextBook.Text.Trim()); } catch (MyException MyEx) { ok = false; errP.SetError(lbl_ClientNoTextBook, MyEx.ToString()); } try { myClient.Title = cmb_TitleBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(cmb_TitleBook, MyEx.tostring()); } try { myClient.Surname = txt_SurnameBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_SurnameBook, MyEx.tostring()); } try { myClient.Forename = txt_ForenameBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_ForenameBook, MyEx.tostring()); } try { myClient.Street = rt_StreetBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(rt_StreetBook, MyEx.tostring()); } try { myClient.Town = txt_TownBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_TownBook, MyEx.tostring()); } try { myClient.County = txt_CountyBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_CountyBook, MyEx.tostring()); } try { myClient.Postcode = txt_PostcodeBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_PostcodeBook, MyEx.tostring()); } try { myClient.Country = txt_CountryBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_CountryBook, MyEx.tostring()); } try { myClient.TelNo = txt_TelephoneBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_TelephoneBook, MyEx.tostring()); } try { myClient.Email = txt_EmailBook.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_EmailBook, MyEx.tostring()); } try { if (chk_SkinBook.Checked) { myClient.SkinTest = "Yes"; } else { myClient.SkinTest = "No"; } } catch (MyException MyEx) { ok = false; errP.SetError(chk_SkinBook, MyEx.tostring()); } if (newClient) { drclient = dsNWRC_HairBeauty.Tables["Client"].NewRow(); drclient["ClientNo"] = myClient.ClientNo; drclient["Title"] = myClient.Title; drclient["Surname"] = myClient.Surname; drclient["Forename"] = myClient.Forename; drclient["Street"] = myClient.Street; drclient["Town"] = myClient.Town; drclient["County"] = myClient.County; drclient["PostCode"] = myClient.Postcode; drclient["Country"] = myClient.Country; drclient["TelNo"] = myClient.TelNo; drclient["Email"] = myClient.Email; drclient["SkinTest"] = myClient.SkinTest; dsNWRC_HairBeauty.Tables["Client"].Rows.Add(drclient); daClient.Update(dsNWRC_HairBeauty, "Client"); MessageBox.Show("New Customer " + lbl_ClientNoTextBook.Text + " added !!!"); } else { try { if (ok) { drclient.BeginEdit(); drclient["Title"] = myClient.Title; drclient["Surname"] = myClient.Surname; drclient["Forename"] = myClient.Forename; drclient["Street"] = myClient.Street; drclient["Town"] = myClient.Town; drclient["County"] = myClient.County; drclient["PostCode"] = myClient.Postcode; drclient["Country"] = myClient.Country; drclient["TelNo"] = myClient.TelNo; drclient["Email"] = myClient.Email; drclient["SkinTest"] = myClient.SkinTest; drclient.EndEdit(); daClient.Update(dsNWRC_HairBeauty, "Client"); MessageBox.Show("Customer " + lbl_ClientNoTextBook.Text + " Details have been Updated !!!"); } } catch (Exception ex) { MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } } //Disable Form entries formEnable(false); btn_CancelBook.Visible = false; btn_Multibook.Text = "Edit Client"; } } }
public void TeselarData() { try { if (AbrirConexion()) { lock (this) { string sSql = ""; try { sSql = "SELECT DISTINCT ip FROM `00equipos`;"; MySql.Data.MySqlClient.MySqlCommand MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySql.Data.MySqlClient.MySqlDataReader MyReaderEquipos = MySQLComm.ExecuteReader(); IList <string> Equipos = new List <string>(); if (MyReaderEquipos.HasRows) { while (MyReaderEquipos.Read()) { if (!MyReaderEquipos.IsDBNull(0)) { Equipos.Add(MyReaderEquipos.GetString("ip")); } } } MyReaderEquipos.Close(); MyReaderEquipos.Dispose(); foreach (string Eq in Equipos) { //Solo calcula los datos a día pasado sSql = "SELECT COUNT(equipo) AS Registros FROM `02diario` WHERE (fecha = '" + DateTime.Now.Date.AddDays(-1.0).AddHours(12.0).ToString("yyyy-MM-dd HH:mm:ss") + "') AND (equipo = '" + Eq + "')"; MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); if (MySQLComm.ExecuteScalar().ToString() == "0") { //Selecciona los datos diarios //De cada dispositivo sSql = "SELECT fecha, temperatura, humedad, co, consumo FROM `01input` WHERE (equipo = '" + Eq + "') AND (fecha BETWEEN '" + DateTime.Now.Date.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss") + "')"; MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySql.Data.MySqlClient.MySqlDataReader MyReaderDiario = MySQLComm.ExecuteReader(); IList <Lectura> Lecturas = new List <Lectura>(); if (MyReaderDiario.HasRows) { while (MyReaderDiario.Read()) { Lecturas.Add(new Lectura(MyReaderDiario.GetDateTime("fecha"), "", MyReaderDiario.GetDouble("temperatura"), MyReaderDiario.GetDouble("humedad"), MyReaderDiario.GetDouble("co"), MyReaderDiario.GetDouble("consumo"))); } } MyReaderDiario.Close(); MyReaderDiario.Dispose(); //Genera el resumen diario if (Lecturas.Count > 0) { Lectura LecturaDiaria = new Lectura(DateTime.Now.Date.AddDays(-1.0).AddHours(12.0), Eq, Lecturas.Select(L => L.Temperatura).Average(), Lecturas.Select(L => L.Humedad).Average(), Lecturas.Select(L => L.CO).Average(), Lecturas.Select(L => L.Consumo).Average()); sSql = string.Format("INSERT" + "\n" + "INTO {0} ({1}, {3}, {5}, {7}, {9}, {11})" + "\n" + "VALUES('{2}', '{4}', {6}, {8}, {10}, {12});", "`02diario`", "fecha", LecturaDiaria.Fecha.ToString("yyyy-MM-dd HH:mm:ss"), "equipo", LecturaDiaria.IpEquipo, "temperatura", LecturaDiaria.Temperatura.ToString("0.00").Replace(',', '.'), "humedad", LecturaDiaria.Humedad.ToString("0.00").Replace(',', '.'), "co", LecturaDiaria.CO.ToString("0.0000").Replace(',', '.'), "consumo", LecturaDiaria.Consumo.ToString("0.00").Replace(',', '.')); MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySQLComm.ExecuteNonQuery(); } } //Solo calcula los datos a mes pasado DateTime mespasado = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(-1); sSql = "SELECT COUNT(equipo) AS Registros FROM `03mensual` WHERE (fecha = '" + mespasado.AddDays(14.0).AddHours(12.0).ToString("yyyy-MM-dd HH:mm:ss") + "') AND (equipo = '" + Eq + "')"; MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); if (MySQLComm.ExecuteScalar().ToString() == "0") { //Selecciona los datos diarios //De cada dispositivo sSql = "SELECT fecha, temperatura, humedad, co, consumo FROM `02diario` WHERE (equipo = '" + Eq + "') AND (fecha BETWEEN '" + mespasado.ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + mespasado.AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss") + "');"; MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySql.Data.MySqlClient.MySqlDataReader MyReaderMensual = MySQLComm.ExecuteReader(); IList <Lectura> Lecturas = new List <Lectura>(); if (MyReaderMensual.HasRows) { while (MyReaderMensual.Read()) { Lecturas.Add(new Lectura(MyReaderMensual.GetDateTime("fecha"), "", MyReaderMensual.GetDouble("temperatura"), MyReaderMensual.GetDouble("humedad"), MyReaderMensual.GetDouble("co"), MyReaderMensual.GetDouble("consumo"))); } } MyReaderMensual.Close(); MyReaderMensual.Dispose(); //Genera el resumen diario if (Lecturas.Count > 0) { Lectura LecturaDiaria = new Lectura(mespasado.AddDays(14.0).AddHours(12.0), Eq, Lecturas.Select(L => L.Temperatura).Average(), Lecturas.Select(L => L.Humedad).Average(), Lecturas.Select(L => L.CO).Average(), Lecturas.Select(L => L.Consumo).Average()); sSql = string.Format("INSERT INTO {0} ({1}, {3}, {5}, {7}, {9}, {11})" + "\n" + "VALUES('{2}', '{4}', {6}, {8}, {10}, {12})", "`03mensual`", "fecha", LecturaDiaria.Fecha.ToString("yyyy-MM-dd HH:mm:ss"), "equipo", LecturaDiaria.IpEquipo, "temperatura", LecturaDiaria.Temperatura.ToString("0.00").Replace(',', '.'), "humedad", LecturaDiaria.Humedad.ToString("0.00").Replace(',', '.'), "co", LecturaDiaria.CO.ToString("0.0000").Replace(',', '.'), "consumo", LecturaDiaria.Consumo.ToString("0.00").Replace(',', '.')); MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySQLComm.ExecuteNonQuery(); } } } } catch (MySql.Data.MySqlClient.MySqlException MyEx) { ErrLogger.LogError(MyEx.ToString() + "\n" + sSql, System.Diagnostics.EventLogEntryType.Error); } } } else { ErrLogger.LogError("Sin conexión con SQLServer.", System.Diagnostics.EventLogEntryType.Error); } } catch (System.Data.SqlClient.SqlException SqlEx) { ErrLogger.LogError(SqlEx.ToString(), System.Diagnostics.EventLogEntryType.Error); } catch (Exception Ex) { ErrLogger.LogError(Ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } }
public bool SetData(string CadenaLectura) { try { if (AbrirConexion()) { Lectura RecLectura = new Lectura(CadenaLectura); bool Res = false; lock (this) { string sSql = ""; try { sSql = "SELECT ip FROM `00equipos` WHERE (ip = '" + RecLectura.IpEquipo + "')"; MySql.Data.MySqlClient.MySqlCommand MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySql.Data.MySqlClient.MySqlDataReader DR1 = MySQLComm.ExecuteReader(); bool hasRows = DR1.HasRows; DR1.Close(); DR1.Dispose(); if (!hasRows) { sSql = "INSERT INTO `00equipos` (ip, nombre) VALUES('" + RecLectura.IpEquipo + "', 'Pendiente de Nombre');"; //no existe el equipo MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySQLComm.ExecuteNonQuery(); } sSql = string.Format("INSERT" + "\n" + "INTO {0} ({1}, {3}, {5}, {7}, {9}, {11})" + "\n" + "VALUES('{2}', '{4}', {6}, {8}, {10}, {12});", "`01input`", "fecha", RecLectura.Fecha.ToString("yyyy-MM-dd HH:mm:ss"), "equipo", RecLectura.IpEquipo, "temperatura", RecLectura.Temperatura.ToString("0.00").Replace(',', '.'), "humedad", RecLectura.Humedad.ToString("0.00").Replace(',', '.'), "co", RecLectura.CO.ToString("0.0000").Replace(',', '.'), "consumo", RecLectura.Consumo.ToString("0.00").Replace(',', '.')); //TODO: UPDATE en 00current para la última lectura MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySQLComm.ExecuteNonQuery(); sSql = string.Format("INSERT INTO {0} ({1}, {3}, {5}, {7}, {9}, {11})" + "\n" + "VALUES('{2}', '{4}', {6}, {8}, {10}, {12})" + "\n" + "ON DUPLICATE KEY" + "\n" + "UPDATE {1}='{2}', {5}={6}, {7}={8}, {9}={10}, {11}={12}", "`00current`", "fecha", RecLectura.Fecha.ToString("yyyy-MM-dd HH:mm:ss"), "equipo", RecLectura.IpEquipo, "temperatura", RecLectura.Temperatura.ToString("0.00").Replace(',', '.'), "humedad", RecLectura.Humedad.ToString("0.00").Replace(',', '.'), "co", RecLectura.CO.ToString("0.0000").Replace(',', '.'), "consumo", RecLectura.Consumo.ToString("0.00").Replace(',', '.')); MySQLComm = new MySql.Data.MySqlClient.MySqlCommand(sSql, MySQLConn); MySQLComm.ExecuteNonQuery(); Res = true; } catch (MySql.Data.MySqlClient.MySqlException MyEx) { ErrLogger.LogError(MyEx.ToString() + "\n" + sSql, System.Diagnostics.EventLogEntryType.Error); Res = false; } } return(Res); } else { ErrLogger.LogError("Sin conexión con SQLServer.", System.Diagnostics.EventLogEntryType.Error); return(false); } } catch (System.Data.SqlClient.SqlException SqlEx) { ErrLogger.LogError(SqlEx.ToString(), System.Diagnostics.EventLogEntryType.Error); return(false); } catch (Exception Ex) { ErrLogger.LogError(Ex.ToString(), System.Diagnostics.EventLogEntryType.Error); return(false); } }
private void btn_EditClient_Click(object sender, EventArgs e) { if (btn_EditClient.Text == "Edit Client") { cmb_Title_Edit.Enabled = true; txt_Forename_Edit.Enabled = true; txt_Surname_Edit.Enabled = true; rt_Street_Edit.Enabled = true; txt_Town_Edit.Enabled = true; txt_County_Edit.Enabled = true; txt_Postcode_Edit.Enabled = true; txt_Country_Edit.Enabled = true; txt_TelNo_Edit.Enabled = true; txt_Email_Edit.Enabled = true; chk_Skin_Edit.Enabled = true; btn_EditClient.Text = "Save Client"; } else { MyClient myClient = new MyClient(); bool ok = true; errP.Clear(); try { myClient.ClientNo = Convert.ToInt32(lbl_ClientNo_EditText.Text.Trim()); } catch (MyException MyEx) { ok = false; errP.SetError(lbl_ClientNo_EditText, MyEx.ToString()); } try { myClient.Title = cmb_Title_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(cmb_Title_Edit, MyEx.tostring()); } try { myClient.Surname = txt_Surname_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_Surname_Edit, MyEx.tostring()); } try { myClient.Forename = txt_Forename_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_Forename_Edit, MyEx.tostring()); } try { myClient.Street = rt_Street_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(rt_Street_Edit, MyEx.tostring()); } try { myClient.Town = txt_Town_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_Town_Edit, MyEx.tostring()); } try { myClient.County = txt_County_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_County_Edit, MyEx.tostring()); } try { myClient.Postcode = txt_Postcode_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_Postcode_Edit, MyEx.tostring()); } try { myClient.Country = txt_Country_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_Country_Edit, MyEx.tostring()); } try { myClient.TelNo = txt_TelNo_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_TelNo_Edit, MyEx.tostring()); } try { myClient.Email = txt_Email_Edit.Text.Trim(); } catch (MyException MyEx) { ok = false; errP.SetError(txt_Email_Edit, MyEx.tostring()); } try { if (chk_Skin_Edit.Checked) { myClient.SkinTest = "Yes"; } else { myClient.SkinTest = "No"; } } catch (MyException MyEx) { ok = false; errP.SetError(chk_Skin_Edit, MyEx.tostring()); } try { if (ok) { drclient.BeginEdit(); // drclient["ClientNo"] = myClient.ClientNo; drclient["Title"] = myClient.Title; drclient["Surname"] = myClient.Surname; drclient["Forename"] = myClient.Forename; drclient["Street"] = myClient.Street; drclient["Town"] = myClient.Town; drclient["County"] = myClient.County; drclient["PostCode"] = myClient.Postcode; drclient["Country"] = myClient.Country; drclient["TelNo"] = myClient.TelNo; drclient["Email"] = myClient.Email; drclient["SkinTest"] = myClient.SkinTest; drclient.EndEdit(); daClient.Update(dsNWRC_HairBeauty, "Client"); MessageBox.Show("Customer " + lbl_ClientNo_EditText.Text + " Details have been Updated !!!"); cmb_Title_Edit.Enabled = false; txt_Forename_Edit.Enabled = false; txt_Surname_Edit.Enabled = false; rt_Street_Edit.Enabled = false; txt_Town_Edit.Enabled = false; txt_County_Edit.Enabled = false; txt_Postcode_Edit.Enabled = false; txt_Country_Edit.Enabled = false; txt_TelNo_Edit.Enabled = false; txt_Email_Edit.Enabled = false; chk_Skin_Edit.Enabled = false; btn_EditClient.Text = "Edit Client"; tab_Client.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } } }