Example #1
0
        private void addct_Click(object sender, RoutedEventArgs e)
        {
            //  MessageBox.Show(lid + " "+cid);
            if (txtamt.Text != "" && txtacshac.Text != "" && txtac.Text != "")
            {
                cashmodel ct = new cashmodel();
                  if (ct.incertcash(cid,lid,Double.Parse(txtamt.Text),txtnaration.Text,dr,dpcashfdate.ToString()))
                  {
                     Show("Succesfull",1);
                    cashtrans.Visibility = Visibility.Hidden;
                      cash c;
                    if (dr)
                    {
                       c = new cash()
                        {
                            tid = ct.tid,  drname = txtacshac.Text,  drgid = cid,  crname = txtac.Text,
                            crid = lid,
                            amt = Double.Parse(txtamt.Text),
                            naration = txtnaration.Text,
                        };
                       int i = application.tb.Where(x => x.Lid == cid).Select<ledgerbalance, int>(x => application.tb.IndexOf(x)).Single<int>();
                       application.tb[i].Balance = application.tb[i].Balance + Double.Parse(txtamt.Text);
                       application.tb[i].CurrBalance = application.tb[i].Balance.ToString("C2");
                       //application.tb[i].BalanceType = "dr";
                       int j = application.tb.Where(x => x.Lid == lid).Select<ledgerbalance, int>(x => application.tb.IndexOf(x)).Single<int>();
                       application.tb[j].Balance = application.tb[j].Balance - Double.Parse(txtamt.Text);
                       application.tb[j].CurrBalance = application.tb[j].Balance.ToString("C2");
                      /// application.tb[i].BalanceType = "dr";
                    }
                    else
                    {
                       c = new cash()
                        {
                            tid = ct.tid,
                            drname = txtac.Text,
                            drgid = lid,
                            crname = txtacshac.Text ,
                            crid = cid,
                            amt = Double.Parse(txtamt.Text),
                            naration = txtnaration.Text,
                        };
                       int i = application.tb.Where(x => x.Lid == cid).Select<ledgerbalance, int>(x => application.tb.IndexOf(x)).Single<int>();
                       application.tb[i].Balance = application.tb[i].Balance -Double.Parse(txtamt.Text);
                       application.tb[i].CurrBalance = application.tb[i].Balance.ToString("C2");
                       //application.tb[i].BalanceType = "dr";
                       int j = application.tb.Where(x => x.Lid == lid).Select<ledgerbalance, int>(x => application.tb.IndexOf(x)).Single<int>();
                       application.tb[j].Balance = application.tb[j].Balance + Double.Parse(txtamt.Text);
                       application.tb[j].CurrBalance = application.tb[j].Balance.ToString("C2");
                    }
                    if (ctype == "crecive")
                    {
                        patmentrecived.Add(c);
                    }
                    else if (ctype == "cgiven")
                    {
                        paymentgiven.Add(c);
                    }
                    else if (ctype == "income")
                    {
                        income.Add(c);
                    }
                    else if (ctype == "expance")
                    {
                        expance.Add(c);
                    }

                  }
            }
            else  {
                Show("Fields Cannot be Empty",2);
            }
        }
Example #2
0
 private void btncacreate_Click(object sender, RoutedEventArgs e)
 {
     if (type == "null")
     {
         if (cbcactype.SelectedItem == null)
         {
             return;
         }
         type = cbcactype.Text;
     }
     if (txtcacname.Text.Trim() != "" && txtcacob.Text.Trim() != ""  )
     {
         cashmodel c =  new cashmodel();
         if (c.createaccount(txtcacname.Text,double.Parse(txtcacob.Text),type,dpcradate.ToString()))
         {
             CrCashAc.Visibility = Visibility.Hidden;
         }
     }
     else
     {
         Show("Please Enter Correct Data",2);
     }
 }