Example #1
0
 public ENT_Delivery_Note ENT_Delivery_Note_GetByID(int ID)
 {
     WMS.Models.DBContext model = new DBContext();
     return(model.DBSet_ENT_Delivery_Note.Where(d => d.ID == ID).FirstOrDefault <ENT_Delivery_Note>());
 }
Example #2
0
        public DataSourceResult WHS_SO_Detail_Create(IEnumerable <WHS_SO_Detail> items, string CreatedBy)
        {
            string WHS_SO_Detail_List             = string.Empty;
            string WHS_SO_Detail_List_Serialized  = string.Empty;
            string WHS_SO_Detail_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (WHS_SO_Detail item in items)
                {
                    WHS_SO_Detail dbItem = new WHS_SO_Detail();

                    item.CreatedBy            = item.ModifiedBy = CreatedBy;
                    item.CreatedDate          = item.ModifiedDate = Common.getUTCDate();
                    dbItem.IsSelected         = item.IsSelected;
                    dbItem.TagStr             = item.TagStr;
                    dbItem.Allocated_Quantity = item.Allocated_Quantity;
                    dbItem.CreatedBy          = item.CreatedBy;
                    dbItem.CreatedDate        = item.CreatedDate;
                    dbItem.ID               = item.ID;
                    dbItem.IsDelete         = item.IsDelete;
                    dbItem.Item_ID          = item.Item_ID;
                    dbItem.ModifiedBy       = item.ModifiedBy;
                    dbItem.ModifiedDate     = item.ModifiedDate;
                    dbItem.Order_Quantity   = item.Order_Quantity;
                    dbItem.Pack_ID          = item.Pack_ID;
                    dbItem.Picked_Quantity  = item.Picked_Quantity;
                    dbItem.Quantity         = item.Quantity;
                    dbItem.Shipped_Quantity = item.Shipped_Quantity;
                    dbItem.SO_ID            = item.SO_ID;
                    dbItem.SO_Line_No       = item.SO_Line_No;

                    WHS_SO_Detail_Items_Serialized += Common.SerializeObject(item);
                    model.DBSet_WHS_SO_Detail.Add(dbItem);
                    Common.SaveChanges(model);

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

                    result.Add(item);
                    WHS_SO_Detail_List_Serialized += Common.SerializeObject(item);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Common.log.Error(WHS_SO_Detail_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Common.log.Warn(CreatedBy + " => " + WHS_SO_Detail_Items_Serialized, new Exception(message));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_SO_Detail_Create: {1} - {2}", CreatedBy, WHS_SO_Detail_List, WHS_SO_Detail_List_Serialized));
            }
            return(result.ToDataSourceResult(new DataSourceRequest()));
        }
Example #3
0
        public bool WHS_SO_Detail_Update(IEnumerable <WHS_SO_Detail> items, string ModifiedBy)
        {
            string WHS_SO_Detail_List             = string.Empty;
            string WHS_SO_Detail_List_Serialized  = string.Empty;
            string WHS_SO_Detail_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (WHS_SO_Detail item in items)
                {
                    WHS_SO_Detail dbItem = model.DBSet_WHS_SO_Detail.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        WHS_SO_Detail_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.Allocated_Quantity = item.Allocated_Quantity;
                        dbItem.CreatedBy          = item.CreatedBy;
                        dbItem.CreatedDate        = item.CreatedDate;
                        dbItem.ID               = item.ID;
                        dbItem.IsDelete         = item.IsDelete;
                        dbItem.Item_ID          = item.Item_ID;
                        dbItem.ModifiedBy       = item.ModifiedBy;
                        dbItem.ModifiedDate     = item.ModifiedDate;
                        dbItem.Order_Quantity   = item.Order_Quantity;
                        dbItem.Pack_ID          = item.Pack_ID;
                        dbItem.Picked_Quantity  = item.Picked_Quantity;
                        dbItem.Quantity         = item.Quantity;
                        dbItem.Shipped_Quantity = item.Shipped_Quantity;
                        dbItem.SO_ID            = item.SO_ID;
                        dbItem.SO_Line_No       = item.SO_Line_No;


                        WHS_SO_Detail_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        WHS_SO_Detail_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(WHS_SO_Detail_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + WHS_SO_Detail_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_SO_Detail_Update: {1} - {2}", ModifiedBy, WHS_SO_Detail_List, WHS_SO_Detail_List_Serialized));
            }
            return(flag);
        }
Example #4
0
 public WHS_SO_Detail WHS_SO_Detail_GetByID(int ID)
 {
     WMS.Models.DBContext model = new DBContext();
     return(model.DBSet_WHS_SO_Detail.Where(d => d.ID == ID).FirstOrDefault <WHS_SO_Detail>());
 }