示例#1
0
        protected void ValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var bAdd = PinhuaContext.TryRecordAdd <dto销售报价, tb_报价表>(main, adding =>
                {
                    adding.业务类型 = base.category;
                    adding.单号   = PinhuaContext.funcAutoCode("订单号");
                    adding.往来   = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称;
                });
                if (bAdd)
                {
                    var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto销售报价, dto销售报价D, tb_报价表, tb_报价表D>(main, detailsTableDataSource, adding =>
                    {
                        adding.子单号 = PinhuaContext.funcAutoCode("子单号");
                    });

                    if (bAdd2)
                    {
                        transaction.Commit();
                    }
                }

                Navigation.NavigateTo(routeA);
            }
        }
示例#2
0
        protected void ValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                try
                {
                    var bAdd1 = PinhuaContext.TryRecordAdd <dto字典, tb_字典表>(main);
                    if (bAdd1)
                    {
                        var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto字典, dto字典D, tb_字典表, tb_字典表D>(main, detailsTableDataSource, adding =>
                        {
                            adding.字典号 = main.字典号;
                            adding.组号  = main.组号;
                        });

                        if (bAdd2)
                        {
                            transaction.Commit();
                        }
                    }

                    Navigation.NavigateTo(routeA);
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }
示例#3
0
        protected void HandelValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var bAdd = PinhuaContext.TryRecordAdd <dto付款单, tb_收付表>(main, creating =>
                {
                    creating.类型 = base.category;
                    creating.单号 = PinhuaContext.funcAutoCode("订单号");
                    creating.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == creating.往来号)?.简称;
                });

                if (bAdd)
                {
                    var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto付款单, dto付款单D, tb_收付表, tb_收付表D>(main, detailsTableDataSource, adding =>
                    {
                        if (string.IsNullOrWhiteSpace(adding.子单号))
                        {
                            adding.子单号 = PinhuaContext.funcAutoCode("子单号");
                        }
                    });

                    if (bAdd2)
                    {
                        transaction.Commit();
                    }
                }

                Navigation.NavigateTo(routeA);
            }
        }
示例#4
0
        protected void HandleValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                try
                {
                    var bAdd = PinhuaContext.TryRecordAdd <dto采购申请, tb_需求表>(main, adding =>
                    {
                        adding.单号   = PinhuaContext.funcAutoCode("订单号");
                        adding.业务类型 = base.category;
                    });
                    if (bAdd)
                    {
                        var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto采购申请, dto采购申请D, tb_需求表, tb_需求表D>(main, detailsTableDataSource, adding =>
                        {
                            if (string.IsNullOrWhiteSpace(adding.子单号))
                            {
                                adding.子单号 = PinhuaContext.funcAutoCode("子单号");
                            }
                        });

                        if (bAdd2)
                        {
                            transaction.Commit();
                        }
                    }

                    Navigation.NavigateTo("/采购/申请");
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }
示例#5
0
        protected void ValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var affected = new List <string>();
                var bAdd     = PinhuaContext.TryRecordAdd <dto销售订单, tb_订单表>(main, adding =>
                {
                    adding.业务类型 = base.category;
                    adding.单号   = PinhuaContext.funcAutoCode("订单号");
                    adding.往来   = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称;
                });

                if (bAdd)
                {
                    var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto销售订单, dto销售订单D, tb_订单表, tb_订单表D>(main, detailsTableDataSource, item =>
                    {
                        if (string.IsNullOrWhiteSpace(item.子单号))
                        {
                            item.子单号 = PinhuaContext.funcAutoCode("子单号");
                        }
                        else
                        {
                            affected.Add(item.子单号);
                            var 报价D = PinhuaContext.tb_报价表D.FirstOrDefault(d => d.子单号 == item.子单号);
                            if (报价D != null)
                            {
                                报价D.状态 = "已下单";
                            }
                        }
                    });

                    if (bAdd2)
                    {
                        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;
                            }
                        }
                        ;
                        PinhuaContext.SaveChanges();

                        transaction.Commit();
                    }
                }

                Navigation.NavigateTo(routeA);
            }
        }
示例#6
0
        protected void ValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var bAdd = PinhuaContext.TryRecordAdd <dto商品, tb_商品表>(main, adding =>
                {
                    adding.品号 = PinhuaContext.funcAutoCode("商品号");
                });

                if (bAdd)
                {
                    transaction.Commit();
                }

                Navigation.NavigateTo(routeA);
            }
        }
示例#7
0
        protected void ValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var affected = new List <string>();
                var bAdd     = PinhuaContext.TryRecordAdd <dto销售出库, tb_IO>(main, adding =>
                {
                    adding.类型 = base.category;
                    adding.单号 = PinhuaContext.funcAutoCode("订单号");
                    adding.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称;
                });
                if (bAdd)
                {
                    var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto销售出库, dto销售出库D, tb_IO, tb_IOD>(main, detailsTableDataSource, adding =>
                    {
                        if (string.IsNullOrWhiteSpace(adding.子单号))
                        {
                            adding.子单号 = PinhuaContext.funcAutoCode("子单号");
                        }
                        else
                        {
                            affected.Add(adding.子单号);
                            //var item = PinhuaContext.tb_订单表D.FirstOrDefault(d => d.子单号 == adding.子单号);
                            //if (item != null)
                            //    item.状态 = "已出库";
                        }
                    }
                                                                                                     );

                    if (bAdd2)
                    {
                        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.状态 = "";
                        }
                        ;
                        PinhuaContext.SaveChanges();

                        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;
                            }
                        }
                        ;
                        PinhuaContext.SaveChanges();

                        transaction.Commit();
                    }
                }

                Navigation.NavigateTo(routeA);
            }
        }