private void ExecuteLoad(object obj)
 {
     if (obj != null)
     {
         byte id = Convert.ToByte(obj);
         if (!VTypeList.Any(x => x.VoucherId == id))
         {
             MessageBox.Show("Invalid Id.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             return;
         }
         SelectedVType = VTypeList.FirstOrDefault(x => x.VoucherId == id);
     }
     VType = new VoucherType
     {
         VoucherId             = SelectedVType.VoucherId,
         VoucherName           = SelectedVType.VoucherName,
         Rate                  = SelectedVType.Rate,
         RateStr               = SelectedVType.RateStr,
         Value                 = SelectedVType.Value,
         ValidStart            = SelectedVType.ValidStart,
         ValidEnd              = SelectedVType.ValidEnd,
         Validity              = SelectedVType.Validity,
         VehicleType           = SelectedVType.VehicleType,
         VoucherInfo           = SelectedVType.VoucherInfo,
         SkipVoucherGeneration = SelectedVType.SkipVoucherGeneration,
         NonVat                = SelectedVType.NonVat
     };
     SetAction(ButtonAction.Selected);
 }
Esempio n. 2
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;
                 }
             }
         }
     });
 }