Пример #1
0
        //Submit button to upload the maintenance details to the database
        private void Submit_maintenance_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=MyTaxi;Integrated Security=True";
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert_maintanance_details", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@vehicle", SqlDbType.VarChar).Value = dropdown_vehicle_list_maintenance.Text.Trim();
                cmd.Parameters.AddWithValue("@type", SqlDbType.VarChar).Value    = Type_combobox.Text.Trim();
                cmd.Parameters.AddWithValue("@cost", Convert.ToInt32(Cost_text.Text.Trim()));
                cmd.Parameters.AddWithValue("@date_add", Convert.ToDateTime(date_pick.Text.Trim()));
                if (KM_text.Visible == true)
                {
                    cmd.Parameters.AddWithValue("@km", Convert.ToInt32(KM_text.Text.Trim()));
                }
                cmd.ExecuteNonQuery();
                MessageBox.Show("Details uploaded");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
                KM_text.Clear();
                Cost_text.Clear();
                Type_combobox.ResetText();
            }
        }
Пример #2
0
        //submiting to insert to database about
        private void Submit_button_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=MyTaxi;Integrated Security=True";


            try
            {
                if (Diesel_text.Text == "")
                {
                    Diesel_text.Text = "0";
                }
                if (diesel_text_us.Text == "")
                {
                    diesel_text_us.Text = "0";
                }
                if (Advance_text_company.Text == "")
                {
                    Advance_text_company.Text = "0";
                }
                if (Advance_text_US.Text == "")
                {
                    Advance_text_US.Text = "0";
                }
                if (qty_text.Text == "")
                {
                    qty_text.Text = "0";
                }

                conn.Open();
                SqlCommand cmd = new SqlCommand("insert_trip_details", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@vehicle_number", dropdown_vehicle_trip.Text.Trim());
                cmd.Parameters.AddWithValue("@cost", Convert.ToInt32(Cost_text.Text.Trim()));
                cmd.Parameters.AddWithValue("@km", Convert.ToInt32(KM_text.Text.Trim()));
                cmd.Parameters.AddWithValue("@company", company_text.Text.Trim());
                cmd.Parameters.AddWithValue("@from_place", From_text.Text.Trim());
                cmd.Parameters.AddWithValue("@to_place", To_text.Text.Trim());
                cmd.Parameters.AddWithValue("@diesel_cost", Convert.ToInt32(Diesel_text.Text.Trim()));
                cmd.Parameters.AddWithValue("@diesel_cost_us", Convert.ToInt32(diesel_text_us.Text.Trim()));
                cmd.Parameters.AddWithValue("@material", Material_text.Text.Trim());
                cmd.Parameters.AddWithValue("@qty", Convert.ToInt32(qty_text.Text.Trim()));
                cmd.Parameters.AddWithValue("@driver", driver_droplist.Text.Trim());
                cmd.Parameters.AddWithValue("@remarks", Convert.ToInt32(Remarks_text.Text.Trim()));
                cmd.Parameters.AddWithValue("@date", Convert.ToDateTime(date_pick.Text.Trim()));
                cmd.Parameters.AddWithValue("@advance", Convert.ToInt32(Advance_text_company.Text.Trim()));
                cmd.Parameters.AddWithValue("@advance_us", Convert.ToInt32(Advance_text_US.Text.Trim()));
                cmd.ExecuteNonQuery();


                //resetting after inserting

                Cost_text.Clear();
                KM_text.Clear();
                Remarks_text.Clear();
                date_pick.ResetText();
                Diesel_text.Clear();
                Material_text.Clear();
                Advance_text_company.Clear();
                Advance_text_US.Clear();
                qty_text.Clear();


                MessageBox.Show("Trip details updated");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }