Example #1
0
 private void VSDetailList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (VSDetailList != null)
     {
         VSales.Amount      = VSDetailList.Sum(x => x.Amount);
         VSales.VAT         = VSDetailList.Sum(x => x.VAT);
         VSales.GrossAmount = VSDetailList.Sum(x => x.NetAmount);
         VSales.Taxable     = VSDetailList.Sum(x => x.Taxable);
         VSales.NonTaxable  = VSDetailList.Sum(x => x.NonTaxable);
         TotQty             = VSDetailList.Sum(x => x.Quantity);
     }
 }
Example #2
0
        private void GenerateVouchers()
        {
            decimal    Total  = VSDetailList.Sum(x => x.Quantity);
            string     Status = "{0} of " + Total.ToString() + " Done";
            Dispatcher d      = Dispatcher.CurrentDispatcher;

            ThreadPool.QueueUserWorkItem(x =>
            {
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        foreach (TParkingSalesDetails pSD in _VSDetailList)
                        {
                            VoucherType vt = VTypeList.First(y => y.VoucherId == pSD.ProdId && y.SkipVoucherGeneration == false);
                            for (int i = 1; i <= pSD.Quantity; i++)
                            {
                                Voucher v = new Voucher()
                                {
                                    BillNo      = pSD.BillNo,
                                    ExpDate     = CurDate.AddDays(vt.Validity),
                                    ValidStart  = vt.ValidStart,
                                    ValidEnd    = vt.ValidEnd,
                                    VoucherName = vt.VoucherName,
                                    Value       = vt.Value,
                                    Sno         = i,
                                    VoucherId   = vt.VoucherId,
                                    FYID        = GlobalClass.FYID
                                };
                                do
                                {
                                    v.Barcode = "#" + new Random().Next(1677215).ToString("X");
                                }while (tran.Connection.ExecuteScalar <int>("SELECT COUNT(*) FROM ParkingVouchers WHERE Barcode = @Barcode", v, transaction: tran) > 0);
                                v.Save(tran);
                                ParkingVouchers.Add(v);
                                d.BeginInvoke((Action)(() =>
                                {
                                    GenCount = string.Format(Status, ParkingVouchers.Count);
                                    Progress = ParkingVouchers.Count / Total * 100;
                                }));
                            }
                        }
                        tran.Commit();
                        PrintVouchers(_VSDetailList.First().BillNo, true, d);
                    }
                }
            });
        }
Example #3
0
        private void AddVoucher(object obj)
        {
            if (VSDetail.ProdId == 0)
            {
                MessageBox.Show("Please Select a Voucher first.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            else if (VSDetail.Quantity == 0)
            {
                MessageBox.Show("Please enter the quantity first.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            else if (VSDetailList.Any(x => x.ProdId == VSDetail.ProdId))
            {
                MessageBox.Show("Selected Voucher is already added.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            GenerateVoucher = !SelectedVoucherType.SkipVoucherGeneration;
            var vsDetail = new TParkingSalesDetails
            {
                FYID        = GlobalClass.FYID,
                PType       = 'V',
                ProdId      = VSDetail.ProdId,
                Description = VSDetail.Description,
                Quantity    = VSDetail.Quantity,
                QuantityStr = VSDetail.QuantityStr,
                Rate        = VSDetail.Rate,
                RateStr     = VSDetail.RateStr,
                Amount      = VSDetail.Amount,
                Taxable     = SelectedVoucherType.NonVat ? 0 : VSDetail.Amount,
                NonTaxable  = SelectedVoucherType.NonVat ? VSDetail.Amount :0,
                Remarks     = VSDetail.Remarks
            };

            vsDetail.VAT       = vsDetail.Taxable * GlobalClass.VAT / 100;
            vsDetail.NetAmount = vsDetail.Amount + vsDetail.VAT;
            VSDetailList.Add(vsDetail);
            VSDetail = new TParkingSalesDetails();
            VSDetail.PropertyChanged += VSDetail_PropertyChanged;
            FocusedElement            = (short)Focusable.VoucherType;
        }
Example #4
0
 private async Task GenerateVouchers(SqlTransaction tran)
 {
     decimal Total  = VSDetailList.Sum(x => x.Quantity);
     string  Status = "{0} of " + Total.ToString() + " Done";
     await Task.Run(() =>
     {
         foreach (TParkingSalesDetails pSD in _VSDetailList)
         {
             VoucherType vt = VTypeList.FirstOrDefault(y => y.VoucherId == pSD.ProdId && y.SkipVoucherGeneration == false);
             if (vt != null)
             {
                 for (int i = 1; i <= pSD.Quantity; i++)
                 {
                     Voucher v = new Voucher()
                     {
                         BillNo      = pSD.BillNo,
                         ExpDate     = CurDate.AddDays(vt.Validity),
                         ValidStart  = vt.ValidStart,
                         ValidEnd    = vt.ValidEnd,
                         VoucherName = vt.VoucherName,
                         Value       = vt.Value,
                         Sno         = i,
                         VoucherId   = vt.VoucherId,
                         FYID        = GlobalClass.FYID
                     };
                     do
                     {
                         v.Barcode = "#" + new Random().Next(1677215).ToString("X");
                     }while (tran.Connection.ExecuteScalar <int>("SELECT COUNT(*) FROM ParkingVouchers WHERE Barcode = @Barcode", v, transaction: tran) > 0);
                     v.Save(tran);
                     ParkingVouchers.Add(v);
                     GenCount = string.Format(Status, ParkingVouchers.Count);
                     Progress = ParkingVouchers.Count / Total * 100;
                 }
             }
         }
     });
 }