Esempio n. 1
0
        protected void HandelValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var bSuccess1 = PinhuaContext.TryRecordEdit <dto付款单, tb_收付表>(main, creating =>
                {
                    creating.类型 = base.category;
                    creating.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == creating.往来号)?.简称;
                });
                if (bSuccess1)
                {
                    var bSuccess2 = PinhuaContext.TryRecordDetailsEdit <dto付款单, dto付款单D, tb_收付表, tb_收付表D>(main, currentDetails, adding =>
                    {
                        if (string.IsNullOrWhiteSpace(adding.子单号))
                        {
                            adding.子单号 = PinhuaContext.funcAutoCode("子单号");
                        }
                    });
                    if (bSuccess2)
                    {
                        transaction.Commit();
                    }
                }

                Navigation.NavigateTo(routeA);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        protected void HandelValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var remote = PinhuaContext.RecordAdd <dto收款单, tb_收付表>(main, creating =>
                {
                    creating.单号 = PinhuaContext.funcAutoCode("订单号");
                    creating.类型 = "收款";
                    creating.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == creating.往来号)?.简称;
                });

                if (PinhuaContext.SaveChanges() > 0)
                {
                    foreach (var localD in detailsTableDataSource)
                    {
                        PinhuaContext.RecordDetailAdd <dto收款单, dto收款单D, tb_收付表, tb_收付表D>(remote, localD, BeforeNewD: beforeD =>
                        {
                            if (string.IsNullOrEmpty(beforeD.子单号))
                            {
                                beforeD.子单号 = PinhuaContext.funcAutoCode("子单号");
                            }
                            else
                            {
                            }
                        });
                    }
                    PinhuaContext.SaveChanges();
                    transaction.Commit();
                }

                Navigation.NavigateTo(routeA);
            }
        }
Esempio n. 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();
                }
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 7
0
        protected void HandleValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                try
                {
                    var remote = PinhuaContext.RecordAdd <dto往来, tb_往来表>(main, adding =>
                    {
                        adding.往来号 = PinhuaContext.funcAutoCode("往来号");
                    });

                    PinhuaContext.SaveChanges();
                    transaction.Commit();

                    Navigation.NavigateTo(routeA);
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }
Esempio n. 8
0
        protected void HandleValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var affected = new List <string>();
                var bEdit    = PinhuaContext.TryRecordEdit <dto采购订单, tb_订单表>(main, adding =>
                {
                    adding.业务类型 = base.category;
                    adding.往来   = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称;
                });
                if (bEdit)
                {
                    Action <dto采购订单D> Adding = item =>
                    {
                        if (string.IsNullOrWhiteSpace(item.子单号)) // 子单号为空的,表示新插入
                        {
                            item.子单号 = PinhuaContext.funcAutoCode("子单号");
                        }
                        else // 子单号不为空,表示从报价单引入,插入
                        {
                            affected.Add(item.子单号);
                            var baojiaD = PinhuaContext.Set <tb_报价表D>().FirstOrDefault(d => d.子单号 == item.子单号);
                            if (baojiaD != null)
                            {
                                baojiaD.状态 = "已下单";
                            }
                        }
                    };
                    Action <dto采购订单D> Updating = item =>
                    {
                        affected.Add(item.子单号);
                        var baojiaD = PinhuaContext.Set <tb_报价表D>().FirstOrDefault(d => d.子单号 == item.子单号);
                        if (baojiaD != null)
                        {
                            baojiaD.状态 = "已下单";
                        }
                    };
                    Action <tb_订单表D> Deleting = item =>
                    {
                        affected.Add(item.子单号);
                        var tb_报价D = PinhuaContext.Set <tb_报价表D>().FirstOrDefault(d => d.子单号 == item.子单号);
                        if (tb_报价D != null)
                        {
                            tb_报价D.状态 = "";
                        }
                    };

                    var bEdit2 = PinhuaContext.TryRecordDetailsEdit <dto采购订单, dto采购订单D, tb_订单表, tb_订单表D>(main, detailsTableDataSource,
                                                                                                         Adding, Updating, Deleting);

                    if (bEdit2)
                    {
                        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);
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        protected void ValidSubmit(EditContext context)
        {
            using (var transaction = PinhuaContext.Database.BeginTransaction())
            {
                var affected = new List <string>();
                var bEdit    = PinhuaContext.TryRecordEdit <dto销售出库, tb_IO>(main, adding =>
                {
                    adding.类型 = base.category;
                    adding.往来 = PinhuaContext.Set <tb_往来表>().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称;
                });

                if (bEdit)
                {
                    Action <dto销售出库D> Adding = item =>
                    {
                        if (string.IsNullOrEmpty(item.子单号)) // 子单号为空的,表示新插入
                        {
                            item.子单号 = PinhuaContext.funcAutoCode("子单号");
                        }
                        else // 子单号不为空,表示从报价单引入,插入
                        {
                            affected.Add(item.子单号);
                        }
                    };

                    Action <dto销售出库D> Updating = item => affected.Add(item.子单号);
                    Action <tb_IOD>   Deleting = item => affected.Add(item.子单号);

                    var bEdit2 = PinhuaContext.TryRecordDetailsEdit <dto销售出库, dto销售出库D, tb_IO, tb_IOD>(main, detailsTableDataSource, Adding, Updating, Deleting);

                    if (bEdit2)
                    {
                        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 result1   = PinhuaContext.tb_订单表D.Where(d => childIds1.Contains(d.子单号));
                        var result2   = PinhuaContext.tb_订单表D.Where(d => childIds2.Contains(d.子单号));
                        foreach (var item in result1)
                        {
                            item.状态 = "已出库";
                        }
                        ;
                        foreach (var item in result2)
                        {
                            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);
            }
        }