Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            //Common.ModelHelper.CompleteMainOnCreate(vm_销售报价);
            //vm_销售报价.单号 = _context.funcAutoCode("订单号");
            //vm_销售报价.业务类型 = "销售报价";
            //vm_销售报价.往来 = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == vm_销售报价.往来号)?.简称;
            //var tb_报价 = _mapper.Map<tb_报价表>(vm_销售报价);
            //_context.tb_报价表.Add(tb_报价);

            var tb_报价 = _context.funcNewRecord <vm_销售报价, tb_报价表>(vm_Main, before =>
            {
                before.单号   = _context.funcAutoCode("订单号");
                before.业务类型 = "销售报价";
                before.往来   = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == vm_Main.往来号)?.简称;
            });

            if (_context.SaveChanges() > 0)
            {
                foreach (var item in vm_Details)
                {
                    _context.funcNewDetail <vm_销售报价, vm_销售报价D, tb_报价表, tb_报价表D>(tb_报价, item, beforeNewD =>
                    {
                        beforeNewD.子单号 = _context.funcAutoCode("子单号");
                    });
                    Common.ModelHelper.CompleteDetailOnCreate(tb_报价, item);
                }
                //_context.tb_报价表D.AddRange(_mapper.Map<IList<tb_报价表D>>(vm_销售报价D列表));
                await _context.SaveChangesAsync();
            }
            else
            {
                return(NotFound());
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var remote = _context.funcNewRecord <vm_收款单, tb_收付表>(vm_Main, creating =>
            {
                creating.单号 = _context.funcAutoCode("订单号");
                creating.类型 = "收款";
                creating.往来 = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == vm_Main.往来号)?.简称;
            });

            if (await _context.SaveChangesAsync() > 0)
            {
                foreach (var localD in vm_Details)
                {
                    _context.funcNewDetail <vm_收款单, vm_收款单D, tb_收付表, tb_收付表D>(remote, localD, BeforeNewD: beforeD =>
                    {
                        if (string.IsNullOrEmpty(beforeD.子单号))
                        {
                            beforeD.子单号 = _context.funcAutoCode("子单号");
                        }
                        else
                        {
                            //var 报价D = _context.tb_报价表D.FirstOrDefault(d => d.子单号 == beforeD.子单号);
                            //if (报价D != null)
                            //    报价D.状态 = "已下单";
                        }
                    });
                }
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var remote = _context.funcEditRecord <vm_收款单, tb_收付表>(Record, before => {
                before.类型 = "收款";
                before.往来 = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == Record.往来号)?.简称;
            });

            _context.funcEditDetails <vm_收款单, vm_收款单D, tb_收付表, tb_收付表D>(Record, RecordDs,
                                                                        creatingD =>
            {
                if (string.IsNullOrEmpty(creatingD.子单号))     // 子单号为空的,表示新插入
                {
                    creatingD.子单号 = _context.funcAutoCode("子单号");
                }
                else if (!string.IsNullOrEmpty(creatingD.子单号))     // 子单号不为空,表示从报价单引入,插入
                {
                }
            },
                                                                        updatingD =>
            {
            },
                                                                        deletingD =>
            {
            });

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tb_收付表Exists(Record.RecordId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _pinhua2.funcNewRecord <vm_供应商, tb_往来表>(供应商, BeforeNew: local =>
            {
                local.往来号 = _pinhua2.funcAutoCode("往来号");
                local.类型  = "供应商";
            });
            _pinhua2.SaveChanges();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 5
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //Common.ModelHelper.CompleteMainOnCreate(客户);
            //客户.往来号 = _pinhua2.funcAutoCode("往来号");
            //客户.类型 = "客户";
            //_pinhua2.tb_往来表.Add(_mapper.Map<tb_往来表>(客户));

            _pinhua2.funcNewRecord <vm_客户, tb_往来表>(客户, creating => {
                creating.往来号 = _pinhua2.funcAutoCode("往来号");
                creating.类型  = "客户";
            });

            _pinhua2.SaveChanges();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var remote = _context.funcNewRecord <vm_销售出库, tb_IO>(vm_Main, creating =>
            {
                creating.类型 = "销售出库";
                creating.单号 = _context.funcAutoCode("订单号");
                creating.往来 = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == vm_Main.往来号)?.简称;
            });

            if (await _context.SaveChangesAsync() > 0)
            {
                foreach (var localD in vm_Details)
                {
                    _context.funcNewDetail <vm_销售出库, vm_销售出库D, tb_IO, tb_IOD>(remote, localD, creatingD => {
                        var 报价D = _context.tb_订单表D.FirstOrDefault(d => d.子单号 == creatingD.子单号);
                        if (报价D != null)
                        {
                            报价D.状态 = "已出库";
                        }
                    });
                }
                await _context.SaveChangesAsync();
            }
            else
            {
                return(NotFound());
            }

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var remote = _context.funcNewRecord <vm_销售订单, tb_订单表>(Record, BeforeNew: creating =>
            {
                creating.单号   = _context.funcAutoCode("订单号");
                creating.业务类型 = "销售订单";
                creating.往来   = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == Record.往来号)?.简称;
            });

            if (await _context.SaveChangesAsync() > 0)
            {
                foreach (var localD in RecordDs)
                {
                    _context.funcNewDetail <vm_销售订单, vm_销售订单D, tb_订单表, tb_订单表D>(remote, localD, BeforeNewD: beforeD =>
                    {
                        if (string.IsNullOrEmpty(beforeD.子单号))
                        {
                            beforeD.子单号 = _context.funcAutoCode("子单号");
                        }
                        else
                        {
                            var 报价D = _context.tb_报价表D.FirstOrDefault(d => d.子单号 == beforeD.子单号);
                            if (报价D != null)
                            {
                                报价D.状态 = "已下单";
                            }
                        }
                    });
                }
                await _context.SaveChangesAsync();
            }
            else
            {
                return(NotFound());
            }

            #region OldWay
            //Common.ModelHelper.CompleteMainOnCreate(vm_销售订单);
            //vm_销售订单.单号 = _context.funcAutoCode("订单号");
            //vm_销售订单.业务类型 = "销售订单";
            //vm_销售订单.往来 = _context.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == vm_销售订单.往来号)?.简称;
            //var tb_订单 = _mapper.Map<tb_订单表>(vm_销售订单);
            //_context.tb_订单表.Add(tb_订单);
            //if (_context.SaveChanges() > 0)
            //{
            //    foreach (var item in vm_销售订单D列表)
            //    {
            //        Common.ModelHelper.CompleteDetailOnCreate(tb_订单, item);
            //        if (string.IsNullOrEmpty(item.子单号))
            //            item.子单号 = _context.funcAutoCode("子单号");
            //        else
            //        {
            //            var remoteD = _context.tb_报价表D.FirstOrDefault(d => d.子单号 == item.子单号);
            //            if (remoteD != null)
            //                remoteD.状态 = "已下单";
            //        }
            //    }
            //    _context.tb_订单表D.AddRange(_mapper.Map<IList<tb_订单表D>>(vm_销售订单D列表));
            //    await _context.SaveChangesAsync();
            //}
            //else
            //    return NotFound();
            #endregion

            return(RedirectToPage("./Index"));
        }