public OrderRemainItem(OrderRemainItem refObj)
 {
     this.Delivery = refObj.Delivery;
     this.LineNumber = refObj.LineNumber;
     this.Note = refObj.Note;
     this.OrderQuantity = refObj.OrderQuantity;
     this.PartNameEn = refObj.PartNameEn;
     this.PartNameVn = refObj.PartNameVn;
     this.PackUnit = refObj.PackUnit;
     this.PartCode = refObj.PartCode;
     this.QuotationQuantity = refObj.QuotationQuantity;
     this.UnitPrice = refObj.UnitPrice;
 }
        public static OrderRemainItem SumRemainOrders(string dCode, string issueNo, string orderNo, string oFrom, string oTo, string iFrom, string iTo)
        {
            var dc = VDMS.II.Linq.DCFactory.GetDataContext<VDMS.II.Linq.PartDataContext>();
            var oF = DataFormat.DateFromString(oFrom);
            var oT = DataFormat.DateFromString(oTo);
            var iF = DataFormat.DateFromString(iFrom);
            var iT = DataFormat.DateFromString(iTo);
            var q = GetBaseQuery(dc, dCode, issueNo, oF, oT, iF, iT);
            if (!string.IsNullOrEmpty(orderNo))
            {
                q = q.Where(p => p.OrderHeader.TipTopNumber == orderNo);
            }

            var res = new OrderRemainItem()
            {
                OrderQuantity = q.Sum(p => p.OrderQuantity),
                QuotationQuantity = q.Sum(p => p.QuotationQuantity),
                Delivery = q.Sum(p => p.DelivaryQuantity),
                UnitPrice = q.Sum(p => (long)p.UnitPrice * (p.QuotationQuantity - (p.DelivaryQuantity == null ? 0 : p.DelivaryQuantity.Value))),
            };

            return res;
        }