Example #1
0
        public purchase getorderdetail(int sid)
        {
            query = "select TOP 1  s.po_id , s.t_id, s.p_date, s.l_id, s.p_total, s.p_nettotal , l.l_name";
              query += " from purchase_order s inner join ledger l on s.l_id = l.l_id  where s.po_id = @sid ";
              OleDbCommand cmd = new OleDbCommand(query, con);
              purchase s = new purchase();
              cmd.Parameters.AddWithValue("sid", sid);
              try
              {
              con.Open();
              OleDbDataReader dr = cmd.ExecuteReader();
              dr.Read();

              s.pid = int.Parse(dr.GetValue(0).ToString());
              s.tid = int.Parse(dr.GetValue(1).ToString());
              s.pdate = dr.GetValue(2).ToString();
              s.lid = int.Parse(dr.GetValue(3).ToString());
              s.ptotal = double.Parse(dr.GetValue(4).ToString());
              s.nettotal = double.Parse(dr.GetValue(5).ToString());
              s.lname = dr.GetValue(6).ToString();
              return s;
              }
              catch (Exception e)
              {
              MessageBox.Show(e.ToString());
              return s;
              }
              finally
              {
              con.Close();
              }
        }
Example #2
0
        public purchase getinvoicedetail(int pid)
        {
            query = "select TOP 1  p.p_id , p.t_id, p.p_date, p.l_id, p.tnsp_chg, p.vat_chg, p.discount, p.round_of, p.p_total, p.p_nettotal , l.l_name";
             query += " from purchase p inner join ledger l on p.l_id = l.l_id  where p.p_id = @pid ";
             OleDbCommand cmd = new OleDbCommand(query,con);
              purchase p = new purchase() ;
             cmd.Parameters.AddWithValue("pid",pid);
             try
             {
             con.Open();
             OleDbDataReader dr = cmd.ExecuteReader();
             dr.Read();

             p.pid = int.Parse(dr.GetValue(0).ToString());
             p.tid = int.Parse(dr.GetValue(1).ToString());
             p.pdate = dr.GetValue(2).ToString();
             p.lid = int.Parse(dr.GetValue(3).ToString());
             p.tnsp_chg = dr.GetValue(4).ToString();
             p.vat_chg = dr.GetValue(5).ToString();
             p.discount = dr.GetValue(6).ToString();
             p.roundof = dr.GetValue(7).ToString();
             p.ptotal = double.Parse(dr.GetValue(8).ToString());
             p.nettotal = double.Parse(dr.GetValue(9).ToString());
             p.lname = dr.GetValue(10).ToString();
             return p;
             }
             catch (Exception e)
             {
             MessageBox.Show(e.ToString());
             return p;
             }
             finally
             {
             con.Close();
             }
        }
Example #3
0
 private void btncomitorder_Click(object sender, RoutedEventArgs e)
 {
     if (pc.Count != 0)
     {
         int tid = new transactionmodel().getid();
         purchase s = new purchase()
         {
             tid = tid,
             lid = lid,
             ptotal = total,
             pdate = datePicker1.ToString(),
             pid = vid,
             tnsp_chg = addcharges.ToString(),
             vat_chg = vat.ToString(),
             roundof = roundof.ToString(),
             nettotal = Double.Parse(txttotalamount.Text),
             discount = "0"
         };
         List<purchaseitem> sl = pc.ToList<purchaseitem>();
         purchasemodel sm = new purchasemodel(s, sl, total);
         if (sm.comitorder(comitoid))
         {
             Show("Data Saved",1);
             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 = int.Parse(sm.getvid().ToString());
         }
     }
     else
     {
         Show("Fields Cannot be empty",2);
     }
 }
Example #4
0
 //  int tid, lid,sdate;
 public purchasemodel(purchase pm,List<purchaseitem> pi,Double total)
 {
     this.pi = pi;
       this.total = total;
       this.pm = pm;
 }
Example #5
0
        private void btnorder_Click(object sender, RoutedEventArgs e)
        {
            if (pc.Count != 0)
            {
                // int tid = new transactionmodel().getid();
                purchase s = new purchase()
                {

                    //   tid = tid,
                    lid = lid,
                    ptotal = total,
                    pdate = datePicker1.ToString(),
                    pid = int.Parse(txtorderno.Text),
                    /// tnsp_chg = addcharges.ToString(),
                    //////// vat_chg = vat.ToString(),
                    //  roundof = roundof.ToString(),
                    nettotal = Double.Parse(txttotalamount.Text),
                    //  discount = "0"
                };
                List<purchaseitem> sl = pc.ToList<purchaseitem>();
                purchasemodel sm = new purchasemodel(s, sl, total);
                if (sm.orderinsert())
                {
                    Show("Data Saved", 1);
                    pc.Clear();
                    reset();
                    txtorderno.Text = sm.getordervid().ToString();
                    orderid = int.Parse(txtorderno.Text);
                }
            }
            else
            {
               Show("Fields Cannot be empty",2);
            }
        }