public sales getorderdetail(int sid) { query = "select TOP 1 s.so_id , s.t_id, s.s_date, s.l_id, s.s_total, s.s_nettotal , l.l_name"; query += " from sale_order s inner join ledger l on s.l_id = l.l_id where s.so_id = @sid "; OleDbCommand cmd = new OleDbCommand(query, con); sales s = new sales(); cmd.Parameters.AddWithValue("sid", sid); try { con.Open(); OleDbDataReader dr = cmd.ExecuteReader(); dr.Read(); s.sid = int.Parse(dr.GetValue(0).ToString()); s.tid = int.Parse(dr.GetValue(1).ToString()); s.sdate = dr.GetValue(2).ToString(); s.lid = int.Parse(dr.GetValue(3).ToString()); s.stotal = double.Parse(dr.GetValue(4).ToString()); s.nettotal = double.Parse(dr.GetValue(5).ToString()); s.lname = dr.GetValue(6).ToString(); return s; } catch (Exception e) { MessageBox.Show(e.ToString()); return s; } finally { con.Close(); } }
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); } }
// int tid, lid,sdate; public salesmodel(sales sm,List<salesitem> si,Double total) { this.si = si; this.total = total; this.sm = sm; }
private void btnorder1_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(txtorderno.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.orderinsert()) { Show("Saved Sucessfully",1); sc.Clear(); reset(); txtorderno.Text = sm.getordervid().ToString(); } } else { Show("Please enter some details",2); } }