예제 #1
0
        public Boolean P1Update(ModeloP1 o, int id, int estado)
        {
            var mysql = new DBConnection.ConexionMysql();

            if (estado > 1)
            {
                query = String.Format("SET SQL_SAFE_UPDATES=0; " +
                                      "UPDATE pat_p1 SET fkestado = '{0}' WHERE idp1 = '{1}'",
                                      estado, id);
            }
            else
            {
                query = String.Format("SET SQL_SAFE_UPDATES=0; " +
                                      "UPDATE pat_p1 SET col_uno='{0}', col_dos='{1}', col_tres='{2}', fkingreso_corriente='{3}' " +
                                      "WHERE idp1 = '{4}';",
                                      o.col1, o.col2, o.col3, o.fkingreso, id);
            }


            try
            {
                mysql.AbrirConexion();
                MySqlCommand cmd = new MySqlCommand(query, mysql.conectar);
                cmd.ExecuteNonQuery();
                mysql.CerrarConexion();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        public DataTable P1Create(ModeloP1 objCrear)
        {
            var       mysql = new DBConnection.ConexionMysql();
            DataTable dt    = new DataTable();

            query = String.Format("INSERT INTO pat_p1 (col_uno, col_dos, col_tres, fkingreso_corriente, fadn, ano) " +
                                  "VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}'); ",
                                  objCrear.col1, objCrear.col2, objCrear.col3, objCrear.fkingreso, objCrear.fadn, objCrear.ano);
            mysql.AbrirConexion();
            MySqlDataAdapter consulta = new MySqlDataAdapter(query, mysql.conectar);

            consulta.Fill(dt);
            mysql.CerrarConexion();
            return(dt);
        }