Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            MenuViaje form = new MenuViaje();

            form.StartPosition = FormStartPosition.CenterScreen;
            form.Show();
            this.Dispose();
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["GD_CRUCEROS"].ConnectionString))
                {
                    cn.Open();


                    using (SqlCommand cmd = new SqlCommand("LOS_QUE_VAN_A_APROBAR.GenerarViaje", cn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        DataRowView drv       = (DataRowView)comboBoxCruceros.SelectedItem;
                        string      IdCrucero = Convert.ToString(drv["IdCrucero"]);
                        cmd.Parameters.Add("@IdCrucero", SqlDbType.NVarChar, 50).Value = IdCrucero;

                        DataRowView drv2        = (DataRowView)comboBoxRecorrido.SelectedItem;
                        int         IdRecorrido = Convert.ToInt32(drv2["CodigoRecorrido"]);
                        cmd.Parameters.Add("@IdRecorrido", SqlDbType.Int).Value = IdRecorrido;

                        DateTime fechaS = Convert.ToDateTime(fechaSalida.Text);
                        cmd.Parameters.Add("@Fecha_Salida", SqlDbType.DateTime2, 3).Value = fechaS;

                        DateTime fechaL = Convert.ToDateTime(fechaLlegada.Text);
                        cmd.Parameters.Add("@Fecha_Llegada", SqlDbType.DateTime2, 3).Value = fechaL;

                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Viaje creado satisfactoriamente");
                        cn.Close();
                        cn.Dispose();
                        MenuViaje form = new MenuViaje();
                        form.StartPosition = FormStartPosition.CenterScreen;
                        form.Show();
                        this.Dispose();
                    }
                }
            }
            catch
            {
                MessageBox.Show("La fecha de salida debe ser mayor a la actual");
            }
        }