Пример #1
0
 public bool orderinsert()
 {
     OleDbTransaction ot;
       con.Open();
       query += " INSERT into [sale_order](so_id,t_id,s_date,l_id,s_total,s_nettotal)";
       query += " VALUES(@sid,@tid,@sdate,@lid,@stotal,@snettotal);";
       ot = con.BeginTransaction();
       OleDbCommand command = new OleDbCommand(query, con, ot);
       command.Parameters.AddWithValue("sid", sm.sid);
       command.Parameters.AddWithValue("tid", sm.tid);
       command.Parameters.AddWithValue("sdate", sm.sdate);
       command.Parameters.AddWithValue("lid", sm.lid);
       command.Parameters.AddWithValue("stotal", sm.stotal);
       command.Parameters.AddWithValue("snettotal", sm.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 (salesitem i in si)
       {
           salesitemmodel sim = new salesitemmodel(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();
       }
 }
Пример #2
0
        public override bool insert()
        {
            OleDbTransaction ot;
              con.Open();
              ot = con.BeginTransaction();
              try
              {
              int j = 1;
              transactionmodel tm = new transactionmodel(si[0].lid, 3, total, total, si[0].sdate);
              tm.tinsert(ot, con).ExecuteNonQuery();
              foreach (salesitem i in si)
              {
                  if (i.scomid != 0)
                  {
                      salesitemmodel sim = new salesitemmodel(i.tid, (Double)i.samt, i.scomid, i.srate, i.lid, i.suom, (Double)i.sqnty, i.vid, (Double)i.vtotal, i.sdate);
                      sim.insert(ot, con).ExecuteNonQuery();
                      commoditymodel com = new commoditymodel(i.scomid);
                      com.setbalquanty_sale((Double)i.sqnty, ot, con).ExecuteNonQuery();
                  }
                  else if (i.ex_type == "+")
                  {
                      i.tid = i.tid + j;
                     salesitemmodel sim = new salesitemmodel(i.tid,i.samt, 0, i.srate, i.lid, "", 0, i.vid, i.vtotal, i.sdate);
                     sim.insert(ot, con).ExecuteNonQuery();
                     transactionmodel tm1 = new transactionmodel(i.tid,si[0].lid,i.lid , (int)i.samt, (int)i.samt, i.sdate);
                     tm1.tinsert(ot, con).ExecuteNonQuery();
                      j++;
                  }
                  //else
                  //  {
                  //    i.tid = i.tid + i;
                  //   salesitemmodel sim = new salesitemmodel(i.tid,(int)i.samt, i.scomid, i.srate, i.lid, i.suom, int.Parse(i.sqnty), i.vid, i.vtotal, i.sdate);
                  //   sim.insert(ot, con).ExecuteNonQuery();
                  //   transactionmodel tm = new transactionmodel(i.lid, 3, i.samt, i.samt, i.sdate);
                  //   tm.tinsert(ot, con).ExecuteNonQuery();
                  //    i++;
                  //  }
              }

              ot.Commit();
              MessageBox.Show("Save ho gaya ");
              return true;
              }
              catch (Exception e)
              {
              MessageBox.Show(e.ToString());
              return false;
              }
              finally
              {
              con.Close();
              }
        }
Пример #3
0
 public bool comitorder(int oid)
 {
     OleDbTransaction ot;
       con.Open();
       String s = "DELETE FROM sale_order WHERE so_id=@soid";
       String s1 = "DELETE FROM saleorder_detail WHERE so_id=@soid";
       query += " INSERT into [sale](s_id,t_id,s_date,l_id,tnsp_chg,vat_chg,discount,round_of,s_total,s_nettotal)";
       query += " VALUES(@sid,@tid,@sdate,@lid,@tnsp_chg,@vat,@discount,@roundof,@stotal,@snettotal);";
       ot = con.BeginTransaction();
       OleDbCommand command = new OleDbCommand(query, con, ot);
       OleDbCommand command1 = new OleDbCommand(s, con, ot);
       OleDbCommand command2 = new OleDbCommand(s1, con, ot);
       command.Parameters.AddWithValue("sid", sm.sid);
       command.Parameters.AddWithValue("tid", sm.tid);
       command.Parameters.AddWithValue("sdate", sm.sdate);
       command.Parameters.AddWithValue("lid", sm.lid);
       command.Parameters.AddWithValue("tnsp_chg", sm.tnsp_chg);
       command.Parameters.AddWithValue("vat", sm.vat_chg);
       command.Parameters.AddWithValue("discount", sm.discount);
       command.Parameters.AddWithValue("roundof", sm.roundof);
       command.Parameters.AddWithValue("stotal", sm.stotal);
       command.Parameters.AddWithValue("snettotal", sm.nettotal);
       command1.Parameters.AddWithValue("soid", oid);
       command2.Parameters.AddWithValue("soid", oid);
       try
       {
           // int j = 1;
           command.ExecuteNonQuery();
           command1.ExecuteNonQuery();
           command2.ExecuteNonQuery();
           transactionmodel tm = new transactionmodel(sm.lid, 3, sm.nettotal, sm.nettotal, sm.sdate, "Being good sold  vid = " + sm.sid.ToString() +" by sale order ="+oid);
           tm.tinsert(ot, con).ExecuteNonQuery();
           foreach (salesitem i in si)
           {
               salesitemmodel sim = new salesitemmodel(i);
               sim.insert(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();
       }
 }
Пример #4
0
        private void lst_report_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lst_report.SelectedValue != null)
            {

                lbl_header.Content = "Sales Invoice";
                salesreport sr = (salesreport)lst_report.SelectedValue;
                sales s;
                if (invoicedetail)
                {
                    listBox2.ItemsSource = new salesitemmodel().getinvoicedetail(int.Parse(sr.vid));
                    s = new salesmodel().getinvoicedetail(int.Parse(sr.vid));
                    rp_datePicker.Text = s.sdate;
                    rp_customer.Content = s.lname;
                    rp_round.Content = s.roundof;
                    rp_tnsp.Content = s.tnsp_chg;
                    rp_total.Content = s.stotal;
                    rp_vatrate.Content = s.vat_chg;
                    rp_vno.Content = s.sid.ToString();
                    lid = s.lid;
                    rp_vat.Content = (Math.Round(double.Parse(s.vat_chg) / s.stotal * 100, 2)).ToString();
                    sales_report.Visibility = Visibility.Hidden;
                    invoice_details.Visibility = Visibility.Visible;
                }
                else
                {
                    reset();
                    List<salesitem> soc = new salesitemmodel().getorderedetail(int.Parse(sr.vid));
                    foreach (var item in soc)
                    {

                        salesitem sa = new salesitem()
                        {
                            sid = int.Parse(txtvno.Text),
                            scomname = item.scomname,
                            scomid = item.scomid,
                            sqnty = item.sqnty,
                             suom = item.suom,
                            srate = item.srate,
                            samt = item.samt,
                        };
                        sc.Add(sa);
                    }
                    s = new salesmodel().getorderdetail(int.Parse(sr.vid));
                    sales_report.Visibility = Visibility.Hidden;
                    ((Storyboard)this.Resources["common_sale"]).Begin();
                    invoicenumber();
                    btncomitorder.Visibility = Visibility.Visible;
                    button1.Visibility = Visibility.Hidden;
                    txtcustomer.Text = s.lname;
                    txttotalamount.Text = s.nettotal.ToString();
                    total = s.stotal;
                    lid = s.lid;
                    comitoid = s.sid;
                    txtacrate.Focus();
                }
            }
        }