Ejemplo n.º 1
0
        //INSERTAR

        public int insertarCliente(int ci, string nombre, string apellido, string fechaNac, string estCivil,
                                   string trabajo, int lugar)
        {
            NpgsqlConnection conn = DAOCliente.getInstanceDAO();

            conn.Open();

            String sql = "INSERT INTO \"Cliente\" (\"CI\", \"Nombre\", \"Apellido\", \"FechaNac\" ,\"EstadoCivil\",\"Trabajo\",\"FK-LugarC\") " +
                         "VALUES (" + ci + ",'" + nombre + "','" + apellido + "',TO_DATE('" + fechaNac + "', 'YYYY-MM-DD'),'"
                         + estCivil + "','" + trabajo + "','" + lugar + "')";
            NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);

            try
            {
                int resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE
                conn.Close();
                return(resp);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                conn.Close();
                return(0);
            }
        }
Ejemplo n.º 2
0
 public static DAOCliente getInstance()
 {
     if (DAOCliente.c != null)
     {
         return(c);
     }
     else
     {
         c = new DAOCliente();
         return(c);
     }
 }