public void Insertar_Producto()
{
try
{
SqlCommand cmd
= new SqlCommand
("sp_Insertar_Producto",con
.Conexion); cmd.CommandType=CommandType.StoredProcedure;
cmd
.Parameters.Add(new SqlParameter
("@Cod_Producto", SqlDbType
.VarChar)); cmd.Parameters["@Cod_Producto"].Direction= ParameterDirection.Input;
cmd.Parameters["@Cod_Producto"].Value=s_Cod_Producto;
cmd
.Parameters.Add(new SqlParameter
("@Nombre",SqlDbType
.VarChar)); cmd.Parameters["@Nombre"].Direction=ParameterDirection.Input;
cmd.Parameters["@Nombre"].Value=s_Nombre;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
SqlCommand cmd_Id
= new SqlCommand
("sp_Productos_Last_ID", con
.Conexion); cmd_Id.CommandType = CommandType.StoredProcedure;
con.Open();
int ID=Convert.ToInt32(cmd_Id.ExecuteScalar());
con.Close();
SqlCommand cmd1
= new SqlCommand
("sp_Fechas_Insertar", con
.Conexion); cmd1.CommandType = CommandType.StoredProcedure;
cmd1
.Parameters.Add(new SqlParameter
("@Id_Producto", SqlDbType
.Int)); cmd1.Parameters["@Id_Producto"].Direction = ParameterDirection.Input;
cmd1.Parameters["@Id_Producto"].Value = ID;
cmd1
.Parameters.Add(new SqlParameter
("@Fecha_Entrada", SqlDbType
.DateTime)); cmd1.Parameters["@Fecha_Entrada"].Direction = ParameterDirection.Input;
cmd1.Parameters["@Fecha_Entrada"].Value = dt_Fecha_Entrada;
con.Open();
cmd1.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}