Exemplo n.º 1
0
        private void btnAltaRecorrido_Click(object sender, EventArgs e)
        {
            if (CodigoRecorrido.Text == "")
            {
                MessageBox.Show("Debe ingresar los valores obligatorios");
            }
            else
            {
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["GD_CRUCEROS"].ConnectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("LOS_QUE_VAN_A_APROBAR.CrearRecorrido", cn))
                    {
                        try
                        {
                            cn.Open();
                            cmd.CommandType = CommandType.StoredProcedure;

                            cmd.Parameters.Add("@CodigoRecorrido", SqlDbType.Decimal).Value = Decimal.Parse(CodigoRecorrido.Text);
                            cmd.Parameters["@CodigoRecorrido"].Precision = 18;
                            cmd.Parameters["@CodigoRecorrido"].Scale     = 2;

                            cmd.Parameters.Add("@Descripcion", SqlDbType.VarChar, 50).Value = DescripcionRecorrido.Text;


                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Nuevo recorrido satisfactorio");
                            cn.Close();
                            cn.Dispose();

                            AgregarTramo form = new AgregarTramo();
                            form.StartPosition = FormStartPosition.CenterScreen;
                            form.Show();
                            this.Dispose();
                        }
                        catch (FormatException)
                        {
                            MessageBox.Show("El codigo de recorrido debe ser numeros enteros positivos");
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["GD_CRUCEROS"].ConnectionString);

            cn.Open();
            SqlCommand sc = new SqlCommand("select top 1 Puerto_Llegada from LOS_QUE_VAN_A_APROBAR.RecorridoPorTramo join LOS_QUE_VAN_A_APROBAR.Tramo on (IdTramo = CodigoTramo) where CodigoRecorrido = @IdRecorrido order by orden desc ", cn);

            sc.CommandType = CommandType.Text;

            sc.Parameters.AddWithValue("@IdRecorrido", Convert.ToInt32(comboBoxModifReco.SelectedValue.ToString()));

            string PuertoS = sc.ExecuteScalar().ToString();



            cn.Close();

            AgregarTramo fo = new AgregarTramo(Convert.ToInt32(comboBoxModifReco.SelectedValue.ToString()), PuertoS);

            fo.StartPosition = FormStartPosition.CenterScreen;
            fo.Show();
        }