internal static void FetchDetails(TransHed transHed, IConnection conn) { IPreparedStatement ps = conn.PrepareStatement(@" SELECT rtrans_det.id, rtrans_det.htrn_id, rtrans_det.dtrn_num, rtrans_det.item_id, rtrans_det.qty1, rtrans_det.unit_price, rtrans_det.disc_line1, rtrans_det.net_value, rtrans_det.vat_value, ritems.item_cod, ritems.item_desc, ritems.item_vat FROM rtrans_det JOIN ritems ON ritems.id = rtrans_det.item_id WHERE htrn_id = :htrn_id ORDER BY rtrans_det.id"); ps.Set("htrn_id", transHed.HtrnId); IResultSet result = ps.ExecuteQuery(); if (transHed.TransDetList == null) { transHed.TransDetList = new TransDetList(); } while (result.Next()) { TransDet d = new TransDet(); d.Fetch(result); transHed.TransDetList.Add(d); } result.Close(); ps.Close(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.InvoiceScreen); LoadControls(); //bindingManager = new SimpleApp.BindingManager(this); /*Library.TransHed.NewTransHed((o, a) => * { * if (a.Error == null) * { * _header = a.Object; * DataBind(); * } * else * { * //show error * } * });*/ _header = new Library.TransHed(); DataBind(); }
public void InvoiceSaved(int id) { if (!((TransHedAdapter)ListAdapter).ContainsId(id)) { Library.TransHed header = Library.TransHed.GetTransHed(this.Activity, id); ((TransHedAdapter)ListAdapter).Insert(header, 0); ((TransHedAdapter)ListAdapter).InsertIntoTransHedList(header, 0); } ((TransHedAdapter)ListAdapter).NotifyDataSetChanged(); }
public static TransHed GetTransHed(Context ctx, double htrnId) { TransHed transHed = new TransHed(); if (htrnId == 0) { return(transHed); } using (IConnection conn = Sync.GetConnection(ctx)) { string query = @" SELECT rtrans_hed.id, cust_id, trans_date, vouch_id, voser_id, docnum, htrn_explanation, rcustomer.cst_desc FROM rtrans_hed LEFT OUTER JOIN rcustomer ON rcustomer.id = rtrans_hed.cust_id WHERE rtrans_hed.id = :htrnId "; IPreparedStatement ps = conn.PrepareStatement(query); ps.Set("htrnId", htrnId); IResultSet result = ps.ExecuteQuery(); if (result.Next()) { transHed.Fetch(result); } result.Close(); ps.Close(); FetchDetails(transHed, conn); conn.Commit(); conn.Release(); } return(transHed); }
public void Save(IConnection conn, TransHed header) { CustomerInfo info = new CustomerInfo(); IPreparedStatement ps; if (IsNew) { if (IsDeleted) { return; } ps = conn.PrepareStatement(@"INSERT INTO rtrans_det ( htrn_id, dtrn_num, item_id, qty1, unit_price, disc_line1, net_value, vat_value ) VALUES ( :htrn_id ,:dtrn_num ,:item_id ,:dtrn_qty1 ,:dtrn_unit_price ,:dtrn_disc_line1 ,:dtrn_net_value ,:dtrn_vat_value )"); ps.Set("htrn_id", header.HtrnId); ps.Set("dtrn_num", DtrnNum); ps.Set("item_id", ItemId); ps.Set("dtrn_qty1", DtrnQty1); ps.Set("dtrn_unit_price", DtrnUnitPrice); ps.Set("dtrn_disc_line1", DtrnDiscLine1); ps.Set("dtrn_net_value", DtrnNetValue); ps.Set("dtrn_vat_value", DtrnVatValue); ps.Execute(); ps = conn.PrepareStatement(@"SELECT TOP 1 id FROM rtrans_det ORDER BY id DESC"); IResultSet rs = ps.ExecuteQuery(); if (rs.Next()) { DtrnId = rs.GetInt("id"); } } else if (IsDeleted) { ps = conn.PrepareStatement(@" DELETE FROM rtrans_det WHERE id = :dtrn_id "); ps.Set("dtrn_id", DtrnId); ps.Execute(); } else { ps = conn.PrepareStatement(@" UPDATE rtrans_det SET htrn_id = :htrn_id ,dtrn_num = :dtrn_num ,item_id = :item_id ,qty1 = :dtrn_qty1 ,unit_price = :dtrn_unit_price ,disc_line1 = :dtrn_disc_line1 ,net_value = :dtrn_net_value ,vat_value = :dtrn_vat_value WHERE id = :dtrn_id "); ps.Set("dtrn_id", DtrnId); ps.Set("htrn_id", header.HtrnId); ps.Set("dtrn_num", DtrnNum); ps.Set("item_id", ItemId); ps.Set("dtrn_qty1", DtrnQty1); ps.Set("dtrn_unit_price", DtrnUnitPrice); ps.Set("dtrn_disc_line1", DtrnDiscLine1); ps.Set("dtrn_net_value", DtrnNetValue); ps.Set("dtrn_vat_value", DtrnVatValue); ps.Execute(); } ps.Close(); }