Exemple #1
0
        public async Task <IActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                var remoteOrder = _pinhuaContext.Warehouse.FirstOrDefault(p => p.Id == Order.Main.Id);
                if (remoteOrder == null)
                {
                    ModelState.AddModelError("", $"单号为 {Order.Main.Id} 的送货单不存在,操作失败。");
                    return(Page());
                }

                // 对主表的缺失信息赋值,ExcelServerRcid,ExcelServerRtid,其他
                Order.Main.ExcelServerRcid = remoteOrder.ExcelServerRcid;
                Order.Main.ExcelServerRtid = remoteOrder.ExcelServerRtid;
                // 将修改标记到数据库中跟踪的数据,remoteOrder
                _mapper.Map <WarehouseDTO, Data.Entities.Pinhua.Warehouse>(Order.Main, remoteOrder);

                // 保存修改
                await _pinhuaContext.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
        public async Task <IActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                var remoteOrder = _pinhuaContext.产品型号清单.FirstOrDefault(p => p.编号 == ModelNumberInfo.ModelNumber);
                if (remoteOrder == null)
                {
                    ModelState.AddModelError("", $"单号为 {ModelNumberInfo.ModelNumber} 的送货单不存在,操作失败。");
                    return(Page());
                }

                // 对主表的缺失信息赋值,ExcelServerRcid,ExcelServerRtid,其他
                ModelNumberInfo.ExcelServerRcid = remoteOrder.ExcelServerRcid;
                ModelNumberInfo.ExcelServerRtid = remoteOrder.ExcelServerRtid;
                // 将修改标记到数据库中跟踪的数据,remoteOrder
                _mapper.Map <ModelNumberDTO, Data.Entities.Pinhua.产品型号清单>(ModelNumberInfo, remoteOrder);

                // 保存修改
                await _pinhuaContext.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
Exemple #3
0
        public async Task <IActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                var remoteOrder = _pinhuaContext.RetailGiMain.FirstOrDefault(p => p.DeliveryId == Order.Main.DeliveryId);
                if (remoteOrder == null)
                {
                    ModelState.AddModelError("", $"单号为 {Order.Main.DeliveryId} 的送货单不存在,操作失败。");
                    return(Page());
                }

                // 对主表的缺失信息赋值,ExcelServerRcid,ExcelServerRtid,其他
                Order.Main.ExcelServerRcid = remoteOrder.ExcelServerRcid;
                Order.Main.ExcelServerRtid = remoteOrder.ExcelServerRtid;
                // Order.Main.CustomerName = _pinhuaContext.往来单位.FirstOrDefault(p => p.单位编号 == Order.Main.CustomerId).单位名称;
                // 将修改标记到数据库中跟踪的数据,remoteOrder
                _mapper.Map <Gi2MainDTO, RetailGiMain>(Order.Main, remoteOrder);
                // 对明细表的缺失信息赋值
                Order.Details.ForEach(i =>
                {
                    i.ExcelServerRcid = remoteOrder.ExcelServerRcid;
                    i.ExcelServerRtid = remoteOrder.ExcelServerRtid;
                    i.DeliveryId      = remoteOrder.DeliveryId;
                });
                Order.Details.ForEach(i =>
                {
                    var result = _pinhuaContext.RetailGiDetails.FirstOrDefault(p => p.DeliveryId == i.DeliveryId && p.Id == i.Id);
                    if (result == null)
                    {
                        // 如果该条信息不存在,则添加
                        _pinhuaContext.RetailGiDetails.Add(_mapper.Map <Gi2DetaislDTO, RetailGiDetails>(i));
                    }
                    else
                    {
                        // 如果该条信息存在,则修改
                        _mapper.Map <Gi2DetaislDTO, RetailGiDetails>(i, result);
                    }
                });
                await _pinhuaContext.RetailGiDetails.Where(p => p.DeliveryId == remoteOrder.DeliveryId).ForEachAsync(i =>
                {
                    var result = Order.Details.FirstOrDefault(p => p.Id == i.Id);
                    if (result == null)
                    {
                        // 如果该条信息多余,则删除
                        _pinhuaContext.RetailGiDetails.Remove(i);
                    }
                });

                // 保存修改
                await _pinhuaContext.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }
            else
            {
                Order.DeliveryTypes      = BuildTypes();
                Order.CustomerSelectList = _pinhuaContext.GetCustomerSelectList();
                return(Page());
            }
        }
        public async Task <IActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                var remoteOrder = _pinhuaContext.ProductRegistrationMain.FirstOrDefault(p => p.ModelNumber == ProductRegistrationInfo.ModelNumber && p.SubModelNumber == ProductRegistrationInfo.SubModelNumber);
                if (remoteOrder == null)
                {
                    ModelState.AddModelError("", $"单号为 {ProductRegistrationInfo.ModelNumber} 的送货单不存在,操作失败。");
                    return(Page());
                }

                // 对主表的缺失信息赋值,ExcelServerRcid,ExcelServerRtid,其他
                ProductRegistrationInfo.ExcelServerRcid = remoteOrder.ExcelServerRcid;
                ProductRegistrationInfo.ExcelServerRtid = remoteOrder.ExcelServerRtid;
                // 将修改标记到数据库中跟踪的数据,remoteOrder
                _mapper.Map <ProductRegistrationDTO, ProductRegistrationMain>(ProductRegistrationInfo, remoteOrder);

                // 保存修改
                await _pinhuaContext.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
