public bool Remove(QuoteHeader data, 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 = RemoveHeader(data, 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 RemoveHeader(QuoteHeader data, SqlConnection oConn) { string sql = "DELETE FROM QuoteHeaders " + " WHERE (QHeaderKey = {0})"; sql = String.Format(sql, data.QHeaderKey); SqlCommand cmd = new SqlCommand(sql, oConn); int number = Convert.ToInt32(cmd.ExecuteNonQuery()); if (number > 0) { return(true); } return(false); }
public QuoteHeader Update(QuoteHeader data, 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; }; QuoteHeader oldData = Get(data.QHeaderKey, oConn); data.QHeaderModifiedDate = DateTime.Now; string sql = "UPDATE QuoteHeaders SET {0} WHERE QHeaderKey = @key"; EnumExtension.setUpdateValues(data, "QHeaderKey", ref sql); SqlCommand cmd = new SqlCommand(sql, oConn); cmd.Parameters.Add("@key", SqlDbType.Int).Value = data.QHeaderKey; 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); } QuoteHeader returnData = Get(data.QHeaderKey, oConn); ConnManager.CloseConn(oConn); return(returnData); }
public QuoteHeader Add(QuoteHeader data, 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; }; data.QHeaderCreatedDate = DateTime.Now; string sql = "INSERT INTO QuoteHeaders ({0}) VALUES ({1}) " + "SELECT SCOPE_IDENTITY()"; EnumExtension.setListValues(data, "QHeaderKey", 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); } QuoteHeader returnData = Get(keyGenerated, oConn); ConnManager.CloseConn(oConn); return(returnData); }
public QuoteHeader 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); }; QuoteHeader data = Get(id, oConn); ConnManager.CloseConn(oConn); return(data); }