private void spinnerItem_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { Spinner spinner = (Spinner)sender; string [] codedesc = spinner.GetItemAtPosition(e.Position).ToString().Split(new char[] { '|' }); if (codedesc.Length < 2) { return; } string icode = codedesc[0].Trim(); Item item = items.Where(x => x.ICode == icode).FirstOrDefault(); // TextView tax = FindViewById<TextView> (Resource.Id.txttax); // EditText price = FindViewById<EditText> (Resource.Id.txtprice); // EditText qty = FindViewById<EditText> (Resource.Id.txtqty); double uprice = Utility.GetUnitPrice(trd, item); if (txtInvMode.Text != "EDIT") { txtprice.Text = uprice.ToString(); } txttax.Text = item.taxgrp; taxper = item.tax; isInclusive = item.isincludesive; txtqty.RequestFocus(); //ShowKeyBoard (qty as View); }
private void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { Spinner spinner = (Spinner)sender; string [] codedesc = spinner.GetItemAtPosition(e.Position).ToString().Split(new char[] { '|' }); string icode = codedesc[0].Trim(); Item item = items.Where(x => x.ICode == icode).FirstOrDefault(); TextView tax = FindViewById <TextView> (Resource.Id.txttax); EditText price = FindViewById <EditText> (Resource.Id.txtprice); //EditText taxper = FindViewById<EditText> (Resource.Id.txtinvtaxper); //CheckBox isincl = FindViewById<CheckBox> (Resource.Id.txtinvisincl); EditText qty = FindViewById <EditText> (Resource.Id.txtqty); // desc.Text = item.IDesc; if (FIRSTLOAD == "") { double uprice = Utility.GetUnitPrice(trd, item); price.Text = uprice.ToString(); } else { FIRSTLOAD = ""; } tax.Text = item.taxgrp; taxper = item.tax; isInclusive = item.isincludesive; qty.RequestFocus(); //ShowKeyBoard (qty); }
private void AddBarCodeItem(Item prd) { //TextView txtcnno = FindViewById<TextView> (Resource.Id.txtInvnp); double stqQty = 1; double uprice = Utility.GetUnitPrice(trd, prd); double taxval = prd.tax; double amount = Math.Round((stqQty * uprice), 2); double netamount = amount; bool taxinclusice = prd.isincludesive; double taxamt = 0; if (taxinclusice) { double percent = (taxval / 100) + 1; double amt2 = Math.Round(amount / percent, 2, MidpointRounding.AwayFromZero); taxamt = amount - amt2; netamount = amount - taxamt; } else { taxamt = Math.Round(amount * (taxval / 100), 2, MidpointRounding.AwayFromZero); } CNNoteDtls invdtls = new CNNoteDtls(); invdtls.cnno = inv.cnno; invdtls.amount = amount; invdtls.icode = prd.ICode; invdtls.price = uprice; invdtls.qty = stqQty; invdtls.tax = taxamt; invdtls.taxgrp = prd.taxgrp; invdtls.netamount = netamount; invdtls.description = prd.IDesc; //int id = Convert.ToInt32 (ITEMUID); //inv..title = spinner.SelectedItem.ToString (); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno && x.icode == prd.ICode).ToList(); if (list.Count > 0) { list [0].qty = list [0].qty + 1; stqQty = list [0].qty; amount = Math.Round((stqQty * uprice), 2); netamount = amount; if (taxinclusice) { double percent = (taxval / 100) + 1; double amt2 = Math.Round(amount / percent, 2, MidpointRounding.AwayFromZero); taxamt = amount - amt2; netamount = amount - taxamt; } else { taxamt = Math.Round(amount * (taxval / 100), 2, MidpointRounding.AwayFromZero); } list [0].tax = taxamt; list [0].amount = amount; list [0].netamount = netamount; db.Update(list [0]); } else { db.Insert(invdtls); } } spinItem.SetSelection(-1); Toast.MakeText(this, Resources.GetString(Resource.String.msg_itemadded), ToastLength.Long).Show(); }
private void AddBarCodeItem(Item prd) { double stqQty = 1; double uprice = Utility.GetUnitPrice(trd, prd); double taxval = prd.tax; double amount = Math.Round((stqQty * uprice), 2); double netamount = amount; bool taxinclusice = prd.isincludesive; double taxamt = 0; if (taxinclusice) { double percent = (taxval / 100) + 1; double amt2 = Math.Round(amount / percent, 2, MidpointRounding.AwayFromZero); taxamt = amount - amt2; netamount = amount - taxamt; } else { taxamt = Math.Round(amount * (taxval / 100), 2, MidpointRounding.AwayFromZero); } InvoiceDtls inv = new InvoiceDtls(); inv.invno = invno; inv.amount = amount; inv.icode = prd.ICode; inv.price = uprice; inv.qty = stqQty; inv.tax = taxamt; inv.taxgrp = prd.taxgrp; inv.netamount = netamount; inv.description = prd.IDesc; //int id = Convert.ToInt32 (ITEMUID); //inv..title = spinner.SelectedItem.ToString (); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <InvoiceDtls> ().Where(x => x.invno == invno && x.icode == prd.ICode).ToList(); if (list.Count > 0) { list [0].qty = list [0].qty + 1; stqQty = list [0].qty; amount = Math.Round((stqQty * uprice), 2); netamount = amount; if (taxinclusice) { double percent = (taxval / 100) + 1; double amt2 = Math.Round(amount / percent, 2, MidpointRounding.AwayFromZero); taxamt = amount - amt2; netamount = amount - taxamt; } else { taxamt = Math.Round(amount * (taxval / 100), 2, MidpointRounding.AwayFromZero); } list [0].tax = taxamt; list [0].amount = amount; list [0].netamount = netamount; db.Update(list [0]); } else { db.Insert(inv); } } listData = new List <InvoiceDtls> (); populate(listData); listView = FindViewById <ListView> (Resource.Id.invitemList); SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter <InvoiceDtls> (this, listData, Resource.Layout.InvDtlItemViewCS, viewdlg); listView.SetSelection(listView.Count - 1); }