public bool Remove(GastosGrupoItem cliente, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(false); }; bool result; try { result = Remove(cliente, oConn); } catch (Exception ex) { ConnManager.CloseConn(oConn); LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); return(false); } ConnManager.CloseConn(oConn); return(result); }
private bool Remove(GastosGrupoItem cliente, SqlConnection oConn) { string sql = "DELETE FROM GastosGruposItems " + " WHERE (GGrupoItemId = {0})"; sql = String.Format(sql, cliente.GGrupoItemId); SqlCommand cmd = new SqlCommand(sql, oConn); int number = Convert.ToInt32(cmd.ExecuteNonQuery()); if (number > 0) { return(true); } return(false); }
public GastosGrupoItem Add(GastosGrupoItem cliente, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); throw; }; string sql = "INSERT INTO GastosGruposItems ({0}) VALUES ({1}) " + "SELECT SCOPE_IDENTITY()"; cliente.GGrupoItemCreado = DateTime.Now; EnumExtension.setListValues(cliente, "GGrupoItemId", ref sql); SqlCommand cmd = new SqlCommand(sql, oConn); int keyGenerated = 0; try { keyGenerated = Convert.ToInt32(cmd.ExecuteScalar()); } catch (Exception ex) { ConnManager.CloseConn(oConn); LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(null); } GastosGrupoItem data = Get(keyGenerated, oConn); ConnManager.CloseConn(oConn); return(data); }
public GastosGrupoItem Get(int id) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); throw; }; GastosGrupoItem data = Get(id, oConn); ConnManager.CloseConn(oConn); return(data); }
public GastosGrupoItem Update(GastosGrupoItem cliente, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); throw; }; string sql = "UPDATE GastosGruposItems SET {0} WHERE GGrupoItemId = " + cliente.GGrupoItemId.ToString(); EnumExtension.setUpdateValues(cliente, "GGrupoItemId", ref sql); SqlCommand cmd = new SqlCommand(sql, oConn); try { cmd.ExecuteNonQuery(); } catch (Exception ex) { ConnManager.CloseConn(oConn); LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(null); } GastosGrupoItem data = Get(cliente.GGrupoItemId, oConn); ConnManager.CloseConn(oConn); return(data); }