private void btnUpdateDriver_Click(object sender, EventArgs e) { try { dbconnection.Open(); string qeury = "update drivers set Driver_Name=@Driver_Name,Driver_Phone=@Driver_Phone,Driver_Address=@Driver_Address ,Driver_BairthDate=@Driver_BairthDate,Driver_License=@Driver_License,Driver_NationalID=@Driver_NationalID,Driver_StartWorkDate=@Driver_StartWorkDate where Driver_ID=" + DriverRow[0].ToString(); MySqlCommand com = new MySqlCommand(qeury, dbconnection); com.Parameters.Add("@Driver_Name", MySqlDbType.VarChar, 255); com.Parameters["@Driver_Name"].Value = txtDriverName.Text; com.Parameters.Add("@Driver_Phone", MySqlDbType.VarChar, 255); com.Parameters["@Driver_Phone"].Value = txtPhone.Text; com.Parameters.Add("@Driver_Address", MySqlDbType.VarChar); com.Parameters["@Driver_Address"].Value = txtAddress.Text; com.Parameters.Add("@Driver_BairthDate", MySqlDbType.Date); com.Parameters["@Driver_BairthDate"].Value = dTPBirthDate.Value.Date; com.Parameters.Add("@Driver_License", MySqlDbType.VarChar, 255); com.Parameters["@Driver_License"].Value = txtLicese.Text; com.Parameters.Add("@Driver_NationalID", MySqlDbType.VarChar, 255); com.Parameters["@Driver_NationalID"].Value = txtNationalID.Text; com.Parameters.Add("@Driver_StartWorkDate", MySqlDbType.Date); com.Parameters["@Driver_StartWorkDate"].Value = dTPWorkStartDate.Value.Date; com.ExecuteNonQuery(); MessageBox.Show("update success"); drivers.DisplayDrivers(); XtraTabPage xtraTabPage = getTabPage("تعديل بيانات سائق"); xtraTabPage.ImageOptions.Image = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } dbconnection.Close(); }
private void btnAddDriver_Click(object sender, EventArgs e) { try { dbconnection.Open(); string query = "select Driver_Name from drivers where Driver_Name='" + txtDriverName.Text + "'"; MySqlCommand com = new MySqlCommand(query, dbconnection); if (com.ExecuteScalar() == null) { if (txtDriverName.Text != "") { string qeury = "insert into drivers (Driver_Name,Driver_Phone,Driver_Address,Driver_BairthDate,Driver_License,Driver_NationalID,Driver_StartWorkDate)values(@Driver_Name,@Driver_Phone,@Driver_Address,@Driver_BairthDate,@Driver_License,@Driver_NationalID,@Driver_StartWorkDate)"; com = new MySqlCommand(qeury, dbconnection); com.Parameters.Add("@Driver_Name", MySqlDbType.VarChar, 255); com.Parameters["@Driver_Name"].Value = txtDriverName.Text; com.Parameters.Add("@Driver_Phone", MySqlDbType.VarChar, 255); com.Parameters["@Driver_Phone"].Value = txtPhone.Text; com.Parameters.Add("@Driver_Address", MySqlDbType.VarChar, 255); com.Parameters["@Driver_Address"].Value = txtAddress.Text; com.Parameters.Add("@Driver_BairthDate", MySqlDbType.Date); com.Parameters["@Driver_BairthDate"].Value = dTPBirthDate.Value.Date; com.Parameters.Add("@Driver_License", MySqlDbType.VarChar, 255); com.Parameters["@Driver_License"].Value = txtLicese.Text; com.Parameters.Add("@Driver_NationalID", MySqlDbType.VarChar, 255); com.Parameters["@Driver_NationalID"].Value = txtNationalID.Text; com.Parameters.Add("@Driver_StartWorkDate", MySqlDbType.Date); com.Parameters["@Driver_StartWorkDate"].Value = dTPWorkStartDate.Value.Date; com.ExecuteNonQuery(); MessageBox.Show("add success"); drivers.DisplayDrivers(); clear(); } else { MessageBox.Show("enter Name"); } } else { MessageBox.Show("This Store already exist"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } dbconnection.Close(); }