예제 #1
0
        public static bool CheckOutDate(WaybillList wb, BaseEntities db, DateTime date)
        {
            bool r     = true;
            var  query = (from wbd in db.WaybillDet
                          from m in db.Materials
                          where wbd.WbillId == wb.WbillId && m.MatId == wbd.MatId
                          orderby wbd.OnDate descending
                          select new
            {
                wbd.OnDate,
                m.Name
            }
                          ).FirstOrDefault();

            /*
             *              select first 1 distinct wbd.ondate, m.name
             * from waybilldet wbd , materials m
             * where wbd.wbillid=:WBILLID and m.matid = wbd.matid
             * order by wbd.ondate desc
             */
            if (query != null && date < query.OnDate)
            {
                if (MessageBox.Show("Дата документа не може бути меншою за дату видаткової партії! \nПозиція: " + query.Name + " \nДата: " + query.OnDate.ToString() + " \nЗмінити дату докомента на " + query.OnDate.ToString() + "?", "Зміна дати докуманта", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    wb.OnDate = query.OnDate.Value;
                    db.SaveChanges();
                }
                else
                {
                    r = false;
                }
            }

            return(r);
        }
예제 #2
0
        public static bool CheckInDate(WaybillList wb, BaseEntities db, DateTime date)
        {
            bool r     = true;
            var  query = (from wmt1 in db.WMatTurn
                          from wmt2 in db.WMatTurn
                          from wbd in db.WaybillDet
                          from m in db.Materials
                          where wbd.WbillId == wb.WbillId && m.MatId == wbd.MatId && wbd.PosId == wmt1.SourceId && wmt1.PosId == wmt2.SourceId && wmt1.TurnType != wmt2.TurnType
                          orderby wmt2.OnDate descending
                          select new
            {
                wmt2.OnDate,
                m.Name
            }
                          ).ToList().FirstOrDefault();



            /*
             *              select first 1 distinct wmt2.ondate, m.name
             * from WMATTURN wmt1, WMATTURN wmt2, waybilldet wbd , materials m
             * where wbd.wbillid=:WBILLID and m.matid = wbd.matid and wbd.posid=wmt1.sourceid
             *   and wmt1.posid=wmt2.sourceid  and wmt1.turntype <> wmt2.turntype
             * order by wmt2.ondate desc
             */

            if (query != null && date < query.OnDate)
            {
                if (MessageBox.Show("Дата документа не може бути меншою за дату прибуткової партії! \nПозиція: " + query.Name + " \nДата: " + query.OnDate.ToString() + " \nЗмінити дату докомента на " + query.OnDate.ToString() + "?", "Зміна дати докуманта", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    wb.OnDate = query.OnDate;
                    db.SaveChanges();
                }
                else
                {
                    r = false;
                }
            }

            return(r);
        }