public static List <GtinHfStockPolicy> GetGtinHfStockPolicyAsList(DataTable dt) { List <GtinHfStockPolicy> oList = new List <GtinHfStockPolicy>(); foreach (DataRow row in dt.Rows) { try { GtinHfStockPolicy o = new GtinHfStockPolicy(); o.HealthFacilityCode = row["HEALTH_FACILITY_CODE"].ToString(); o.Gtin = row["GTIN"].ToString(); o.ReorderQty = Helper.ConvertToDecimal(row["REORDER_QTY"]); o.SafetyStock = Helper.ConvertToDecimal(row["SAFETY_STOCK"]); o.AvgDailyDemandRate = Helper.ConvertToDecimal(row["AVG_DAILY_DEMAND_RATE"]); o.ConsumptionLogic = row["CONSUMPTION_LOGIC"].ToString(); o.LeadTime = Helper.ConvertToInt(row["LEAD_TIME"]); o.ForecastPeriodDemand = Helper.ConvertToDecimal(row["FORECAST_PERIOD_DEMAND"]); o.Notes = row["NOTES"].ToString(); oList.Add(o); } catch (Exception ex) { Log.InsertEntity("GtinHfStockPolicy", "GetGtinHfStockPolicyAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); throw ex; } } return(oList); }
public static int Update(GtinHfStockPolicy o) { try { string query = @"UPDATE ""GTIN_HF_STOCK_POLICY"" SET ""REORDER_QTY"" = @ReorderQty, ""SAFETY_STOCK"" = @SafetyStock, ""AVG_DAILY_DEMAND_RATE"" = @AvgDailyDemandRate, ""CONSUMPTION_LOGIC"" = @ConsumptionLogic, ""LEAD_TIME"" = @LeadTime, ""FORECAST_PERIOD_DEMAND"" = @ForecastPeriodDemand, ""NOTES"" = @Notes WHERE ""HEALTH_FACILITY_CODE"" = @HealthFacilityCode and ""GTIN"" = @Gtin "; List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>() { new NpgsqlParameter("@HealthFacilityCode", DbType.String) { Value = o.HealthFacilityCode }, new NpgsqlParameter("@Gtin", DbType.String) { Value = o.Gtin }, new NpgsqlParameter("@ReorderQty", DbType.Double) { Value = (object)o.ReorderQty ?? DBNull.Value }, new NpgsqlParameter("@SafetyStock", DbType.Double) { Value = (object)o.SafetyStock ?? DBNull.Value }, new NpgsqlParameter("@AvgDailyDemandRate", DbType.Double) { Value = (object)o.AvgDailyDemandRate ?? DBNull.Value }, new NpgsqlParameter("@ConsumptionLogic", DbType.String) { Value = (object)o.ConsumptionLogic ?? DBNull.Value }, new NpgsqlParameter("@LeadTime", DbType.Int32) { Value = (object)o.LeadTime ?? DBNull.Value }, new NpgsqlParameter("@ForecastPeriodDemand", DbType.Double) { Value = (object)o.ForecastPeriodDemand ?? DBNull.Value }, new NpgsqlParameter("@Notes", DbType.String) { Value = (object)o.Notes ?? DBNull.Value }, new NpgsqlParameter("@Gtin", DbType.String) { Value = o.Gtin } }; int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters); // AuditTable.InsertEntity("GtinHfStockPolicy", string.Format("RecordId: {0}", o.Gtin), 2, DateTime.Now, 1); return(rowAffected); } catch (Exception ex) { Log.InsertEntity("GtinHfStockPolicy", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); } return(-1); }
public static int Insert(GtinHfStockPolicy o) { try { string query = @"INSERT INTO ""GTIN_HF_STOCK_POLICY"" (""HEALTH_FACILITY_CODE"", ""GTIN"", ""REORDER_QTY"", ""SAFETY_STOCK"", ""AVG_DAILY_DEMAND_RATE"", ""CONSUMPTION_LOGIC"", ""LEAD_TIME"", ""FORECAST_PERIOD_DEMAND"", ""NOTES"") VALUES (@HealthFacilityCode, @Gtin, @ReorderQty, @SafetyStock, @AvgDailyDemandRate, @ConsumptionLogic, @LeadTime, @ForecastPeriodDemand, @Notes) returning ""HEALTH_FACILITY_CODE"" || ""GTIN"" "; List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>() { new NpgsqlParameter("@HealthFacilityCode", DbType.String) { Value = o.HealthFacilityCode }, new NpgsqlParameter("@Gtin", DbType.String) { Value = o.Gtin }, new NpgsqlParameter("@ReorderQty", DbType.Double) { Value = (object)o.ReorderQty ?? DBNull.Value }, new NpgsqlParameter("@SafetyStock", DbType.Double) { Value = (object)o.SafetyStock ?? DBNull.Value }, new NpgsqlParameter("@AvgDailyDemandRate", DbType.Double) { Value = (object)o.AvgDailyDemandRate ?? DBNull.Value }, new NpgsqlParameter("@ConsumptionLogic", DbType.String) { Value = (object)o.ConsumptionLogic ?? DBNull.Value }, new NpgsqlParameter("@LeadTime", DbType.Int32) { Value = (object)o.LeadTime ?? DBNull.Value }, new NpgsqlParameter("@ForecastPeriodDemand", DbType.Double) { Value = (object)o.ForecastPeriodDemand ?? DBNull.Value }, new NpgsqlParameter("@Notes", DbType.String) { Value = (object)o.Notes ?? DBNull.Value } }; object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters); //AuditTable.InsertEntity("GtinHfStockPolicy", id.ToString(), 1, DateTime.Now, 1); return(1);// int.Parse(id.ToString()); } catch (Exception ex) { Log.InsertEntity("GtinHfStockPolicy", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); } return(-1); }