예제 #1
0
파일: salesmodel.cs 프로젝트: sumit10/BMS
        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();
              }
        }
예제 #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();
              }
        }