Ejemplo n.º 1
0
        internal static bool GetPaymentIsUsed(AppBase.Reciept PaymentReciept)
        {
            bool valid = false;

            using (Connection Connection = new Connection())
            {
                int count = Connection.WarretyPaymentCount(PaymentReciept);
                valid = (count == 0);
            }
            return(valid);
        }
Ejemplo n.º 2
0
        internal bool IsValid(AppBase.Reciept PaymentReciept)
        {
            bool valid = false;

            valid = DataHelper.DataProvider.GetPaymentIsUsed(PaymentReciept);
            if (!valid)
            {
                return(valid);
            }
            decimal totalWarretyPayment = this.GetTotalWarretnyPayment();
            decimal TotalPayment        = PaymentReciept.GetTotalPayment();

            //Check 1 is Payment values same
            valid = totalWarretyPayment == TotalPayment;
            if (!valid)
            {
                return(valid);
            }
            //Check 2 is the Payment item Selected
            foreach (var item in this)
            {
                if (!valid)
                {
                    return(valid);
                }
                item.PaymentItem = item.GetPaymentItem();
                if (item.PaymentItem == null)
                {
                    throw new DataHelper.NoWarrentySettingFoundException("No Warranty Settings Found", "Cannot Proceed");
                }
                foreach (var payment in PaymentReciept)
                {
                    if (item.PaymentItem == payment.ItemId && payment.PaymentUsage > 0)
                    {
                        payment.UpdateUsage();
                        item.PaymentReciept = PaymentReciept;
                        valid = true;
                        break;
                    }
                    else
                    {
                        valid = false;
                    }
                }
                if (!valid)
                {
                    return(valid);
                }
            }
            foreach (var payment in PaymentReciept)
            {
                if (payment.PaymentUsage != 0)
                {
                    valid = false;
                    if (!valid)
                    {
                        return(valid);
                    }
                }
            }
            if (totalWarretyPayment == TotalPayment)
            {
                return(true);
            }

            else
            {
                valid = false;
            }
            return(valid);
        }