Пример #1
0
 public List<cash> getcashdata(string date)
 {
     List<cash> cd = new List<cash>();
     query = " select t.t_id, t.t_dr, t.t_cr,t.t_naration, l.l_name AS dr_name, ll.l_name AS cr_name, ";
     query += "l.l_groupid AS dr_gid, ll.l_groupid AS cr_gid ,t.t_dramt ";
     query += " FROM (([transaction] t INNER JOIN  ledger l ON t.t_dr = l.l_id) ";
     query +=  "INNER JOIN  ledger ll ON t.t_cr = ll.l_id) ";
     query += " where t.t_date = @date and  (l.l_groupid = 1 OR l.l_groupid = 14 OR ll.l_groupid = 1 OR ll.l_groupid = 14) ";
     OleDbCommand cmd = new OleDbCommand(query, con);
     cmd.Parameters.AddWithValue("date", date);
     try
     {
         con.Open();
         OleDbDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             cash s = new cash()
             {
                 tid = int.Parse(dr.GetValue(0).ToString()),
                 drid = int.Parse(dr.GetValue(1).ToString()),
                 crid = int.Parse(dr.GetValue(2).ToString()),
                 naration = dr.GetValue(3).ToString(),
                 drname = dr.GetValue(4).ToString(),
                 crname = dr.GetValue(5).ToString(),
                 drgid = int.Parse(dr.GetValue(6).ToString()),
                 crgid = int.Parse(dr.GetValue(7).ToString()),
                 amt = double.Parse(dr.GetValue(8).ToString()),
             };
             cd.Add(s);
         }
         return cd;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return cd;
     }
     finally
     {
         con.Close();
     }
 }
Пример #2
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);
            }
        }