public bool UpdateCorreo(Ytbl_CondicionesCorte model) { Connection conn = new Connection(); OleDbConnection objConn = conn.Conn(); try { // Calling sp_processdata defined inside PKG PKG_MANAGER string commText = "YPKG_WEBCORTES.YPRD_UPDATECONNOCORT"; objConn.Open(); OleDbCommand cmd = new OleDbCommand(commText, objConn); cmd.CommandType = CommandType.StoredProcedure; OleDbParameter Id = new OleDbParameter("PN_ID_CORTE", OleDbType.Integer); Id.Direction = ParameterDirection.Input; Id.Value = model.Id; cmd.Parameters.Add(Id); OleDbParameter IsValid = new OleDbParameter("PV_ISVALID", OleDbType.VarChar); IsValid.Direction = ParameterDirection.Input; IsValid.Value = model.IsValid; cmd.Parameters.Add(IsValid); cmd.ExecuteNonQuery(); objConn.Close(); return(true); } catch (Exception ex) { Logs.WriteErrorLog("Error en update: " + ex.ToString()); objConn.Close(); return(false); } finally { objConn.Close(); } }
public bool SaveCondicionesCorte(Ytbl_CondicionesCorte CondicionesCorte) { Connection conn = new Connection(); OleDbConnection objConn = conn.Conn(); try { // Calling sp_processdata defined inside PKG PKG_MANAGER string commText = "YPKG_WEBCORTES.YPRD_INSERTCONNOCORT"; objConn.Open(); OleDbCommand cmd = new OleDbCommand(commText, objConn); cmd.CommandType = CommandType.StoredProcedure; OleDbParameter Provider = new OleDbParameter("PV_PROVIDER", OleDbType.VarChar); Provider.Direction = ParameterDirection.Input; Provider.Value = CondicionesCorte.Provider; cmd.Parameters.Add(Provider); OleDbParameter Ciudad = new OleDbParameter("PV_CITY", OleDbType.VarChar); Ciudad.Direction = ParameterDirection.Input; Ciudad.Value = CondicionesCorte.Ciudad; cmd.Parameters.Add(Ciudad); OleDbParameter PaymentMode = new OleDbParameter("PV_PAYMENTMODE", OleDbType.VarChar); PaymentMode.Direction = ParameterDirection.Input; PaymentMode.Value = CondicionesCorte.PaymentMode; cmd.Parameters.Add(PaymentMode); OleDbParameter Business = new OleDbParameter("PV_BUSINESS", OleDbType.VarChar); Business.Direction = ParameterDirection.Input; Business.Value = CondicionesCorte.Business; cmd.Parameters.Add(Business); OleDbParameter Company = new OleDbParameter("PV_COMPANY", OleDbType.VarChar); Company.Direction = ParameterDirection.Input; Company.Value = CondicionesCorte.Company; cmd.Parameters.Add(Company); OleDbParameter Id_Corte = new OleDbParameter("PN_ID_CORTE", OleDbType.Integer); Id_Corte.Direction = ParameterDirection.Input; Id_Corte.Value = CondicionesCorte.Id_Corte; cmd.Parameters.Add(Id_Corte); OleDbParameter IsValid = new OleDbParameter("PV_ISVALID", OleDbType.VarChar); IsValid.Direction = ParameterDirection.Input; IsValid.Value = CondicionesCorte.IsValid; cmd.Parameters.Add(IsValid); OleDbParameter Usuario = new OleDbParameter("PV_APPUSER", OleDbType.VarChar); Usuario.Direction = ParameterDirection.Input; Usuario.Value = CondicionesCorte.Usuario; cmd.Parameters.Add(Usuario); cmd.ExecuteNonQuery(); objConn.Close(); return(true); } catch (Exception ex) { Logs.WriteErrorLog("Error en insert: " + ex.ToString()); objConn.Close(); return(false); } finally { objConn.Close(); } }
public Ytbl_CondicionesCorte SelectCondicionesCorteById(int id) { Connection conn = new Connection(); OleDbConnection objConn = conn.Conn(); string commText = "select * from YTBL_CONDICIONESNOCORTE where id =" + id; objConn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = objConn; cmd.CommandText = commText; cmd.CommandType = CommandType.Text; OleDbDataReader myReader = cmd.ExecuteReader(); int RecordCount = 0; Ytbl_CondicionesCorte CondicionCorte = new Ytbl_CondicionesCorte(); try { if (myReader.HasRows) { while (myReader.Read()) { RecordCount++; CondicionCorte.Id = int.Parse(myReader.GetDecimal(0).ToString()); try { CondicionCorte.Provider = myReader.GetString(1).ToString(); } catch (Exception ex) { CondicionCorte.Provider = null; } try { CondicionCorte.Ciudad = myReader.GetString(2).ToString(); } catch (Exception ex) { CondicionCorte.Ciudad = null; } try { CondicionCorte.PaymentMode = myReader.GetString(3).ToString(); } catch (Exception ex) { CondicionCorte.PaymentMode = null; } try { CondicionCorte.Business = myReader.GetString(4).ToString(); } catch (Exception ex) { CondicionCorte.Business = null; } try { CondicionCorte.Company = myReader.GetString(5).ToString(); } catch (Exception ex) { CondicionCorte.Company = null; } CondicionCorte.Id_Corte = Int32.Parse(myReader.GetDecimal(6).ToString()); try { CondicionCorte.Fecha = DateTime.Parse(myReader.GetDateTime(7).ToString()); } catch (Exception ex) { CondicionCorte.Fecha = null; } CondicionCorte.IsValid = myReader.GetString(8).ToString(); CondicionCorte.Usuario = myReader.GetString(9).ToString(); } } return(CondicionCorte); } catch (Exception ex) { myReader.Close(); objConn.Close(); Logs.WriteErrorLog("Error en la consulta de datos por ID||" + ex.ToString()); return(CondicionCorte); } finally { myReader.Close(); objConn.Close(); } }
public List <Estadisticas> getStadistic(int id, string parameter) { conn = new Connection(); OleDbConnection objConn = conn.Conn(); string commText = ""; switch (parameter) { case "BANCO": commText = "select count(*), banco from (select distinct(CPARTYACCOUNT_ID), banco from YTBL_DETALLEPROGCORTE where ID_PROGCORTE = " + id + ") group by banco"; break; case "CIUDAD": commText = "select count(*), CIUDAD from (select distinct(CPARTYACCOUNT_ID), CIUDAD from YTBL_DETALLEPROGCORTE where ID_PROGCORTE = " + id + ") GROUP BY CIUDAD"; break; case "BUSINESS": commText = "select count(*), BUSINESS from (select distinct(CPARTYACCOUNT_ID), BUSINESS from YTBL_DETALLEPROGCORTE where ID_PROGCORTE = " + id + ") GROUP BY BUSINESS"; break; case "COMPANY": commText = "select count(*), COMPANY from (select distinct(CPARTYACCOUNT_ID), COMPANY from YTBL_DETALLEPROGCORTE where ID_PROGCORTE = " + id + " ) GROUP BY COMPANY"; break; case "CUENTAS": commText = "select COUNT(distinct CPARTYACCOUNT_ID), 'Cuentas' from YTBL_DETALLEPROGCORTE where ID_PROGCORTE = " + id; break; } objConn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = objConn; cmd.CommandText = commText; cmd.CommandType = CommandType.Text; OleDbDataReader myReader = cmd.ExecuteReader(); List <Estadisticas> ListEstadictica = new List <Estadisticas>(); Ytbl_CondicionesCorte condicion = new Ytbl_CondicionesCorte(); try { if (myReader.HasRows) { while (myReader.Read()) { Estadisticas estadistica = new Estadisticas(); try { if (parameter == "CIUDAD") { estadistica.cantidad = int.Parse(myReader.GetDecimal(0).ToString()); if (myReader.GetValue(1).ToString() != "") { estadistica.nombre = condicion.getNameProperty(myReader.GetValue(1).ToString(), "CIUDAD"); } else { estadistica.nombre = "Ninguno"; } } else { estadistica.cantidad = int.Parse(myReader.GetDecimal(0).ToString()); if (myReader.GetValue(1).ToString() != "") { estadistica.nombre = myReader.GetValue(1).ToString(); } else { estadistica.nombre = "Ninguno"; } } } catch (Exception ex) { estadistica.nombre = "Ninguno"; } ListEstadictica.Add(estadistica); } } return(ListEstadictica); } catch (Exception ex) { myReader.Close(); objConn.Close(); Logs.WriteErrorLog("Error en la consulta de datos por ID||" + ex.ToString()); return(ListEstadictica); } finally { myReader.Close(); objConn.Close(); } }