//---------------------------------------------------------------------------------------------- //Eliminar Fuente public String EliminarFuenteDAL(UTIL_Fuente utilFu) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("update_fuentes", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_nombre", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilFu.sNombre); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Insertar Material public String AgregarMaterialDAL(UTIL_Material utilMa) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("insert_materiales", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_asadafk", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMa.sAsada); postCommand.Parameters.Add("_material", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMa.sNombre); postCommand.Parameters.Add("_stock", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilMa.iStock); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Modificar Usuario public String ModificarUsuarioDAL(UTIL_Usuario utilUs) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("update_users", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_nick", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilUs.sUser); postCommand.Parameters.Add("_tipo", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilUs.iTipo); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Buscar Abonado por cedula public DataTable GetTarifaDALL() { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("Buscar_Tarifa", conn); postCommand.CommandType = CommandType.StoredProcedure; try { conn.Open(); postCommand.ExecuteNonQuery(); NpgsqlDataAdapter dta = new NpgsqlDataAdapter(postCommand); dta.Fill(ds); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conn.Close(); } if (ds.Tables.Count > 0) { return(ds.Tables[0]); } else { return(null); } }
//---------------------------------------------------------------------------------------------- //Eliminar Lectura public String ModificarLecturaDAL(UTIL_Lectura utilLe) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("update_lectura", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilLe.iMedidor); postCommand.Parameters.Add("_cantidad", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilLe.iLectura); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
public String TipoMedidorDALL(int medidor) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("Buscar_Tipo", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(medidor); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Llenar Combobox con public DataTable LlenarMedidorDAL() { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("LlenarCombo_Medidor", conn); postCommand.CommandType = CommandType.StoredProcedure; try { conn.Open(); postCommand.ExecuteNonQuery(); NpgsqlDataAdapter dta = new NpgsqlDataAdapter(postCommand); dta.Fill(ds); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conn.Close(); } if (ds.Tables.Count > 0) { return(ds.Tables[0]); } else { return(null); } }
//---------------------------------------------------------------------------------------------- //Modificar Arreglo public String ModificarArregloDAL(UTIL_Arreglo utilAr) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("update_arreglo", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_abonado", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAr.iCedula); postCommand.Parameters.Add("_monto", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAr.iMonto); postCommand.Parameters.Add("_abono", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAr.iAbono); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Buscar Arreglo por cedula public DataTable BuscarArregloDAL(UTIL_Arreglo utilAr) { DataSet ds = new DataSet(); ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("buscar_arreglo", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_cedula", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAr.iCedula); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); NpgsqlDataAdapter dta = new NpgsqlDataAdapter(postCommand); dta.Fill(ds); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conn.Close(); } if (ds.Tables.Count > 0) { return(ds.Tables[0]); } else { return(null); } }
//---------------------------------------------------------------------------------------------- //Insertar Medidor public String AgregarMedidorDAL(UTIL_Medidor utilMe) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("insert_abonado", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("asada_own", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMe.sAsada); postCommand.Parameters.Add("_cedula", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilMe.iCedula); postCommand.Parameters.Add("_id_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilMe.iIdMedidor); postCommand.Parameters.Add("_proveedor", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMe.sProveedor); postCommand.Parameters.Add("_garantia", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMe.sGarantia); postCommand.Parameters.Add("_marca", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMe.sMarca); postCommand.Parameters.Add("_ubicacion_x", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMe.sUbicacionX); postCommand.Parameters.Add("_ubicacion_y", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMe.sUbicacionY); postCommand.Parameters.Add("_tipo", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilMe.iTipo); postCommand.Parameters.Add("_estado", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilMe.iEstado); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Insertar Abonado public String AgregarAbonadoDAL(UTIL_Abonado utilAb) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("insert_abonado", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_cedula", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAb.iCedula); postCommand.Parameters.Add("_nombre", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilAb.sNombre); postCommand.Parameters.Add("_telefono", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAb.iTelefono); postCommand.Parameters.Add("_direccion", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilAb.sDireccion); postCommand.Parameters.Add("asada_local", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilAb.sAsada); postCommand.Parameters.Add("_estado", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAb.iEstado); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Insertar Asada public String AgregarAsadaDAL(UTIL_Asada utilAs) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("insert_asada", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_nombre", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilAs.sNombre); postCommand.Parameters.Add("_ubicacion_x", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilAs.sUbicacionX); postCommand.Parameters.Add("_ubicacion_y", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilAs.sUbicacionY); postCommand.Parameters.Add("_estado", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAs.iEstado); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }