public static int Update(VaccinationQueue o, int id) { try { string query = @"UPDATE ""VACCINATION_QUEUE"" SET ""ID"" = " + o.Id + @", ""BARCODE_ID"" = '" + o.BarcodeId + @"', ""HEALTH_FACILITY_ID"" = " + o.HealthFacilityId + @", ""DATE"" = " + o.Date + @", ""USER_ID"" = " + o.UserId + @"WHERE ""ID"" = " + id; int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, null); Log.InsertEntity(2, "Success", id.ToString(), "VaccinationQueue", "Update"); return(rowAffected); } catch (Exception ex) { Log.InsertEntity("VaccinationQueue", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); } return(-1); }
public static int Insert(VaccinationQueue o) { try { string query = @"INSERT INTO ""VACCINATION_QUEUE"" (""BARCODE_ID"", ""HEALTH_FACILITY_ID"", ""DATE"", ""USER_ID"") VALUES ('" + o.BarcodeId + @"', " + o.HealthFacilityId + @", '" + o.Date + @"', " + o.UserId + @") returning ""ID"" "; object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, null); Log.InsertEntity(1, "Success", id.ToString(), "VaccinationQueue", "Insert"); return(int.Parse(id.ToString())); } catch (Exception ex) { Log.InsertEntity("VaccinationQueue", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); } return(-1); }
public static VaccinationQueue GetVaccinationQueueAsObject(DataTable dt) { foreach (DataRow row in dt.Rows) { try { VaccinationQueue o = new VaccinationQueue(); o.Id = Helper.ConvertToInt(row["ID"]); o.BarcodeId = row["BARCODE_ID"].ToString(); o.HealthFacilityId = Helper.ConvertToInt(row["HEALTH_FACILITY_ID"]); o.UserId = Helper.ConvertToInt(row["USER_ID"]); o.Date = Helper.ConvertToDate(row["DATE"]); return(o); } catch (Exception ex) { Log.InsertEntity("VaccinationQueue", "GetVaccinationQueueAsObject", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); throw ex; } } return(null); }