Пример #1
0
 // ============= custom ============ //
 public static bool existsName(Clientes cli)
 {
     String sql = String.Format("SELECT * FROM clientes WHERE rut = '{0}' AND dv = '{1}'", cli.Rut, cli.Dv);
     DataTable dt = BD.getInstance().sqlSelect(sql);
     if (dt.Rows.Count == 0)
         return false;
     return true;
 }
Пример #2
0
 public static bool sqlUpdate(Clientes cli)
 {
     String sql = String.Format("UPDATE clientes SET rut = '{0}', dv = '{1}', nombre = '{2}', ape_paterno = '{3}', ape_materno = '{4}', email = '{5}', fecha_nac = '{6}', telefono= '{7}', sexo = '{8}', direccion = '{9}' WHERE idclientes = '{10}'"
                                 , cli.Rut
                                 , cli.Dv
                                 , cli.Nombre
                                 , cli.Ape_paterno
                                 , cli.Ape_materno
                                 , cli.Email
                                 , cli.Fecha_nac.ToString("dd/MM/yyyy")
                                 , cli.Telefono
                                 , cli.Sexo
                                 , cli.Direccion
                                 , cli.Id
                                 );
         return BD.getInstance().sqlEjecuta(sql);
 }
Пример #3
0
        public static bool sqlLeer(Clientes cli)
        {
            String sql = String.Format("SELECT * FROM clientes WHERE idclientes = '{0}'"
                                       , cli.Id);
            DataTable dt = BD.getInstance().sqlSelect(sql);
            if (dt.Rows.Count == 0)
                return false;

            cli.Rut = int.Parse(dt.Rows[0]["rut"].ToString());
            cli.Dv = char.Parse(dt.Rows[0]["dv"].ToString());
            cli.Nombre = dt.Rows[0]["nombre"].ToString();
            cli.Ape_paterno = dt.Rows[0]["ape_paterno"].ToString();
            cli.Ape_materno = dt.Rows[0]["ape_materno"].ToString();
            cli.Email = dt.Rows[0]["email"].ToString();
            cli.Fecha_nac = DateTime.Parse(dt.Rows[0]["fecha_nac"].ToString());
            cli.Telefono = dt.Rows[0]["telefono"].ToString();
            cli.Sexo = char.Parse(dt.Rows[0]["sexo"].ToString());
            cli.Direccion = dt.Rows[0]["direccion"].ToString();
            return true;
        }
Пример #4
0
 public static bool sqlInsert(Clientes cli)
 {
     if (!existsName(cli))
     {
         String sql = String.Format("INSERT INTO clientes (rut, dv, nombre, ape_paterno, ape_materno, email, fecha_nac, telefono, sexo, direccion) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')"
                                 , cli.Rut
                                 , cli.Dv
                                 , cli.Nombre
                                 , cli.Ape_paterno
                                 , cli.Ape_materno
                                 , cli.Email
                                 , cli.Fecha_nac.ToString("dd/MM/yyyy")
                                 , cli.Telefono
                                 , cli.Sexo
                                 , cli.Direccion
                                 );
         return BD.getInstance().sqlEjecuta(sql);
     }
     return false;
 }
Пример #5
0
 public static bool sqlDelete(Clientes cli)
 {
     String sql = String.Format("DELETE FROM clientes WHERE idclientes = '{0}'"
                             , cli.Id);
     return BD.getInstance().sqlEjecuta(sql);
 }