Пример #1
0
        public bool WHS_PODetail_Update(IEnumerable <WHS_PODetail> items, string ModifiedBy)
        {
            string WHS_PODetail_List             = string.Empty;
            string WHS_PODetail_List_Serialized  = string.Empty;
            string WHS_PODetail_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (WHS_PODetail item in items)
                {
                    WHS_PODetail dbItem = model.DBSet_WHS_PODetail.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        WHS_PODetail_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.C_System_POStatus_ID = item.C_System_POStatus_ID;
                        dbItem.CreatedBy            = item.CreatedBy;
                        dbItem.CreatedDate          = item.CreatedDate;
                        dbItem.ID               = item.ID;
                        dbItem.IsDeleted        = item.IsDeleted;
                        dbItem.Item_ID          = item.Item_ID;
                        dbItem.ModifiedBy       = item.ModifiedBy;
                        dbItem.ModifiedDate     = item.ModifiedDate;
                        dbItem.Notes            = item.Notes;
                        dbItem.Oder_Line_No     = item.Oder_Line_No;
                        dbItem.Order_Line_No    = item.Order_Line_No;
                        dbItem.PO_ID            = item.PO_ID;
                        dbItem.ReceiptStatus_ID = item.ReceiptStatus_ID;
                        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;


                        WHS_PODetail_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        WHS_PODetail_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(WHS_PODetail_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + WHS_PODetail_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_PODetail_Update: {1} - {2}", ModifiedBy, WHS_PODetail_List, WHS_PODetail_List_Serialized));
            }
            return(flag);
        }
Пример #2
0
        public DataSourceResult WHS_PODetail_Create(WHS_PODetail item, string CreatedBy)
        {
            string WHS_PODetail_List             = string.Empty;
            string WHS_PODetail_List_Serialized  = string.Empty;
            string WHS_PODetail_Items_Serialized = string.Empty;

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

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

                WHS_PODetail dbItem = new WHS_PODetail();

                item.CreatedBy              = item.ModifiedBy = CreatedBy;
                item.CreatedDate            = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected           = item.IsSelected;
                dbItem.TagStr               = item.TagStr;
                dbItem.C_System_POStatus_ID = item.C_System_POStatus_ID;
                dbItem.CreatedBy            = item.CreatedBy;
                dbItem.CreatedDate          = item.CreatedDate;
                dbItem.ID                      = item.ID;
                dbItem.IsDeleted               = item.IsDeleted;
                dbItem.Item_ID                 = item.Item_ID;
                dbItem.ModifiedBy              = item.ModifiedBy;
                dbItem.ModifiedDate            = item.ModifiedDate;
                dbItem.Notes                   = item.Notes;
                dbItem.Oder_Line_No            = item.Oder_Line_No;
                dbItem.Order_Line_No           = item.Order_Line_No;
                dbItem.PO_ID                   = item.PO_ID;
                dbItem.ReceiptStatus_ID        = item.ReceiptStatus_ID;
                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;
                WHS_PODetail_Items_Serialized += Common.SerializeObject(item);
                model.DBSet_WHS_PODetail.Add(dbItem);
                Common.SaveChanges(model);

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

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