private void Window_Loaded(object sender, RoutedEventArgs e) { List<stock> sc = new commoditymodel().getstock(); List<chartdata> cd = new List<chartdata>(); foreach (stock s in sc) { int a = int.Parse(Math.Round(s.balstock, 0).ToString()); chartdata c = new chartdata() { name = s.name, value = a }; cd.Add(c); } barseries.ItemsSource = cd; }
public stockview() { commoditymodel cm = new commoditymodel(); InitializeComponent(); autocomplete.fillcombo(cmbuom, "u_sym", "uom"); OleDbDataReader dr = cm.getcom(); while (dr.Read()) { stockdata sd = new stockdata() { Cid = int.Parse(dr.GetValue(0).ToString()), Cname = dr.GetValue(1).ToString(), Cuom = dr.GetValue(2).ToString(), Cpp = dr.GetValue(3).ToString(), Csp = dr.GetValue(4).ToString(), Copstock = dr.GetValue(5).ToString(), Cbalstock = dr.GetValue(6).ToString() }; sc.Add(sd); } listBox1.ItemsSource = sc; }
private void button2_Click_1(object sender, RoutedEventArgs e) { if (cmbuom.SelectedItem != null && dpdate.SelectedDate != null) { cmbuom.ClearValue(ComboBox.BorderBrushProperty); dpdate.ClearValue(DatePicker.BorderBrushProperty); commoditymodel cm = new commoditymodel(txtconame.Text, cmbuom.SelectedValue.ToString(), txtcopp.Text, txtcosp.Text, txtcoops.Text, dpdate.Text); if (cm.insert(this)) { Show("Saved Succesfully",1); } else { //dashboard d = new dashboard(); ////////////////////cm.showerror(error, this); } } else { cmbuom.BorderBrush = Brushes.Red; dpdate.BorderBrush = Brushes.Red; } }
private void btn_update_Click(object sender, RoutedEventArgs e) { if (txtconame.Text == "" || cmbuom.SelectedValue == null || txtcopp.Text == "" || txtcosp.Text == "") { Show("Please fill all Field",2); return; } commoditymodel cm = new commoditymodel(txtconame.Text,cmbuom.SelectedValue.ToString(),txtcopp.Text,txtcosp.Text,"null","null",s.Cid); if (cm.update(this)) { Show("Successfully Updated",1); btn_edit.IsEnabled = true; btn_update.Visibility = Visibility.Hidden; edittoggle(false); var x = sc.FirstOrDefault(i => i.Cid == s.Cid); x.Cname = txtconame.Text; } }
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(); } }
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(); } }
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(); } }