Esempio n. 1
0
        public bool CheckIsLast(int noteid)
        {
            bool bRet = false;

            using (var repo = DMRepository.Get())
            {
                DeliveryNote note = repo.Get <DeliveryNote>(p => p.noteid == noteid);
                if (note != null)
                {
                    Spec <CustomerEntity> where = new Spec <CustomerEntity>();
                    where.And(p => p.customer == note.customer);
                    where.And(p => p.cyear == note.sdate.Year);
                    CustomerEntity customer = repo.Get <CustomerEntity>(where.Exp);
                    if (customer != null)
                    {
                        if (customer.sequence == note.deliverid)
                        {
                            bRet = true;
                        }
                    }
                }
            }


            return(bRet);
        }
Esempio n. 2
0
        public String Delete(int noteid, bool isdecrease)
        {
            String         bErr     = "";
            CustomerEntity customer = null;

            if (isdecrease)
            {
                using (var repo = DMRepository.Get())
                {
                    DeliveryNote note = repo.Get <DeliveryNote>(p => p.noteid == noteid);
                    if (note == null)
                    {
                        return("当前送货单不存在");
                    }

                    Spec <CustomerEntity> where = new Spec <CustomerEntity>();
                    where.And(p => p.customer == note.customer);
                    if (note.sdate.Year <= 1)
                    {
                        where.And(p => p.cyear == DateTime.Now.Year);
                    }
                    else
                    {
                        where.And(p => p.cyear == note.sdate.Year);
                    }
                    customer = repo.Get <CustomerEntity>(where.Exp);
                    if (customer == null)
                    {
                        return("系统中没有此客户信息");
                    }

                    if (customer.sequence != note.deliverid)
                    {
                        return("当前送货单已归档,不能删除");
                    }
                    customer.sequence = customer.sequence - 1;
                }
            }

            using (var dmt = DMContext.GetTransaction())
            {
                var trans = dmt.BeginTransaction();
                if (customer != null & isdecrease)
                {
                    DMContext.Update <CustomerEntity>(customer, p => p.cid == customer.cid, null, trans);
                }

                DMContext.Delete <DeliveryItem>(p => p.noteid == noteid, trans);
                DMContext.Delete <DeliveryNote>(p => p.noteid == noteid, trans);
                trans.Commit();
            }

            return(bErr);
        }
Esempio n. 3
0
        public DeliveryNote Select(int noteId)
        {
            DeliveryNote note;

            using (var repo = DMRepository.Get())
            {
                note       = repo.Get <DeliveryNote>(p => p.noteid == noteId);
                note.items = repo.GetList <DeliveryItem>(50, p => p.noteid == noteId, p => p.itemid.Asc());
            }

            return(note);
        }