private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();
                string       query = "select Car_License_ID from car_license where Car_ID=" + CarId + "";
                MySqlCommand com   = new MySqlCommand(query, dbconnection);


                if (com.ExecuteScalar() == null)
                {
                    if (txtCarNumber.Text != "")
                    {
                        string qeury = "insert into car_license (Car_ID,Car_License_Number,Car_Shaza_Number,Car_Model,Car_Company,Start_License_Date,End_License_Date)values(@Car_ID,@Car_License_Number,@Car_Shaza_Number,@Car_Model,@Car_Company,@Start_License_Date,@End_License_Date)";
                        com = new MySqlCommand(qeury, dbconnection);
                        com.Parameters.Add("@Car_ID", MySqlDbType.Int16);
                        com.Parameters["@Car_ID"].Value = CarId;
                        com.Parameters.Add("@Car_License_Number", MySqlDbType.VarChar, 255);
                        com.Parameters["@Car_License_Number"].Value = txtLicenseNumber.Text;
                        com.Parameters.Add("@Car_Shaza_Number", MySqlDbType.VarChar, 255);
                        com.Parameters["@Car_Shaza_Number"].Value = txtShaza.Text;
                        com.Parameters.Add("@Car_Model", MySqlDbType.VarChar, 255);
                        com.Parameters["@Car_Model"].Value = txtModel.Text;
                        com.Parameters.Add("@Car_Company", MySqlDbType.VarChar);
                        com.Parameters["@Car_Company"].Value = txtCarCampany.Text;
                        com.Parameters.Add("@Start_License_Date", MySqlDbType.Date);
                        com.Parameters["@Start_License_Date"].Value = dateTimePicker1.Value.Date;
                        com.Parameters.Add("@End_License_Date", MySqlDbType.Date);
                        com.Parameters["@End_License_Date"].Value = dateTimePicker2.Value.Date;

                        com.ExecuteNonQuery();

                        MessageBox.Show("add success");
                        clear();
                        XtraTabPage xtraTabPage = getTabPage("تسجيل رخصة العربية");
                        xtraTabPage.ImageOptions.Image = null;

                        carsMainForm.displayNotification(dbconnection);
                    }
                    else
                    {
                        MessageBox.Show("enter Car Number");
                    }
                }
                else
                {
                    MessageBox.Show("This Car already exist");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();

                if (txtCarNumber.Text != "")
                {
                    string       qeury = "update car_license set Car_License_Number=@Car_License_Number,Car_Shaza_Number=@Car_Shaza_Number,Car_Model=@Car_Model,Car_Company=@Car_Company,Start_License_Date=@Start_License_Date,End_License_Date=@End_License_Date where Car_ID=" + CarId;
                    MySqlCommand com   = new MySqlCommand(qeury, dbconnection);

                    com.Parameters.Add("@Car_License_Number", MySqlDbType.VarChar, 255);
                    com.Parameters["@Car_License_Number"].Value = txtLicenseNumber.Text;
                    com.Parameters.Add("@Car_Shaza_Number", MySqlDbType.VarChar, 255);
                    com.Parameters["@Car_Shaza_Number"].Value = txtShaza.Text;
                    com.Parameters.Add("@Car_Model", MySqlDbType.VarChar, 255);
                    com.Parameters["@Car_Model"].Value = txtModel.Text;
                    com.Parameters.Add("@Car_Company", MySqlDbType.VarChar);
                    com.Parameters["@Car_Company"].Value = txtCarCampany.Text;
                    com.Parameters.Add("@Start_License_Date", MySqlDbType.Date);
                    com.Parameters["@Start_License_Date"].Value = dateTimePicker1.Value.Date;
                    com.Parameters.Add("@End_License_Date", MySqlDbType.Date);
                    com.Parameters["@End_License_Date"].Value = dateTimePicker2.Value.Date;

                    com.ExecuteNonQuery();

                    MessageBox.Show("update success");

                    carsMainForm.displayNotification(dbconnection);
                    XtraTabPage xtraTabPage = getTabPage("تعديل رخصة العربية");
                    xtraTabPage.ImageOptions.Image = null;
                }
                else
                {
                    MessageBox.Show("enter Car Number");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();

                if (comSpareParts.Text != "")
                {
                    string       qeury = "insert into car_sparepart (Car_ID,SparePart_ID,Car_SparePart_Info,Car_SpareDate)values(@Car_ID,@SparePart_ID,@Car_SparePart_Info,@Car_SpareDate)";
                    MySqlCommand com   = new MySqlCommand(qeury, dbconnection);
                    com.Parameters.Add("@Car_ID", MySqlDbType.Int32);
                    com.Parameters["@Car_ID"].Value = CarId;
                    com.Parameters.Add("@SparePart_ID", MySqlDbType.Int16);
                    com.Parameters["@SparePart_ID"].Value = comSpareParts.SelectedValue;
                    com.Parameters.Add("@Car_SparePart_Info", MySqlDbType.VarChar, 255);
                    com.Parameters["@Car_SparePart_Info"].Value = txtInfo.Text;
                    com.Parameters.Add("@Car_SpareDate", MySqlDbType.Date);
                    com.Parameters["@Car_SpareDate"].Value = dateTimePicker1.Value.Date;

                    com.ExecuteNonQuery();

                    displayCarSpareParts();
                    comSpareParts.Focus();
                    carsMainForm.displayNotification(dbconnection);
                }
                else
                {
                    MessageBox.Show("enter Name");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }