public bool Remove(EstatusInfo estatus, 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(estatus, 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(EstatusInfo estatus, SqlConnection oConn) { string sql = "DELETE FROM EstatusInformativo " + " WHERE (EstaInfoId = {0})"; sql = String.Format(sql, estatus.EstaInfoId); SqlCommand cmd = new SqlCommand(sql, oConn); int number = Convert.ToInt32(cmd.ExecuteNonQuery()); if (number > 0) { return(true); } return(false); }
public EstatusInfo Add(EstatusInfo estatus, 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; }; estatus.EstaInfoCreado = DateTime.Now; string sql = "INSERT INTO EstatusInformativo ({0}) VALUES ({1}) " + "SELECT SCOPE_IDENTITY()"; EnumExtension.setListValues(estatus, "EstaInfoId", 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); } EstatusInfo data = Get(keyGenerated, oConn); ConnManager.CloseConn(oConn); return(data); }
public EstatusInfo Get(int id, 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(null); }; EstatusInfo data = Get(id, oConn); ConnManager.CloseConn(oConn); return(data); }
public EstatusInfo Update(EstatusInfo estatus, 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; }; estatus.EstaInfoModificado = DateTime.Now; string sql = "UPDATE EstatusInformativo SET {0} WHERE EstaInfoId = " + estatus.EstaInfoId.ToString(); EnumExtension.setUpdateValues(estatus, "EstaInfoId", 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); } EstatusInfo data = Get(estatus.EstaInfoId, oConn); ConnManager.CloseConn(oConn); return(data); }