Beispiel #1
0
        public Boolean Insert(clsCaracteristica car)
        {
            try
            {
                con.conectarBD();

                cmd             = new MySqlCommand("GuardaCaracteristica", con.conector);
                cmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter oParam;
                oParam           = cmd.Parameters.AddWithValue("descripcion", car.Descripcion);
                oParam           = cmd.Parameters.AddWithValue("codusu", car.CodUser);
                oParam           = cmd.Parameters.AddWithValue("newid", 0);
                oParam.Direction = ParameterDirection.Output;
                int x = cmd.ExecuteNonQuery();

                car.CodCaracteristicaNuevo = Convert.ToInt32(cmd.Parameters["newid"].Value);

                if (x != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }
Beispiel #2
0
        public Boolean Update(clsCaracteristica car)
        {
            try
            {
                con.conectarBD();

                cmd             = new MySqlCommand("ActualizaCaracteristica", con.conector);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("codcar", car.CodCaracteristica);
                cmd.Parameters.AddWithValue("descripcion", car.Descripcion);
                int x = cmd.ExecuteNonQuery();
                if (x != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }
Beispiel #3
0
        public clsCaracteristica CargaCaracteristica(Int32 Codigo)
        {
            clsCaracteristica car = null;

            try
            {
                con.conectarBD();
                cmd = new MySqlCommand("MuestraCaracteristica", con.conector);
                cmd.Parameters.AddWithValue("codcar", Codigo);
                cmd.CommandType = CommandType.StoredProcedure;
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        car = new clsCaracteristica();
                        car.CodCaracteristica = Convert.ToInt32(dr.GetDecimal(0));
                        car.Descripcion       = dr.GetString(1);
                        car.Estado            = dr.GetBoolean(2);
                        car.CodUser           = Convert.ToInt32(dr.GetDecimal(3));
                        car.FechaRegistro     = dr.GetDateTime(4);// capturo la fecha
                    }
                }
                return(car);
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }
Beispiel #4
0
 public Boolean update(clsCaracteristica car)
 {
     try
     {
         return(Mcar.Update(car));
     }
     catch (Exception ex)
     {
         DevComponents.DotNetBar.MessageBoxEx.Show("Se encontró el siguiente problema: " + ex.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return(false);
     }
 }
Beispiel #5
0
        public Boolean insert(clsCaracteristica car)
        {
            try
            {
                return(Mcar.Insert(car));
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Duplicate entry"))
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Se encontró el siguiente problema: N°- de Documento Repetido", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                else
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Se encontró el siguiente problema: " + ex.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                return(false);
            }
        }