Exemplo n.º 1
0
        public bool ENT_Item_Update(IEnumerable <ENT_Item> items, string ModifiedBy)
        {
            string ENT_Item_List             = string.Empty;
            string ENT_Item_List_Serialized  = string.Empty;
            string ENT_Item_Items_Serialized = string.Empty;

            string result = string.Empty;
            bool   flag   = true;

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (ENT_Item item in items)
                {
                    ENT_Item dbItem = model.DBSet_ENT_Item.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        ENT_Item_List    += "[" + item.ID + "] ";
                        item.ModifiedBy   = ModifiedBy;
                        item.ModifiedDate = Common.getUTCDate();
                        if (item.CreatedDate == DateTime.MinValue)
                        {
                            item.CreatedDate = dbItem.CreatedDate;
                        }
                        dbItem.IsSelected             = item.IsSelected;
                        dbItem.TagStr                 = item.TagStr;
                        dbItem.Allocation_Strategy_Id = item.Allocation_Strategy_Id;
                        dbItem.Batch_No               = item.Batch_No;
                        dbItem.C_System_Itemtype      = item.C_System_Itemtype;
                        dbItem.Carton_ID              = item.Carton_ID;
                        dbItem.Code_UOM_ID            = item.Code_UOM_ID;
                        dbItem.CreatedBy              = item.CreatedBy;
                        dbItem.CreatedDate            = item.CreatedDate;
                        dbItem.Cube                = item.Cube;
                        dbItem.CycleClass_ID       = item.CycleClass_ID;
                        dbItem.Gross_weight        = item.Gross_weight;
                        dbItem.ID                  = item.ID;
                        dbItem.IsDeleted           = item.IsDeleted;
                        dbItem.Item_Code           = item.Item_Code;
                        dbItem.Item_Description    = item.Item_Description;
                        dbItem.ItemtypeDetail_ID   = item.ItemtypeDetail_ID;
                        dbItem.Last_cycle_count    = item.Last_cycle_count;
                        dbItem.Location_ID         = item.Location_ID;
                        dbItem.Lot_No              = item.Lot_No;
                        dbItem.ModifiedBy          = item.ModifiedBy;
                        dbItem.ModifiedDate        = item.ModifiedDate;
                        dbItem.Net_weight          = item.Net_weight;
                        dbItem.Notes               = item.Notes;
                        dbItem.Owner_Id            = item.Owner_Id;
                        dbItem.Pack_Id             = item.Pack_Id;
                        dbItem.Putaway_Strategy_Id = item.Putaway_Strategy_Id;
                        dbItem.RotatebyDetail_ID   = item.RotatebyDetail_ID;
                        dbItem.RotationDetail_ID   = item.RotationDetail_ID;
                        dbItem.Tare_weight         = item.Tare_weight;
                        dbItem.To_Best_By_Day      = item.To_Best_By_Day;
                        dbItem.To_Deliver_By_Days  = item.To_Deliver_By_Days;
                        dbItem.To_Expire_Days      = item.To_Expire_Days;
                        dbItem.UDF_1               = item.UDF_1;
                        dbItem.UDF_2               = item.UDF_2;
                        dbItem.UDF_3               = item.UDF_3;
                        dbItem.UDF_4               = item.UDF_4;
                        dbItem.UDF_5               = item.UDF_5;
                        dbItem.V_CycleCount_ID     = item.V_CycleCount_ID;
                        dbItem.V_Lot_ID            = item.V_Lot_ID;
                        dbItem.V_Receipt_ID        = item.V_Receipt_ID;
                        dbItem.Zone_Id             = item.Zone_Id;


                        ENT_Item_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        ENT_Item_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(ENT_Item_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + ENT_Item_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_Item_Update: {1} - {2}", ModifiedBy, ENT_Item_List, ENT_Item_List_Serialized));
            }
            return(flag);
        }
Exemplo n.º 2
0
        public DataSourceResult ENT_Item_Create(ENT_Item item, string CreatedBy)
        {
            string ENT_Item_List             = string.Empty;
            string ENT_Item_List_Serialized  = string.Empty;
            string ENT_Item_Items_Serialized = string.Empty;

            string          message = string.Empty;
            List <ENT_Item> result  = new List <ENT_Item>();

            try
            {
                WMS.Models.DBContext model = new DBContext();

                ENT_Item dbItem = new ENT_Item();

                item.CreatedBy                = item.ModifiedBy = CreatedBy;
                item.CreatedDate              = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected             = item.IsSelected;
                dbItem.TagStr                 = item.TagStr;
                dbItem.Allocation_Strategy_Id = item.Allocation_Strategy_Id;
                dbItem.Batch_No               = item.Batch_No;
                dbItem.C_System_Itemtype      = item.C_System_Itemtype;
                dbItem.Carton_ID              = item.Carton_ID;
                dbItem.Code_UOM_ID            = item.Code_UOM_ID;
                dbItem.CreatedBy              = item.CreatedBy;
                dbItem.CreatedDate            = item.CreatedDate;
                dbItem.Cube                = item.Cube;
                dbItem.CycleClass_ID       = item.CycleClass_ID;
                dbItem.Gross_weight        = item.Gross_weight;
                dbItem.ID                  = item.ID;
                dbItem.IsDeleted           = item.IsDeleted;
                dbItem.Item_Code           = item.Item_Code;
                dbItem.Item_Description    = item.Item_Description;
                dbItem.ItemtypeDetail_ID   = item.ItemtypeDetail_ID;
                dbItem.Last_cycle_count    = item.Last_cycle_count;
                dbItem.Location_ID         = item.Location_ID;
                dbItem.Lot_No              = item.Lot_No;
                dbItem.ModifiedBy          = item.ModifiedBy;
                dbItem.ModifiedDate        = item.ModifiedDate;
                dbItem.Net_weight          = item.Net_weight;
                dbItem.Notes               = item.Notes;
                dbItem.Owner_Id            = item.Owner_Id;
                dbItem.Pack_Id             = item.Pack_Id;
                dbItem.Putaway_Strategy_Id = item.Putaway_Strategy_Id;
                dbItem.RotatebyDetail_ID   = item.RotatebyDetail_ID;
                dbItem.RotationDetail_ID   = item.RotationDetail_ID;
                dbItem.Tare_weight         = item.Tare_weight;
                dbItem.To_Best_By_Day      = item.To_Best_By_Day;
                dbItem.To_Deliver_By_Days  = item.To_Deliver_By_Days;
                dbItem.To_Expire_Days      = item.To_Expire_Days;
                dbItem.UDF_1               = item.UDF_1;
                dbItem.UDF_2               = item.UDF_2;
                dbItem.UDF_3               = item.UDF_3;
                dbItem.UDF_4               = item.UDF_4;
                dbItem.UDF_5               = item.UDF_5;
                dbItem.V_CycleCount_ID     = item.V_CycleCount_ID;
                dbItem.V_Lot_ID            = item.V_Lot_ID;
                dbItem.V_Receipt_ID        = item.V_Receipt_ID;
                dbItem.Zone_Id             = item.Zone_Id;
                ENT_Item_Items_Serialized += Common.SerializeObject(item);
                model.DBSet_ENT_Item.Add(dbItem);
                Common.SaveChanges(model);

                item.ID        = dbItem.ID;
                ENT_Item_List += "[" + item.ID + "] ";

                result.Add(item);
                ENT_Item_List_Serialized += Common.SerializeObject(item);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Common.log.Error(ENT_Item_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Common.log.Warn(CreatedBy + " => " + ENT_Item_Items_Serialized, new Exception(message));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_Item_Create: {1} - {2}", CreatedBy, ENT_Item_List, ENT_Item_List_Serialized));
            }
            return(result.ToDataSourceResult(new DataSourceRequest()));
        }