Example #1
0
 public override bool insert()
 {
     OleDbTransaction ot;
       con.Open();
       query += " INSERT into [purchase]( p_id,s_invoiceno, t_id, p_date, l_id, tnsp_chg, vat_chg, discount, round_of, p_total, p_nettotal)";
       query += " VALUES(@pid,@si,@tid,@pdate,@lid,@tnsp_chg,@vat,@discount,@roundof,@ptotal,@snettotal);";
       ot = con.BeginTransaction();
       OleDbCommand command = new OleDbCommand(query, con, ot);
       command.Parameters.AddWithValue("pid", pm.pid);
       command.Parameters.AddWithValue("si", pm.sinvoiceno);
       command.Parameters.AddWithValue("tid", pm.tid);
       command.Parameters.AddWithValue("sdate", pm.pdate);
       command.Parameters.AddWithValue("lid", pm.lid);
       command.Parameters.AddWithValue("tnsp_chg", pm.tnsp_chg);
       command.Parameters.AddWithValue("vat", pm.vat_chg);
       command.Parameters.AddWithValue("discount", pm.discount);
       command.Parameters.AddWithValue("roundof", pm.roundof);
       command.Parameters.AddWithValue("stotal", pm.ptotal);
       command.Parameters.AddWithValue("snettotal", pm.nettotal);
       try
       {
      // int j = 1;
       command.ExecuteNonQuery();
       transactionmodel tm = new transactionmodel(2,pm.lid, pm.nettotal, pm.nettotal, pm.pdate,"Being good purchase of v_id : "+pm.pid.ToString());
       tm.tinsert(ot, con).ExecuteNonQuery();
       foreach (purchaseitem i in pi)
       {
            purchaseitemmodel pim = new purchaseitemmodel(i);
            pim.insert(ot, con).ExecuteNonQuery();
            commoditymodel com = new commoditymodel(i.pcomid);
            com.setbalquanty_purchase((Double)i.pqnty, ot, con).ExecuteNonQuery();
       }
       //if (sm.vat_chg != "" || sm.vat_chg != null)
       //{
       //    transactionmodel tm1 = new transactionmodel(sm.tid + 1, sm.lid, 89, Double.Parse(sm.vat_chg), Double.Parse(sm.vat_chg), sm.sdate);
       //    tm1.tinsert(ot, con).ExecuteNonQuery();
       //    j++;
       //}
       //if (sm.tnsp_chg != "" || sm.tnsp_chg != null)
       //{
       //    transactionmodel tm1 = new transactionmodel(sm.tid + j, sm.lid, 85, Double.Parse(sm.tnsp_chg), Double.Parse(sm.tnsp_chg), sm.sdate);
       //    tm1.tinsert(ot, con).ExecuteNonQuery();
       //    j++;
       //}
       ot.Commit();
       return true;
       }
       catch (Exception e)
       {
       MessageBox.Show(e.ToString());
       return false;
       }
       finally
       {
       con.Close();
       }
 }
Example #2
0
 public bool orderinsert()
 {
     OleDbTransaction ot;
       con.Open();
       query += " INSERT into [purchase_order](po_id,t_id,p_date,l_id,p_total,p_nettotal)";
       query += " VALUES(@sid,@tid,@sdate,@lid,@stotal,@snettotal);";
       ot = con.BeginTransaction();
       OleDbCommand command = new OleDbCommand(query, con, ot);
       command.Parameters.AddWithValue("sid", pm.pid);
       command.Parameters.AddWithValue("tid", pm.tid);
       command.Parameters.AddWithValue("sdate", pm.pdate);
       command.Parameters.AddWithValue("lid", pm.lid);
       command.Parameters.AddWithValue("stotal", pm.ptotal);
       command.Parameters.AddWithValue("snettotal", pm.nettotal);
       try
       {
       // int j = 1;
       command.ExecuteNonQuery();
       // transactionmodel tm = new transactionmodel(sm.lid, 3, sm.nettotal, sm.nettotal, sm.sdate);
       // tm.tinsert(ot, con).ExecuteNonQuery();
       foreach (purchaseitem i in pi)
       {
           purchaseitemmodel sim = new purchaseitemmodel(i);
           sim.orderinsert(ot, con).ExecuteNonQuery();
           //  commoditymodel com = new commoditymodel(i.scomid);
           //  com.setbalquanty_sale((Double)i.sqnty, ot, con).ExecuteNonQuery();
       }
       //if (sm.vat_chg != "" || sm.vat_chg != null)
       //{
       //    transactionmodel tm1 = new transactionmodel(sm.tid + 1, sm.lid, 89, Double.Parse(sm.vat_chg), Double.Parse(sm.vat_chg), sm.sdate);
       //    tm1.tinsert(ot, con).ExecuteNonQuery();
       //    j++;
       //}
       //if (sm.tnsp_chg != "" || sm.tnsp_chg != null)
       //{
       //    transactionmodel tm1 = new transactionmodel(sm.tid + j, sm.lid, 85, Double.Parse(sm.tnsp_chg), Double.Parse(sm.tnsp_chg), sm.sdate);
       //    tm1.tinsert(ot, con).ExecuteNonQuery();
       //    j++;
       //}
       ot.Commit();
       return true;
       }
       catch (Exception e)
       {
       MessageBox.Show(e.ToString());
       return false;
       }
       finally
       {
       con.Close();
       }
 }
Example #3
0
        private void lst_report_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lst_report.SelectedValue != null)
            {

                lbl_header.Content = "Purchase Invoice";
                purchasereport sr = (purchasereport)lst_report.SelectedValue;
                purchase s;
                if (invoicedetail)
                {
                    listBox2.ItemsSource = new purchaseitemmodel().getinvoicedetail(int.Parse(sr.vid));
                    s = new purchasemodel().getinvoicedetail(int.Parse(sr.vid));
                    rp_datePicker.Text = s.pdate;
                    rp_customer.Content = s.lname;
                    rp_round.Content = s.roundof;
                    rp_tnsp.Content = s.tnsp_chg;
                    rp_total.Content = s.ptotal;
                    rp_vatrate.Content = s.vat_chg;
                    rp_vno.Content = s.pid.ToString();
                    rp_vat.Content = (Math.Round(double.Parse(s.vat_chg) / s.ptotal * 100, 2)).ToString();
                    purchase_report.Visibility = Visibility.Hidden;
                    invoice_details.Visibility = Visibility.Visible;
                }
                else
                {
                    reset();
                    List<purchaseitem> soc = new purchaseitemmodel().getorderedetail(int.Parse(sr.vid));
                    foreach (var item in soc)
                    {

                        purchaseitem sa = new purchaseitem()
                        {
                            pid = vid,
                            pcomname = item.pcomname,
                            pcomid = item.pcomid,
                            pqnty = item.pqnty,
                            puom = item.puom,
                            prate = item.prate,
                            pamt = item.pamt,
                        };
                        pc.Add(sa);
                    }
                    s = new purchasemodel().getorderdetail(int.Parse(sr.vid));
                    purchase_report.Visibility = Visibility.Hidden;
                    purchase.Visibility = Visibility.Visible;
                    invoicenumber();
                    btncomitorder.Visibility = Visibility.Visible;
                    button1.Visibility = Visibility.Hidden;
                    txtcustomer.Text = s.lname;
                    txttotalamount.Text = s.nettotal.ToString();
                    total = s.ptotal;
                    lid = s.lid;
                    comitoid = s.pid;
                    txtacrate.Focus();
                }
            }
        }