Exemplo n.º 1
0
        public override bool insert()
        {
            OleDbTransaction ot;
              con.Open();
              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);
              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);
              try
              {
             // int j = 1;
              command.ExecuteNonQuery();
              transactionmodel tm = new transactionmodel(sm.lid, 3, sm.nettotal, sm.nettotal, sm.sdate,"Being good sold  vid = "+sm.sid.ToString());
              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();
              }
        }
Exemplo n.º 2
0
        public bool incertcash(int cid,int lid,double amt,string naration,bool cdr,string date)
        {
            transactionmodel t;
            if (cdr)
            {
                t = new transactionmodel(cid,lid,amt,amt,date,naration);
            }
            else
            {
                t = new transactionmodel(lid, cid, amt, amt, date, naration);
            }

            if (t.insert())
            {
                tid = t.gettid();
                return true;
            }
            return false;
        }
Exemplo n.º 3
0
 public bool createaccount(string name, double ob, string type, string date)
 {
     ledgermodel l;
         int a = -1;
         transactionmodel t;
         bool ldr;
         if (type == "Cash")
         {
             a = 1;
             ldr = true;
         }
         else if(type == "Bank A/c")
         {
             a = 14;
             ldr = true;
         }
         else if (type == "expance")
         {
             a = 12;
             ldr = false;
         }
         else
         {
             a = 15;
             ldr = true;
         }
         l = new ledgermodel(name, a, "", "", "");
         int lid = l.getlid();
         if (ldr)
         {
             t = new transactionmodel(lid, 76, ob, ob, date);
         }
         else
         {
             t = new transactionmodel(76, lid, ob, ob, date);
         }
         OleDbTransaction olt;
       try
     {
         con.Open();
         olt = con.BeginTransaction();
         l.tinsert(con, olt).ExecuteNonQuery();
         t.tinsert(olt, con).ExecuteNonQuery();
         olt.Commit();
         MessageBox.Show("Account Created Succesfull");
         return true;
     }
     catch (Exception e)
     {
         MessageBox.Show("Error " + e.ToString());
         return false;
     }
     finally
     {
         con.Close();
     }
 }
Exemplo n.º 4
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();
              }
        }
Exemplo n.º 5
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();
       }
 }
Exemplo n.º 6
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);
     }
 }
Exemplo n.º 7
0
        public bool insert(UserControl u)
        {
            checkvalid();
               if (validate)
            {
                OleDbTransaction olt;
                con.Open();
                olt = con.BeginTransaction();
                query = " INSERT into [stock](com_name,com_uom,com_pp,com_sp,com_opstock,com_balstock) ";
                query += " VALUES(@comname,@comuom,@compp,@comsp,@comopstock,@combalstock);";
                OleDbCommand command = new OleDbCommand(query, con, olt);
                command.Parameters.AddWithValue("comname", comname);
                command.Parameters.AddWithValue("comuom", uom);
                command.Parameters.AddWithValue("compp", compp);
                command.Parameters.AddWithValue("comsp", comsp);
                command.Parameters.AddWithValue("comopstock", comops);
                command.Parameters.AddWithValue("combalstock", comops);
                int amt = int.Parse(compp) * int.Parse(comops);
                int x = 9; int y = 5;
                transactionmodel tm = new transactionmodel(x,y,amt,amt,tdate);
                OleDbCommand command1 = tm.tinsert(olt,con);
                try
                {

                    command.ExecuteNonQuery();
                    command1.ExecuteNonQuery();
                    olt.Commit();
                    return true;
                }
                catch (Exception a)
                {
                    olt.Rollback();
                    System.Windows.MessageBox.Show(a.ToString());
                    if (a.ToString().IndexOf("duplicate") != -1)
                    {
                        System.Windows.MessageBox.Show("Duplicate value found in Database");
                        e["lname!"] = "duplicate";
                        showerror(e, u);
                    }
                    else
                    {
                        System.Windows.MessageBox.Show(a.ToString());
                    }
                    return false;
                 }
                finally
                {

                    con.Close();
                }
               }
               else
               {
               showerror(e, u);
               return false;
               }
        }
Exemplo n.º 8
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     if (sc.Count != 0)
     {
         int tid = new transactionmodel().getid();
         sales s = new sales()
         {
             tid = tid,
             lid = lid,
             stotal = total,
             sdate = datePicker1.ToString(),
             sid = int.Parse(txtvno.Text),
             tnsp_chg = addcharges.ToString(),
             vat_chg = vat.ToString(),
             roundof = roundof.ToString(),
             nettotal = Double.Parse(txttotalamount.Text),
             discount = "0"
         };
         List<salesitem> sl = sc.ToList<salesitem>();
         salesmodel sm = new salesmodel(s, sl, total);
         if (sm.insert())
         {
             Show("Saved Succesfully",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 = "cr";
             sc.Clear();
             reset();
             txtvno.Text = sm.getvid().ToString();
         }
     }
     else
     {
        Show("Fields cannot be empty",2);
     }
 }