Exemple #1
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     if (pc.Count != 0)
     {
         int tid = new transactionmodel().getid();
         purchase p = new purchase()
         {
             pid = vid,
             tid = tid,
             lid = lid,
             ptotal = total,
             pdate = datePicker1.ToString(),
             tnsp_chg = addcharges.ToString(),
             vat_chg = vat.ToString(),
             roundof = roundof.ToString(),
             nettotal = Double.Parse(txttotalamount.Text),
             discount = "0",
             sinvoiceno = int.Parse(txtvno.Text)
         };
         List<purchaseitem> pl = pc.ToList<purchaseitem>();
         purchasemodel pm = new purchasemodel(p, pl, total);
         if (pm.insert())
         {
             Show("Data Saved", 2);
             int i = application.tb.Where(x => x.Lid == lid).Select<ledgerbalance, int>(x => application.tb.IndexOf(x)).Single<int>();
             application.tb[i].Balance = application.tb[i].Balance + Double.Parse(txttotalamount.Text);
             application.tb[i].CurrBalance = application.tb[i].Balance.ToString("C2");
             application.tb[i].BalanceType = "dr";
             pc.Clear();
             reset();
             vid = pm.getvid();
         }
     }
     else
     {
        Show("Fields Cannot be Empty",2);
     }
 }