示例#1
0
 public void ObtenerDatos()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "SELECT * FROM producto WHERE id=?id";
         sql.Parameters.AddWithValue("?id", id);
         DataTable dt = ConexionBD.EjecutarConsultaSelect(sql);
         foreach (DataRow dr in dt.Rows)
         {
             idProveedor   = (int)dr["proveedor_id"];
             idCategoria   = (int)dr["categoria"];
             nombre        = dr["nombre"].ToString();
             marca         = dr["marca"].ToString();
             codigo        = dr["codigo"].ToString();
             descripcion01 = dr["descripcion1"].ToString();
             costo         = (decimal)dr["costo"];
             unidad        = (Unidades)Enum.Parse(typeof(Unidades), dr["unidad"].ToString());
             if (dr["imagen01"] != DBNull.Value)
             {
                 imagen01 = FuncionesGenerales.BytesImagen((byte[])dr["imagen01"]);
             }
             else
             {
                 imagen01 = null;
             }
             if (dr["imagen02"] != DBNull.Value)
             {
                 imagen02 = FuncionesGenerales.BytesImagen((byte[])dr["imagen02"]);
             }
             else
             {
                 imagen02 = null;
             }
             if (dr["imagen03"] != DBNull.Value)
             {
                 imagen03 = FuncionesGenerales.BytesImagen((byte[])dr["imagen03"]);
             }
             else
             {
                 imagen03 = null;
             }
             eliminado  = (bool)dr["eliminado"];
             createUser = (int)dr["create_user"];
             createTime = (DateTime)dr["create_time"];
             if (dr["update_user"] != DBNull.Value)
             {
                 updateUser = (int)dr["update_user"];
             }
             else
             {
                 updateUser = 0;
             }
             if (dr["update_time"] != DBNull.Value)
             {
                 updateTime = (DateTime)dr["update_time"];
             }
             else
             {
                 updateTime = new DateTime();
             }
             if (dr["delete_user"] != DBNull.Value)
             {
                 deleteUser = (int)dr["delete_user"];
             }
             else
             {
                 deleteUser = 0;
             }
             if (dr["delete_time"] != DBNull.Value)
             {
                 deleteTime = (DateTime)dr["delete_time"];
             }
             else
             {
                 deleteTime = new DateTime();
             }
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
 /// <summary>
 /// Obtiene los datos de un proveedor según su ID
 /// </summary>
 public override void ObtenerDatos()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "SELECT * FROM proveedor WHERE id=?id";
         sql.Parameters.AddWithValue("?id", id);
         DataTable dt = ConexionBD.EjecutarConsultaSelect(sql);
         foreach (DataRow dr in dt.Rows)
         {
             sucursal      = (int)dr["sucursal_id"];
             cuenta        = (int)dr["cuenta_id"];
             nombre        = dr["nombre"].ToString();
             razonSocial   = dr["razon_social"].ToString();
             rfc           = dr["rfc"].ToString();
             calle         = dr["calle"].ToString();
             numExt        = dr["num_ext"].ToString();
             numInt        = dr["num_int"].ToString();
             colonia       = dr["colonia"].ToString();
             ciudad        = dr["ciudad"].ToString();
             estado        = dr["estado"].ToString();
             cp            = dr["cp"].ToString();
             telefono01    = dr["telefono1"].ToString();
             telefono02    = dr["telefono2"].ToString();
             correo        = dr["email"].ToString();
             lada01        = dr["lada1"].ToString();
             lada02        = dr["lada2"].ToString();
             tipo          = (TipoPersona)Enum.Parse(typeof(TipoPersona), dr["tipo"].ToString());
             limiteCredito = (decimal)dr["limite_credito"];
             eliminado     = bool.Parse(dr["eliminado"].ToString());
             createUser    = (int)dr["create_user"];
             createTime    = (DateTime)dr["create_time"];
             if (dr["update_user"] != DBNull.Value)
             {
                 updateUser = (int)dr["update_user"];
             }
             else
             {
                 updateUser = 0;
             }
             if (dr["update_time"] != DBNull.Value)
             {
                 updateTime = (DateTime)dr["update_time"];
             }
             else
             {
                 updateTime = new DateTime();
             }
             if (dr["delete_user"] != DBNull.Value)
             {
                 deleteUser = (int)dr["delete_user"];
             }
             else
             {
                 deleteUser = 0;
             }
             if (dr["delete_time"] != DBNull.Value)
             {
                 deleteTime = (DateTime)dr["delete_time"];
             }
             else
             {
                 deleteTime = new DateTime();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }