예제 #1
0
        public static List <ItemLot> GetItemLotAsList(DataTable dt)
        {
            List <ItemLot> oList = new List <ItemLot>();

            foreach (DataRow row in dt.Rows)
            {
                try
                {
                    ItemLot o = new ItemLot();
                    o.Gtin       = row["GTIN"].ToString();
                    o.LotNumber  = row["LOT_NUMBER"].ToString();
                    o.ItemId     = Helper.ConvertToInt(row["ITEM_ID"]);
                    o.Id         = Helper.ConvertToInt(row["ID"]);
                    o.ExpireDate = Helper.ConvertToDate(row["EXPIRE_DATE"]);
                    o.Notes      = row["NOTES"].ToString();
                    o.IsActive   = Helper.ConvertToBoolean(row["IS_ACTIVE"]);
                    oList.Add(o);
                }
                catch (Exception ex)
                {
                    Log.InsertEntity("ItemLot", "GetItemLotAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                    throw ex;
                }
            }
            return(oList);
        }
예제 #2
0
 public static int Update(ItemLot o)
 {
     try
     {
         string query = @"UPDATE ""ITEM_LOT"" SET ""ITEM_ID"" = @ItemId, ""EXPIRE_DATE"" = @ExpireDate, ""NOTES"" = @Notes WHERE ""GTIN"" = @Gtin AND ""LOT_NUMBER"" = @LotNumber ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Gtin", DbType.String)
             {
                 Value = o.Gtin
             },
             new NpgsqlParameter("@LotNumber", DbType.String)
             {
                 Value = o.LotNumber
             },
             new NpgsqlParameter("@ItemId", DbType.Int32)
             {
                 Value = o.ItemId
             },
             new NpgsqlParameter("@ExpireDate", DbType.Date)
             {
                 Value = o.ExpireDate
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("ItemLot", o.Gtin + o.LotNumber, 2, DateTime.Now, 1);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ItemLot", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
예제 #3
0
 public static int Insert(ItemLot o)
 {
     try
     {
         string query = @"INSERT INTO ""ITEM_LOT"" (""GTIN"", ""LOT_NUMBER"", ""ITEM_ID"", ""EXPIRE_DATE"", ""NOTES"") VALUES (@Gtin, @LotNumber, @ItemId, @ExpireDate, @Notes) returning ""GTIN"" || ""LOT_NUMBER"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Gtin", DbType.String)
             {
                 Value = o.Gtin
             },
             new NpgsqlParameter("@LotNumber", DbType.String)
             {
                 Value = o.LotNumber
             },
             new NpgsqlParameter("@ItemId", DbType.Int32)
             {
                 Value = o.ItemId
             },
             new NpgsqlParameter("@ExpireDate", DbType.Date)
             {
                 Value = o.ExpireDate
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             }
         };
         object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("ItemLot", o.Gtin + o.LotNumber, 1, DateTime.Now, 1);
         return(1);// int.Parse(id.ToString());
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ItemLot", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }