Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                datetime = System.DateTime.Now.ToString("yyyy-MM-dd H:mm:ss");
                SqlCommand cmd = new SqlCommand("Insert_Vehical", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@location", SqlDbType.VarChar).Value        = location;
                cmd.Parameters.Add("@date_time", SqlDbType.VarChar).Value       = datetime;
                cmd.Parameters.Add("@type", SqlDbType.VarChar).Value            = comboBox1.Text;
                cmd.Parameters.Add("@registration_no", SqlDbType.VarChar).Value = txt_VNUMBER.Text;
                cmd.Parameters.Add("@driver_name", SqlDbType.VarChar).Value     = txt_driver_name.Text;
                cmd.Parameters.Add("@driver_cnic", SqlDbType.VarChar).Value     = txt_driver_CNIC.Text;
                cmd.Parameters.Add("@no_of_passengers", SqlDbType.Int).Value    = txt_No_of_P.Text;
                cmd.Parameters.Add("@user_id", SqlDbType.Int).Value             = global_user_id.GlobalVar;
                con.Open();
                cmd.ExecuteNonQuery();

                SqlCommand cmd2 = new SqlCommand("Select max(vehical_id) from tbl_vehicals", con);
                cmd2.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter(cmd2);
                DataTable      dt = new DataTable();
                da.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    vehical_id_int = int.Parse(dr[0].ToString());
                }

                if (i != 0)
                {
                    for (int j = 0; j < i; j++)
                    {
                        SqlCommand cmd3 = new SqlCommand("Insert_Passengers", con);
                        cmd3.CommandType = CommandType.StoredProcedure;
                        cmd3.Parameters.Add("@name", SqlDbType.VarChar).Value   = listView1.Items[j].SubItems[0].Text;
                        cmd3.Parameters.Add("@CNIC", SqlDbType.VarChar).Value   = listView1.Items[j].SubItems[1].Text;
                        cmd3.Parameters.Add("@vehical_id", SqlDbType.Int).Value = vehical_id_int;
                        cmd3.ExecuteNonQuery();
                    }
                }

                recipet_form rf = new recipet_form(Convert.ToInt32(vehical_id_int));
                rf.Show();
            }

            catch (Exception x)
            {
                MessageBox.Show("" + x);
            }

            finally
            {
                con.Close();
            }
        }
Example #2
0
 private void button4_Click_1(object sender, EventArgs e)
 {
     if (MessageBox.Show("Current Passengers Added are " + no__of_passengers.ToString() + ".\n Are you sure these are all the Passengers Confirm?", "Close Application", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         recipet_form frm = new recipet_form(Convert.ToInt32(vehical_id_temp));
         frm.Show();
     }
     else
     {
     }
 }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            recipet_form frm = new recipet_form(vehical_id_int);

            frm.Show();
        }