Exemple #5
0
        protected async Task toDelete()
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var tb_main = await PinhuaContext.tb_IO.FindAsync(RecordId);

                if (tb_main != null)
                {
                    var tb_details = PinhuaContext.tb_IOD.Where(p => p.RecordId == tb_main.RecordId);
                    var affected   = tb_details.Select(d => d.子单号).ToList();
                    PinhuaContext.tb_IO.Remove(tb_main);
                    PinhuaContext.tb_IOD.RemoveRange(tb_details);
                    await PinhuaContext.SaveChangesAsync();

                    var childIds1 = PinhuaContext.View订单数量收发().Where(d => (d.已收 ?? 0) > 0 && affected.Contains(d.子单号)).Select(d => d.子单号);
                    var childIds2 = PinhuaContext.View订单数量收发().Where(d => (d.已收 ?? 0) == 0 && affected.Contains(d.子单号)).Select(d => d.子单号);
                    var items1    = PinhuaContext.tb_订单表D.Where(d => childIds1.Contains(d.子单号));
                    var items2    = PinhuaContext.tb_订单表D.Where(d => childIds2.Contains(d.子单号));

                    foreach (var item in items1)
                    {
                        item.状态 = "已入库";
                    }
                    ;
                    foreach (var item in items2)
                    {
                        item.状态 = "";
                    }
                    ;

                    await PinhuaContext.SaveChangesAsync();

                    var mains = from m in PinhuaContext.tb_订单表
                                join d in PinhuaContext.tb_订单表D on m.RecordId equals d.RecordId
                                where affected.Contains(d.子单号)
                                select m;

                    foreach (var m in mains)
                    {
                        var bRet = PinhuaContext.tb_订单表D.Where(d => d.RecordId == m.RecordId).Any(d => d.状态.Contains("已"));
                        if (bRet)
                        {
                            m.LockStatus = 1;
                        }
                        else
                        {
                            m.LockStatus = 0;
                        }
                    }
                    ;

                    await PinhuaContext.SaveChangesAsync();

                    transaction.Commit();
                }
            }

            Navigation.NavigateTo(routeA);
        }
