public int SetReferto(RefertoVO data) { int result = 0; Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); string table = this.RefertoTabName; try { string connectionString = this.GRConnectionString; string refeidid = data.refeidid.HasValue ? data.refeidid.Value.ToString() : null; if (refeidid == null) { // INSERT NUOVA result = DBSQL.InsertOperation(connectionString, table, data); log.Info(string.Format("Inserted {0} new records!", result)); } else { // UPDATE Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "REFEIDID", Value = refeidid, Op = DBSQL.Op.Equal, Conj = DBSQL.Conj.None, } }, }; result = DBSQL.UpdateOperation(connectionString, table, data, conditions); log.Info(string.Format("Updated {0} records!", result)); } } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(result); }
public RefertoVO GetRefertoById(string refeidid) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); RefertoVO refe = null; try { string connectionString = this.GRConnectionString; int refeidid_ = int.Parse(refeidid); string table = this.RefertoTabName; Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "refeidid", Op = DBSQL.Op.Equal, Value = refeidid_, Conj = DBSQL.Conj.None } } }; DataTable data = DBSQL.SelectOperation(connectionString, table, conditions); log.Info(string.Format("DBSQL Query Executed! Retrieved {0} record!", LibString.ItemsNumber(data))); if (data != null) { if (data.Rows.Count == 1) { refe = RefertoMapper.RefeMapper(data.Rows[0]); log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(refe), LibString.TypeName(refe))); } } } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(refe); }