コード例 #1
0
        public static List <HealthFacilityBalance> GetHealthFacilityBalanceAsList(DataTable dt)
        {
            List <HealthFacilityBalance> oList = new List <HealthFacilityBalance>();

            foreach (DataRow row in dt.Rows)
            {
                try
                {
                    HealthFacilityBalance o = new HealthFacilityBalance();
                    o.HealthFacilityCode = row["HEALTH_FACILITY_CODE"].ToString();
                    o.Gtin        = row["GTIN"].ToString();
                    o.LotNumber   = row["LOT_NUMBER"].ToString();
                    o.Received    = Helper.ConvertToDecimal(row["RECEIVED"]);
                    o.Distributed = Helper.ConvertToDecimal(row["DISTRIBUTED"]);
                    o.Used        = Helper.ConvertToDecimal(row["USED"]);
                    o.Wasted      = Helper.ConvertToDecimal(row["WASTED"]);
                    o.StockCount  = Helper.ConvertToDecimal(row["STOCK_COUNT"]);
                    o.Balance     = Helper.ConvertToDecimal(row["BALANCE"]);
                    o.Allocated   = Helper.ConvertToDecimal(row["ALLOCATED"]);
                    oList.Add(o);
                }
                catch (Exception ex)
                {
                    Log.InsertEntity("HealthFacilityBalance", "GetHealthFacilityBalanceAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                    throw ex;
                }
            }
            return(oList);
        }
コード例 #2
0
 public static int Update(HealthFacilityBalance o)
 {
     try
     {
         string query = @"UPDATE ""HEALTH_FACILITY_BALANCE"" SET ""RECEIVED"" = @Received, ""DISTRIBUTED"" = @Distributed, ""USED"" = @Used, ""WASTED"" = @Wasted, ""STOCK_COUNT"" = @StockCount, ""BALANCE"" = @Balance, ""ALLOCATED"" = @Allocated WHERE ""HEALTH_FACILITY_CODE"" = @HealthFacilityCode AND ""GTIN"" = @Gtin AND ""LOT_NUMBER"" = @LotNumber  ";
         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("@LotNumber", DbType.String)
             {
                 Value = o.LotNumber
             },
             new NpgsqlParameter("@Received", DbType.Double)
             {
                 Value = (object)o.Received ?? DBNull.Value
             },
             new NpgsqlParameter("@Distributed", DbType.Double)
             {
                 Value = (object)o.Distributed ?? DBNull.Value
             },
             new NpgsqlParameter("@Used", DbType.Double)
             {
                 Value = (object)o.Used ?? DBNull.Value
             },
             new NpgsqlParameter("@Wasted", DbType.Double)
             {
                 Value = (object)o.Wasted ?? DBNull.Value
             },
             new NpgsqlParameter("@StockCount", DbType.Double)
             {
                 Value = (object)o.StockCount ?? DBNull.Value
             },
             new NpgsqlParameter("@Balance", DbType.Double)
             {
                 Value = (object)o.Balance ?? DBNull.Value
             },
             new NpgsqlParameter("@Allocated", DbType.Double)
             {
                 Value = (object)o.Allocated ?? DBNull.Value
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("HealthFacilityBalance", string.Format("RecordId: {0}", o.HealthFacilityCode + o.Gtin + o.LotNumber), 2, DateTime.Now, 1);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("HealthFacilityBalance", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
コード例 #3
0
 public static int Insert(HealthFacilityBalance o)
 {
     try
     {
         string query = @"INSERT INTO ""HEALTH_FACILITY_BALANCE"" (""HEALTH_FACILITY_CODE"", ""GTIN"", ""LOT_NUMBER"", ""RECEIVED"", ""DISTRIBUTED"", ""USED"", ""WASTED"", ""STOCK_COUNT"", ""BALANCE"", ""ALLOCATED"") VALUES (@HealthFacilityCode, @Gtin, @LotNumber, @Received, @Distributed, @Used, @Wasted, @StockCount, @Balance, @Allocated) returning ""HEALTH_FACILITY_CODE"" || ""GTIN"" || ""LOT_NUMBER"" ";
         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("@LotNumber", DbType.String)
             {
                 Value = o.LotNumber
             },
             new NpgsqlParameter("@Received", DbType.Double)
             {
                 Value = (object)o.Received ?? DBNull.Value
             },
             new NpgsqlParameter("@Distributed", DbType.Double)
             {
                 Value = (object)o.Distributed ?? DBNull.Value
             },
             new NpgsqlParameter("@Used", DbType.Double)
             {
                 Value = (object)o.Used ?? DBNull.Value
             },
             new NpgsqlParameter("@Wasted", DbType.Double)
             {
                 Value = (object)o.Wasted ?? DBNull.Value
             },
             new NpgsqlParameter("@StockCount", DbType.Double)
             {
                 Value = (object)o.StockCount ?? DBNull.Value
             },
             new NpgsqlParameter("@Balance", DbType.Double)
             {
                 Value = (object)o.Balance ?? DBNull.Value
             },
             new NpgsqlParameter("@Allocated", DbType.Double)
             {
                 Value = (object)o.Allocated ?? DBNull.Value
             }
         };
         object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("HealthFacilityBalance", id.ToString(), 1, DateTime.Now, 1);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("HealthFacilityBalance", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }