Пример #1
0
        public DataSourceResult WHS_Packing_List_Create(WHS_Packing_List item, string CreatedBy)
        {
            string WHS_Packing_List_List             = string.Empty;
            string WHS_Packing_List_List_Serialized  = string.Empty;
            string WHS_Packing_List_Items_Serialized = string.Empty;

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

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

                WHS_Packing_List dbItem = new WHS_Packing_List();

                item.CreatedBy                     = item.ModifiedBy = CreatedBy;
                item.CreatedDate                   = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected                  = item.IsSelected;
                dbItem.TagStr                      = item.TagStr;
                dbItem.Batch_Note                  = item.Batch_Note;
                dbItem.CreatedBy                   = item.CreatedBy;
                dbItem.CreatedDate                 = item.CreatedDate;
                dbItem.ID                          = item.ID;
                dbItem.IsDeleted                   = item.IsDeleted;
                dbItem.Kg_Note                     = item.Kg_Note;
                dbItem.Lot_No_Note                 = item.Lot_No_Note;
                dbItem.M3_Note                     = item.M3_Note;
                dbItem.ModifiedBy                  = item.ModifiedBy;
                dbItem.ModifiedDate                = item.ModifiedDate;
                dbItem.Pack_Note                   = item.Pack_Note;
                dbItem.Packing_List_Note_No        = item.Packing_List_Note_No;
                dbItem.Qty_Note                    = item.Qty_Note;
                dbItem.SO_Detail_ID                = item.SO_Detail_ID;
                WHS_Packing_List_Items_Serialized += Common.SerializeObject(item);
                model.DBSet_WHS_Packing_List.Add(dbItem);
                Common.SaveChanges(model);

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

                result.Add(item);
                WHS_Packing_List_List_Serialized += Common.SerializeObject(item);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Common.log.Error(WHS_Packing_List_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Common.log.Warn(CreatedBy + " => " + WHS_Packing_List_Items_Serialized, new Exception(message));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_Packing_List_Create: {1} - {2}", CreatedBy, WHS_Packing_List_List, WHS_Packing_List_List_Serialized));
            }
            return(result.ToDataSourceResult(new DataSourceRequest()));
        }
Пример #2
0
        public bool WHS_Packing_List_Update(IEnumerable <WHS_Packing_List> items, string ModifiedBy)
        {
            string WHS_Packing_List_List             = string.Empty;
            string WHS_Packing_List_List_Serialized  = string.Empty;
            string WHS_Packing_List_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (WHS_Packing_List item in items)
                {
                    WHS_Packing_List dbItem = model.DBSet_WHS_Packing_List.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        WHS_Packing_List_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.Batch_Note           = item.Batch_Note;
                        dbItem.CreatedBy            = item.CreatedBy;
                        dbItem.CreatedDate          = item.CreatedDate;
                        dbItem.ID                   = item.ID;
                        dbItem.IsDeleted            = item.IsDeleted;
                        dbItem.Kg_Note              = item.Kg_Note;
                        dbItem.Lot_No_Note          = item.Lot_No_Note;
                        dbItem.M3_Note              = item.M3_Note;
                        dbItem.ModifiedBy           = item.ModifiedBy;
                        dbItem.ModifiedDate         = item.ModifiedDate;
                        dbItem.Pack_Note            = item.Pack_Note;
                        dbItem.Packing_List_Note_No = item.Packing_List_Note_No;
                        dbItem.Qty_Note             = item.Qty_Note;
                        dbItem.SO_Detail_ID         = item.SO_Detail_ID;


                        WHS_Packing_List_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        WHS_Packing_List_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(WHS_Packing_List_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + WHS_Packing_List_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_Packing_List_Update: {1} - {2}", ModifiedBy, WHS_Packing_List_List, WHS_Packing_List_List_Serialized));
            }
            return(flag);
        }