Exemple #6
0
        protected async Task toDelete()
        {
            var tb_商品表 = await PinhuaContext.tb_商品表.FindAsync(RecordId);

            if (tb_商品表 != null)
            {
                PinhuaContext.tb_商品表.Remove(tb_商品表);
                await PinhuaContext.SaveChangesAsync();

                Navigation.NavigateTo(routeA);
            }
        }
        public async Task <IActionResult> OnPost()
        {
            var remoteOrder = _pinhuaContext.Gr2Main.FirstOrDefault(p => p.PurchasingId == Purchasing.Main.PurchasingId);

            if (remoteOrder == null)
            {
                ModelState.AddModelError("", $"单号为 {Purchasing.Main.PurchasingId} 的送货单不存在,操作失败。");
                return(Page());
            }

            // 对主表的缺失信息赋值,ExcelServerRcid,ExcelServerRtid,其他
            Purchasing.Main.ExcelServerRcid = remoteOrder.ExcelServerRcid;
            Purchasing.Main.ExcelServerRtid = remoteOrder.ExcelServerRtid;
            Purchasing.Main.SupplierName    = _pinhuaContext.往来单位.FirstOrDefault(p => p.单位编号 == Purchasing.Main.Supplier).单位名称;
            // 将修改标记到数据库中跟踪的数据,remoteOrder
            _mapper.Map <Gr2MainDto, Gr2Main>(Purchasing.Main, remoteOrder);
            // 对明细表的缺失信息赋值
            Purchasing.Details.ForEach(i =>
            {
                i.ExcelServerRcid = remoteOrder.ExcelServerRcid;
                i.ExcelServerRtid = remoteOrder.ExcelServerRtid;
                i.PurchasingId    = remoteOrder.PurchasingId;
            });
            Purchasing.Details.ForEach(i =>
            {
                var result = _pinhuaContext.Gr2Details.FirstOrDefault(p => p.PurchasingId == i.PurchasingId && p.ItemId == i.ItemId);
                if (result == null)
                {
                    // 如果该条信息不存在,则添加
                    _pinhuaContext.Gr2Details.Add(_mapper.Map <Gr2DetailsDto, Gr2Details>(i));
                }
                else
                {
                    // 如果该条信息存在,则修改
                    _mapper.Map <Gr2DetailsDto, Gr2Details>(i, result);
                }
            });
            await _pinhuaContext.Gr2Details.Where(p => p.PurchasingId == remoteOrder.PurchasingId).ForEachAsync(i =>
            {
                var result = Purchasing.Details.FirstOrDefault(p => p.ItemId == i.ItemId);
                if (result == null)
                {
                    // 如果该条信息多余,则删除
                    _pinhuaContext.Gr2Details.Remove(i);
                }
            });

            // 保存修改
            await _pinhuaContext.SaveChangesAsync();

            return(RedirectToPage("Index"));
        }
Exemple #8
0
        protected async Task toDelete()
        {
            var tb_字典表 = await PinhuaContext.tb_字典表.FindAsync(RecordId);

            if (tb_字典表 != null)
            {
                var tb_字典表D = PinhuaContext.tb_字典表D.Where(p => p.RecordId == tb_字典表.RecordId);

                PinhuaContext.tb_字典表.Remove(tb_字典表);
                PinhuaContext.tb_字典表D.RemoveRange(tb_字典表D);
                await PinhuaContext.SaveChangesAsync();

                Navigation.NavigateTo(routeA);
            }
        }
Exemple #9
0
        protected async Task toDelete()
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var tb_main = await PinhuaContext.tb_报价表.FindAsync(RecordId);

                if (tb_main != null)
                {
                    var tb_details     = PinhuaContext.tb_报价表D.Where(p => p.RecordId == tb_main.RecordId);
                    var tb_requirement = from d1 in PinhuaContext.tb_需求表D
                                         join d2 in tb_details on d1.子单号 equals d2.子单号
                                         select d1;

                    foreach (var item in tb_requirement)
                    {
                        item.状态 = "";
                    }
                    await PinhuaContext.SaveChangesAsync();

                    var mains = from m in PinhuaContext.tb_需求表
                                join d in tb_requirement on m.RecordId equals d.RecordId
                                select m;

                    foreach (var m in mains)
                    {
                        var bRet = PinhuaContext.tb_需求表D.Where(d => d.RecordId == m.RecordId).Any(d => d.状态.Contains("已"));
                        if (bRet)
                        {
                            m.LockStatus = 1;
                        }
                        else
                        {
                            m.LockStatus = 0;
                        }
                    }
                    ;
                    PinhuaContext.tb_报价表.Remove(tb_main);
                    PinhuaContext.tb_报价表D.RemoveRange(tb_details);

                    await PinhuaContext.SaveChangesAsync();

                    transaction.Commit();
                }
            }

            Navigation.NavigateTo(routeA);
        }