void Printreceipt() { InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection(pathToDatabase)){ var ls = db.Table <InvoiceDtls> ().Where(x => x.invno == inv.invno).ToList <InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo(list); } //mmDevice = null; //findBTPrinter (); IPrintDocument prtInv = PrintDocManager.GetPrintDocument <PrintInvoice>(); prtInv.SetDocument(inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy(1); prtInv.SetCallingActivity(this); if (prtInv.StartPrint()) { updatePrintedStatus(inv); } else { Toast.MakeText(this, prtInv.GetErrMsg(), ToastLength.Long).Show(); } }
void PrintInv(Invoice inv, int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection(pathToDatabase)){ var ls = db.Table <InvoiceDtls> ().Where(x => x.invno == inv.invno).ToList <InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo(list); } //mmDevice = null; //findBTPrinter (); IPrintDocument prtInv = PrintDocManager.GetPrintDocument <PrintInvoice>(); prtInv.SetDocument(inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy(noofcopy); prtInv.SetCallingActivity(this); if (prtInv.StartPrint()) { updatePrintedStatus(inv); var found = listData.Where(x => x.invno == inv.invno).ToList(); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter <Invoice> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } else { Toast.MakeText(this, prtInv.GetErrMsg(), ToastLength.Long).Show(); } }
public void PrintTaxSumm(ref string test,InvoiceDtls[] list ) { List<Item> list2 = new List<Item> (); using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { list2 = db.Table<Item> ().ToList<Item> (); } var grp = from p in list group p by p.taxgrp into g select new {taxgrp = g.Key, ttltax = g.Sum (x => x.tax),ttlAmt = g.Sum (v => v.netamount)}; test += "------------------------------------------------\r"; test += "SUMMARY TAX GROUP AMOUNT TAX AMT \r"; test += "------------------------------------------------\r"; // 12345678 123456789012345 123456789012 1234567890 string pline=""; foreach (var g in grp) { var list3 =list2.Where (x => x.taxgrp == g.taxgrp).ToList (); if (list3.Count > 0) { string stax = g.taxgrp.Trim () + " @ " + list3 [0].tax.ToString () + "%"; pline = pline + stax.PadRight (15,' '); } else pline = pline + g.taxgrp.Trim().PadRight (15, ' '); pline = pline + g.ttlAmt.ToString("n2").PadLeft(12, ' ')+" "; pline = pline + g.ttltax.ToString("n2").PadLeft(10, ' '); test += "".PadRight(9,' ')+pline + "\r"; pline = ""; } }
void populate(List <InvoiceDtls> list) { list.Clear(); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list2 = db.Table <InvoiceDtls>().Where(x => x.invno == inv.invno) .OrderByDescending(x => x.ID) .ToList <InvoiceDtls>(); ttlamt = 0; ttltax = 0; foreach (var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } InvoiceDtls inv1 = new InvoiceDtls(); inv1.icode = "TAX"; inv1.netamount = ttltax; InvoiceDtls inv2 = new InvoiceDtls(); inv2.icode = "AMOUNT"; inv2.netamount = ttlamt; list.Add(inv1); list.Add(inv2); } }
private void SetViewDelegate(View view, object clsobj) { InvoiceDtls item = (InvoiceDtls)clsobj; string sqty = item.qty == 0?"": item.qty.ToString(); string sprice = item.price == 0?"": item.price.ToString("n2"); if (item.icode == "TAX" || item.icode == "AMOUNT") { view.FindViewById <LinearLayout> (Resource.Id.linearLayout1).Visibility = ViewStates.Gone; view.FindViewById <LinearLayout> (Resource.Id.linearLayout2).Visibility = ViewStates.Visible; view.FindViewById <TextView> (Resource.Id.invitemdesc).Visibility = ViewStates.Gone; view.FindViewById <TextView> (Resource.Id.invitemTemp1).Text = item.description; view.FindViewById <TextView> (Resource.Id.invitemTemp2).Text = item.netamount.ToString("n2"); } else { view.FindViewById <LinearLayout> (Resource.Id.linearLayout2).Visibility = ViewStates.Gone; view.FindViewById <LinearLayout> (Resource.Id.linearLayout1).Visibility = ViewStates.Visible; view.FindViewById <TextView> (Resource.Id.invitemdesc).Visibility = ViewStates.Visible; view.FindViewById <TextView> (Resource.Id.invitemdesc).Text = item.description; view.FindViewById <TextView> (Resource.Id.invitemcode).Text = item.icode; view.FindViewById <TextView> (Resource.Id.invitemtax).Text = item.tax.ToString("n2"); view.FindViewById <TextView> (Resource.Id.invitemprice).Text = sprice; view.FindViewById <TextView> (Resource.Id.invitemamt).Text = item.netamount.ToString("n2"); view.FindViewById <TextView> (Resource.Id.invitemqty).Text = sqty; view.FindViewById <TextView> (Resource.Id.invitemtaxgrp).Text = item.taxgrp; } }
public string PrintDetail(InvoiceDtls itm, int count) { string test = ""; string desc = itm.description; string pline2 = itm.icode.ToUpper() + "\n" + desc.ToUpper().Trim() + "\n"; pline2 = pline2 + count.ToString().PadRight(3, ' '); if (itm.qty < 0) { string sqty = "(EX)" + itm.qty.ToString().Trim(); pline2 = pline2 + sqty.PadLeft(9, ' ') + " "; } else { pline2 = pline2 + itm.qty.ToString().PadLeft(9, ' ') + " "; } pline2 = pline2 + Math.Round(itm.price, 2).ToString("n2").PadLeft(8, ' ') + " "; string stax = Math.Round(itm.tax, 2).ToString("n2") + " " + itm.taxgrp; pline2 = pline2 + stax.PadLeft(10, ' ') + " "; pline2 = pline2 + Math.Round(itm.netamount, 2).ToString("n2").PadLeft(9, ' '); test += pline2 + "\n"; return(test); }
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { InvoiceDtls item = listData.ElementAt(e.Position); if (item.icode.IndexOf("TAX") > -1) { return; } if (item.icode.IndexOf("AMOUNT") > -1) { return; } PopupMenu menu = new PopupMenu(e.Parent.Context, e.View); menu.Inflate(Resource.Menu.popupItem); menu.Menu.RemoveItem(Resource.Id.popadd); menu.MenuItemClick += (s1, arg1) => { if (arg1.Item.ItemId == Resource.Id.popdelete) { Delete(item); } else if (arg1.Item.ItemId == Resource.Id.popedit) { EditItem(item.invno, item.ID); } }; menu.Show(); }
void Delete(InvoiceDtls invdtls) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete) + "?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(invdtls); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { InvoiceDtls item = listData.ElementAt(e.Position); if (item.icode.IndexOf("TAX") > -1) { return; } if (item.icode.IndexOf("AMOUNT") > -1) { return; } PopupMenu menu = new PopupMenu(e.Parent.Context, e.View); menu.Inflate(Resource.Menu.popupItem); if (!rights.InvAllowAdd) { menu.Menu.RemoveItem(Resource.Id.popadd); } if (!rights.InvAllowEdit) { menu.Menu.RemoveItem(Resource.Id.popedit); } if (!rights.InvAllowDelete) { menu.Menu.RemoveItem(Resource.Id.popdelete); } //if allow edit and Invoice printed, remove edit //printed invoice not allow to edit if (isNotAllowEditAfterPrinted) { menu.Menu.RemoveItem(Resource.Id.popedit); menu.Menu.RemoveItem(Resource.Id.popdelete); menu.Menu.RemoveItem(Resource.Id.popadd); } menu.MenuItemClick += (s1, arg1) => { if (arg1.Item.ItemId == Resource.Id.popadd) { NewItem(item.invno); } else if (arg1.Item.ItemId == Resource.Id.popedit) { Edit(item); } else if (arg1.Item.ItemId == Resource.Id.popdelete) { Delete(item); } }; menu.Show(); }
void populate(List <InvoiceDtls> list) { list.Clear(); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list2 = db.Table <InvoiceDtls> () .Where(x => x.invno == inv.invno) .OrderByDescending(x => x.ID) .ToList <InvoiceDtls> (); ttlamt = 0; ttltax = 0; foreach (var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } double roundVal = 0; double ttlNet = Utility.AdjustToNear(ttlamt + ttltax, ref roundVal); InvoiceDtls inv1 = new InvoiceDtls(); inv1.icode = "TAX"; inv1.netamount = ttlamt; inv1.description = "TOTAL EXCL GST"; InvoiceDtls inv2 = new InvoiceDtls(); inv2.icode = "AMOUNT"; inv2.netamount = ttltax; inv2.description = "TOTAL 6% GST"; InvoiceDtls inv3 = new InvoiceDtls(); inv3.icode = "TAX"; inv3.netamount = ttlamt + ttltax; inv3.description = "TOTAL INCL GST"; InvoiceDtls inv4 = new InvoiceDtls(); inv4.icode = "AMOUNT"; inv4.netamount = roundVal; inv4.description = "ROUNDING ADJUST"; InvoiceDtls inv5 = new InvoiceDtls(); inv5.icode = "AMOUNT"; inv5.netamount = ttlNet; inv5.description = "NET TOTAL"; list.Add(inv1); list.Add(inv2); list.Add(inv3); if (TRXTYPE == "CASH") { list.Add(inv4); list.Add(inv5); } } }
void Edit(InvoiceDtls inv) { //var intent = new Intent(this, typeof(EntryActivity)); var intent = ActivityManager.GetActivity <EntryActivityEx>(this.ApplicationContext); intent.PutExtra("invoiceno", inv.invno); intent.PutExtra("trxtype", TRXTYPE); intent.PutExtra("itemuid", inv.ID.ToString()); intent.PutExtra("editmode", "EDIT"); intent.PutExtra("customer", CUSTNAME); intent.PutExtra("custcode", CUSTCODE); StartActivity(intent); }
public string PrintDetail_NTax(InvoiceDtls itm,int count) { string test = ""; string desc = itm.description; string pline2 = desc.ToUpper().Trim()+ "\n"; pline2 = pline2 + count.ToString ().PadRight (4, ' '); if (itm.qty < 0) { string sqty = "(EX)"+itm.qty.ToString ().Trim () ; pline2 = pline2 +sqty.PadLeft (9, ' ')+" "; }else pline2 = pline2 + itm.qty.ToString ().PadLeft (9, ' ')+" "; pline2 = pline2 + Math.Round (itm.price, 2).ToString ("n2").PadLeft (12, ' ')+" "; pline2 = pline2 + Math.Round (itm.netamount, 2).ToString ("n2").PadLeft (14, ' '); test += pline2 + "\n"; return test; }
private void LoadData(string invno, string uid) { TextView txtInvNo = FindViewById <TextView> (Resource.Id.txtInvnp); Spinner spinner = FindViewById <Spinner> (Resource.Id.txtcode); EditText qty = FindViewById <EditText> (Resource.Id.txtqty); //TextView desc = FindViewById<TextView> (Resource.Id.txtdesc); EditText price = FindViewById <EditText> (Resource.Id.txtprice); EditText amount = FindViewById <EditText> (Resource.Id.txtamount); //EditText taxper = FindViewById<EditText> (Resource.Id.txtinvtaxper); EditText taxamt = FindViewById <EditText> (Resource.Id.txttaxamt); //CheckBox isincl = FindViewById<CheckBox> (Resource.Id.txtinvisincl); TextView tax = FindViewById <TextView> (Resource.Id.txttax); int id = Convert.ToInt32(uid); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var invlist = db.Table <InvoiceDtls> ().Where(x => x.invno == invno && x.ID == id).ToList <InvoiceDtls> (); if (invlist.Count > 0) { InvoiceDtls invItem = invlist [0]; //int index = dataAdapter.GetPosition (invItem.icode + " | " + invItem.description); int index = -1; if (invItem.description.Length > 40) { index = dataAdapter.GetPosition(invItem.icode + " | " + invItem.description.Substring(0, 40) + "..."); } else { index = dataAdapter.GetPosition(invItem.icode + " | " + invItem.description); } Item item = items.Where(x => x.ICode == invItem.icode).FirstOrDefault(); spinner.SetSelection(index); qty.Text = invItem.qty.ToString(); price.Text = invItem.price.ToString(); taxamt.Text = invItem.tax.ToString(); tax.Text = item.taxgrp; taxper = item.tax; isInclusive = item.isincludesive; //taxper.Text = item.tax.ToString (); // isincl.Checked = item.isincludesive; amount.Text = invItem.amount.ToString(); price.Text = invItem.price.ToString(); } } }
public string PrintDetail(InvoiceDtls itm,int count) { string test = ""; string desc = itm.description; string pline2 =itm.icode.ToUpper()+"\n"+desc.ToUpper().Trim()+ "\n"; pline2 = pline2 + count.ToString ().PadRight (3, ' '); if (itm.qty < 0) { string sqty = "(EX)"+itm.qty.ToString ().Trim () ; pline2 = pline2 +sqty.PadLeft (9, ' ')+" "; }else pline2 = pline2 + itm.qty.ToString ().PadLeft (9, ' ')+" "; pline2 = pline2 + Math.Round (itm.price, 2).ToString ("n2").PadLeft (8, ' ')+" "; string stax=Math.Round (itm.tax, 2).ToString ("n2") +" "+ itm.taxgrp; pline2 = pline2 + stax.PadLeft (10, ' ') + " "; pline2 = pline2 + Math.Round (itm.netamount, 2).ToString ("n2").PadLeft (9, ' '); test += pline2 + "\n"; return test; }
void DeleteItem(InvoiceDtls invdtls) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <InvoiceDtls>().Where(x => x.invno == invdtls.invno && x.ID == invdtls.ID).ToList <InvoiceDtls>(); if (list.Count > 0) { db.Delete(list [0]); RefreshItemList(); // var arrlist= listData.Where(x=>x.invno==invdtls.invno&& x.ID==invdtls.ID).ToList<InvoiceDtls>(); // if (arrlist.Count > 0) { // listData.Remove (arrlist [0]); // SetViewDlg viewdlg = SetViewDelegate; // listView.Adapter = new GenericListAdapterEx<InvoiceDtls> (this, listData, Resource.Layout.InvDtlItemViewCS, viewdlg); // } } } }
void EditItem(InvoiceDtls invdtls) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <InvoiceDtls>().Where(x => x.invno == invdtls.invno && x.ID == invdtls.ID).ToList <InvoiceDtls>(); if (list.Count > 0) { txtqty.Text = list [0].qty.ToString(); txtprice.Text = list [0].price.ToString("n2"); int pos1 = 0; if (list [0].description.Length > 40) { pos1 = dAdapterItem.GetPosition(list [0].icode + " | " + list [0].description.Substring(0, 40) + "..."); } else { pos1 = dAdapterItem.GetPosition(list [0].icode + " | " + list [0].description); } spinItem.SetSelection(pos1); spinItem.Enabled = false; butFindItem.Enabled = false; IsEdit = true; IDdtls = list [0].ID; txtInvMode.Text = "EDIT"; //txtprice.Text = list [0].price.ToString("n2"); spinQty.SetSelection(0); if (list [0].qty < 0) { spinQty.SetSelection(1); } if (list [0].price == 0) { spinQty.SetSelection(2); } txtqty.RequestFocus(); txtqty.SelectAll(); } } }
private void GetInvoiceText(Invoice inv, InvoiceDtls[] list) { prtcompHeader.PrintCompHeader (ref text); prtCustHeader.PrintCustomerInv (ref text, inv); prtHeader.PrintHeader_NTax (ref text, inv); string dline = ""; double ttlAmt = 0; double ttltax = 0; int count = 0; foreach (InvoiceDtls itm in list) { count += 1; dline = dline + prtDetail.PrintDetail_NTax (itm, count); ttlAmt = ttlAmt + itm.netamount; ttltax = ttltax + itm.tax; } text += dline; prtTotal.PrintTotal_NTax (ref text, ttlAmt, ttltax); prtFooter.PrintFooter (ref text); text += "\nTHANK YOU\n\n\n\n\n\n\n\n"; }
public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView; // re-use an existing view, if one is available // otherwise create a new one if (view == null) { view = context.LayoutInflater.Inflate(_viewID, parent, false); } T item = Filterlist[position]; if (item != null) { _dlg.Invoke(view, item); } InvoiceDtls itmcode = item as InvoiceDtls; if (itmcode.icode == "TAX" || itmcode.icode == "AMOUNT") { view.SetBackgroundColor(Color.WhiteSmoke); SetChildFontColor(view, Color.DarkBlue); } else { if (position % 2 == 1) { view.SetBackgroundResource(Resource.Drawable.listview_selector_even); SetChildFontColor(view, Color.White); } else { view.SetBackgroundResource(Resource.Drawable.listview_selector_odd); SetChildFontColor(view, Color.Black); } } return(view); }
private void SetViewDelegate(View view, object clsobj) { InvoiceDtls item = (InvoiceDtls)clsobj; string sqty = item.qty == 0?"": item.qty.ToString(); string sprice = item.price == 0?"": item.price.ToString("n2"); view.FindViewById <TextView> (Resource.Id.invitemcode).Text = item.icode; view.FindViewById <TextView> (Resource.Id.invitemdesc).Text = item.description; view.FindViewById <TextView> (Resource.Id.invitemqty).Text = sqty; view.FindViewById <TextView> (Resource.Id.invitemtaxgrp).Text = item.taxgrp; if (item.icode == "TAX" || item.icode == "AMOUNT") { view.FindViewById <TextView> (Resource.Id.invitemtax).Text = ""; } else { view.FindViewById <TextView> (Resource.Id.invitemtax).Text = item.tax.ToString("n2"); } view.FindViewById <TextView> (Resource.Id.invitemprice).Text = sprice; view.FindViewById <TextView> (Resource.Id.invitemamt).Text = item.netamount.ToString("n2"); }
private void GetInvoiceText(Invoice inv, InvoiceDtls[] list) { prtcompHeader.PrintCompHeader (ref text); prtCustHeader.PrintCustomerInv (ref text, inv); prtHeader.PrintHeader (ref text, inv); string dline = ""; double ttlAmt = 0; double ttltax = 0; int count = 0; foreach (InvoiceDtls itm in list) { count += 1; dline = dline + prtDetail.PrintDetail (itm, count); ttlAmt = ttlAmt + itm.netamount; ttltax = ttltax + itm.tax; } text += dline; if (inv.trxtype=="CASH") prtTotal.PrintTotalAjust (ref text, ttlAmt, ttltax); else prtTotal.PrintTotal (ref text, ttlAmt, ttltax); prtTaxSummary.PrintTaxSumm (ref text, list); prtFooter.PrintFooter (ref text); text += "\nTHANK YOU\n\n\n\n\n\n\n\n"; }
public string PrintDetail_NTax(InvoiceDtls itm, int count) { string test = ""; string desc = itm.description; string pline2 = desc.ToUpper().Trim() + "\n"; pline2 = pline2 + count.ToString().PadRight(4, ' '); if (itm.qty < 0) { string sqty = "(EX)" + itm.qty.ToString().Trim(); pline2 = pline2 + sqty.PadLeft(9, ' ') + " "; } else { pline2 = pline2 + itm.qty.ToString().PadLeft(9, ' ') + " "; } pline2 = pline2 + Math.Round(itm.price, 2).ToString("n2").PadLeft(12, ' ') + " "; pline2 = pline2 + Math.Round(itm.netamount, 2).ToString("n2").PadLeft(14, ' '); test += pline2 + "\n"; return(test); }
void Printreceipt() { InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection(pathToDatabase)){ var ls = db.Table <InvoiceDtls> ().Where(x => x.invno == inv.invno).ToList <InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo(list); } if (inv.custcode == null || inv.custcode == "") { string[] codes = spinCust.SelectedItem.ToString().Split(new char[] { '|' }); if (codes.Length < 2) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invalidcust), ToastLength.Long).Show(); return; } inv.custcode = codes [0].Trim(); inv.description = txtcustname; } //mmDevice = null; //findBTPrinter (); IPrintDocument prtInv = PrintDocManager.GetPrintDocument <PrintInvoice>(); prtInv.SetDocument(inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy(1); prtInv.SetCallingActivity(this); if (prtInv.StartPrint()) { updatePrintedStatus(inv); } else { Toast.MakeText(this, prtInv.GetErrMsg(), ToastLength.Long).Show(); } }
private void butAddClick(object sender, EventArgs e) { GetControls(); TextView txttax = FindViewById <TextView> (Resource.Id.txttax); if (!IsValidEntry()) { return; } string[] codedesc = spinItem.SelectedItem.ToString().Split(new char[] { '|' }); var itemlist = items.Where(x => x.ICode == codedesc [0].Trim()).ToList <Item> (); if (itemlist.Count == 0) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invaliditem), ToastLength.Long).Show(); return; } Item ItemCode = itemlist [0]; int qtytye = spinQty.SelectedItemPosition; double stqQty = Convert.ToDouble(txtqty.Text); if (qtytye == 1) //return { stqQty = stqQty * -1; } double uprice = Convert.ToDouble(txtprice.Text); if (qtytye == 2) //FOC { uprice = 0; } double taxval = taxper; //Convert.ToDouble(taxper.Text); double amount = Math.Round((stqQty * uprice), 2); double netamount = amount; bool taxinclusice = isInclusive; // isincl.Checked; 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); } using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { InvoiceDtls invdtl = new InvoiceDtls(); if (IsEdit) { var list = db.Table <InvoiceDtls> ().Where(x => x.invno == inv.invno && x.ID == IDdtls).ToList <InvoiceDtls> (); if (list.Count > 0) { invdtl = list [0]; } } invdtl.invno = inv.invno; invdtl.amount = amount; invdtl.icode = codedesc [0].Trim(); // spinner.SelectedItem.ToString (); invdtl.price = uprice; invdtl.qty = stqQty; invdtl.tax = taxamt; invdtl.taxgrp = txttax.Text; invdtl.netamount = netamount; invdtl.description = ItemCode.IDesc; invdtl.isincludesive = taxinclusice; if (IsEdit) { db.Update(invdtl); } else { db.Insert(invdtl); } } IsEdit = false; IDdtls = -1; spinItem.Enabled = true; butFindItem.Enabled = true; //spinner.SetSelection (-1); txtqty.Text = ""; txtInvMode.Text = "NEW"; //txtprice.Text = ""; //txtttltax.Text = ""; //txtttlamt.Text = ""; ClearItemData(); RefreshItemList(); }
private void AddBarCodeItem(Item prd) { TextView txtInvNo = 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); } InvoiceDtls inv = new InvoiceDtls(); inv.invno = txtInvNo.Text; 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 == txtInvNo.Text && 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); } } spinner.SetSelection(-1); Toast.MakeText(this, Resources.GetString(Resource.String.msg_itemadded), ToastLength.Long).Show(); }
void PrintInv(Invoice inv,int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<InvoiceDtls> ().Where (x => x.invno==inv.invno).ToList<InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo (list); } //mmDevice = null; //findBTPrinter (); IPrintDocument prtInv = PrintDocManager.GetPrintDocument<PrintInvoice>(); prtInv.SetDocument (inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy (noofcopy); prtInv.SetCallingActivity (this); if (prtInv.StartPrint ()) { updatePrintedStatus (inv); var found = listData.Where (x => x.invno == inv.invno).ToList (); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<Invoice> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } else { Toast.MakeText (this, prtInv.GetErrMsg(), ToastLength.Long).Show (); } }
void Printreceipt() { InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<InvoiceDtls> ().Where (x => x.invno==inv.invno).ToList<InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo (list); } if (inv.custcode == null || inv.custcode == "") { string[] codes = spinCust.SelectedItem.ToString ().Split (new char[]{ '|' }); if (codes.Length < 2) { Toast.MakeText (this, Resources.GetString (Resource.String.msg_invalidcust), ToastLength.Long).Show (); return; } inv.custcode = codes [0].Trim(); inv.description = txtcustname; } //mmDevice = null; //findBTPrinter (); IPrintDocument prtInv = PrintDocManager.GetPrintDocument<PrintInvoice>(); prtInv.SetDocument (inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy (1); prtInv.SetCallingActivity (this); if (prtInv.StartPrint ()) { updatePrintedStatus (inv); } else { Toast.MakeText (this, prtInv.GetErrMsg(), 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); }
void Delete(InvoiceDtls invdtls) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete)+"?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(invdtls); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
void EditItem(InvoiceDtls invdtls) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table<InvoiceDtls>().Where(x=>x.invno==invdtls.invno&& x.ID==invdtls.ID).ToList<InvoiceDtls>(); if (list.Count > 0) { txtqty.Text = list [0].qty.ToString(); txtprice.Text = list [0].price.ToString("n2"); int pos1 = 0; if (list [0].description.Length > 40) { pos1= dAdapterItem.GetPosition (list [0].icode+" | "+list [0].description.Substring(0,40)+"..."); }else pos1= dAdapterItem.GetPosition (list [0].icode+" | "+list [0].description); spinItem.SetSelection (pos1); spinItem.Enabled = false; butFindItem.Enabled = false; IsEdit = true; IDdtls = list [0].ID; txtInvMode.Text = "EDIT"; //txtprice.Text = list [0].price.ToString("n2"); spinQty.SetSelection (0); if (list [0].qty < 0) spinQty.SetSelection (1); if (list [0].price == 0) spinQty.SetSelection (2); txtqty.RequestFocus (); txtqty.SelectAll (); } } }
public List<string> GetPrintDetalis(Invoice inv,InvoiceDtls[] invdtls) { List<string> text = new List<string>(); ttlline = 0; _ttltax =0; _ttlAmt=0; string line = ""; int itemno = 1; byte[] charfont; Regex re = new Regex("\r\r$"); string desc = ""; IEnumerable<Item> itemcodes = DataHelper.GetItems (); string uom = ""; foreach (InvoiceDtls dtl in invdtls) { uom = ""; var item = from p in itemcodes where p.ICode == dtl.icode select p; if (item.ToList ().Count > 0) uom = item.ToList () [0].StdUom; desc = re.Replace(dtl.description, "").ToUpper(); if (dtl.icode.Length < 15 && desc.Length < 28) { ttlline += 1; line = (itemno.ToString () + ".").PadRight (4, ' ') + dtl.icode.ToUpper ().PadRight (16, ' ') + desc.PadRight (29, ' ') + dtl.price.ToString ("n2").PadLeft (9, ' ') + dtl.qty.ToString ("n0").PadLeft (5, ' ') + uom.PadLeft (6, ' ') + dtl.tax.ToString ("n2").PadLeft (8, ' ') + dtl.taxgrp.PadLeft (7, ' ') + dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r"; text.Add(line); } else if (dtl.icode.Length > 15 && desc.Length < 28) { ttlline += 2; line = (itemno.ToString () + ".").PadRight (4, ' ') + dtl.icode.Substring(0,15).ToUpper ().PadRight (16, ' ') + desc.PadRight (29, ' ') + dtl.price.ToString ("n2").PadLeft (9, ' ') + dtl.qty.ToString ("n0").PadLeft (5, ' ') + uom.PadLeft (6, ' ') + dtl.tax.ToString ("n2").PadLeft (8, ' ') + dtl.taxgrp.PadLeft (7, ' ') + dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r"; text.Add(line); text.Add("".PadRight (4, ' ') +dtl.icode.ToUpper ().Substring (15) + "\r"); }else if (desc.Length >= 28) { List<string> lines = GetLine (desc,28); ttlline = ttlline + lines.Count; List<string> ICodes = new List<string> (); if (dtl.icode.Length > 15) { ICodes.Add (dtl.icode.ToUpper ().Substring (0, 15)); ICodes.Add (dtl.icode.ToUpper ().Substring (15)); }else ICodes.Add (dtl.icode.ToUpper ()); for (int i = 0; i < lines.Count; i++) { ICodes.Add (""); } line = (itemno.ToString () + ".").PadRight (4, ' ') + ICodes[0].PadRight (16, ' ') + lines[0].PadRight (29, ' ') + dtl.price.ToString ("n2").PadLeft (9, ' ') + dtl.qty.ToString ("n0").PadLeft (5, ' ') + uom.PadLeft (6, ' ') + dtl.tax.ToString ("n2").PadLeft (8, ' ') + dtl.taxgrp.PadLeft (7, ' ') + dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r"; text.Add(line); for (int i = 1; i < lines.Count; i++) { line = "".PadRight (4, ' ') + ICodes[i].PadRight (16, ' ') + lines[i].PadRight (29, ' ') + "\r"; text.Add(line); } } itemno += 1; _ttltax = _ttltax + dtl.tax; _ttlAmt = _ttlAmt + dtl.netamount; } return text; }
public int GetTotalDtlLineCount(Invoice inv,InvoiceDtls[] invdtls) { int ttlline = 0; foreach (InvoiceDtls dtl in invdtls) { if (dtl.icode.Length < 15 && dtl.description.Length < 28) { ttlline += 1; } else if (dtl.icode.Length > 15 && dtl.description.Length < 28) { ttlline += 2; }else if (dtl.description.Length > 28) { List<string> lines = GetLine (dtl.description,29); ttlline = ttlline + lines.Count; } } return ttlline; }
void populate(List<InvoiceDtls> list) { var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); pathToDatabase = Path.Combine(documents, "db_adonet.db"); comp = DataHelper.GetCompany (pathToDatabase); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list1 = db.Table<Invoice>().Where(x=>x.invno==invno).ToList<Invoice>(); var list2 = db.Table<InvoiceDtls>().Where(x=>x.invno==invno).ToList<InvoiceDtls>(); var list3 = db.Table<Trader>().Where(x=>x.CustCode==CUSTCODE).ToList<Trader>(); double ttlamt = 0; double ttltax = 0; if (list3.Count > 0) { CUSTNAME = list3 [0].CustName; } foreach(var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } if (list1.Count > 0) { list1 [0].amount = ttlamt; db.Update (list1 [0]); } InvoiceDtls inv1 = new InvoiceDtls (); inv1.icode = "TAX"; inv1.netamount = ttltax; InvoiceDtls inv2 = new InvoiceDtls (); inv2.icode = "AMOUNT"; inv2.netamount = ttlamt; list.Add (inv1); list.Add (inv2); } }
private void butSaveClick(object sender,EventArgs e) { TextView txtInvNo = FindViewById<TextView> (Resource.Id.txtInvnp); Spinner spinner = FindViewById<Spinner> (Resource.Id.txtcode); EditText qty = FindViewById<EditText> (Resource.Id.txtqty); // TextView desc = FindViewById<TextView> (Resource.Id.txtdesc); EditText price = FindViewById<EditText> (Resource.Id.txtprice); //EditText taxper = FindViewById<EditText> (Resource.Id.txtinvtaxper); //CheckBox isincl = FindViewById<CheckBox> (Resource.Id.txtinvisincl); TextView txttax = FindViewById<TextView> (Resource.Id.txttax); EditText ttlamt = FindViewById<EditText> (Resource.Id.txtamount); EditText ttltax = FindViewById<EditText> (Resource.Id.txttaxamt); if (spinner.SelectedItem == null) { Toast.MakeText (this, "No Item Code selected...", ToastLength.Long).Show (); spinner.RequestFocus (); return; } if (string.IsNullOrEmpty(qty.Text)) { Toast.MakeText (this, "Qty is blank...", ToastLength.Long).Show (); qty.RequestFocus (); return; } if (string.IsNullOrEmpty(price.Text)) { Toast.MakeText (this, "Unit Price is blank...", ToastLength.Long).Show (); price.RequestFocus (); return; } double stqQty = Convert.ToDouble(qty.Text); double uprice = Convert.ToDouble(price.Text); double taxval = taxper;//Convert.ToDouble(taxper.Text); double amount = Math.Round((stqQty * uprice),2); double netamount = amount; bool taxinclusice = isInclusive;// isincl.Checked; 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 (); string[] codedesc = spinner.SelectedItem.ToString ().Split (new char[]{ '|' }); inv.invno = txtInvNo.Text; inv.amount = amount; //inv.description = codedesc [1].Trim(); inv.icode = codedesc [0].Trim();// spinner.SelectedItem.ToString (); inv.price = uprice; inv.qty = stqQty; inv.tax = taxamt; inv.taxgrp = txttax.Text; inv.netamount = netamount; var itemlist = items.Where (x => x.ICode == inv.icode).ToList<Item> (); if (itemlist.Count == 0) { Toast.MakeText (this, "Invlaid Item Code...", ToastLength.Long).Show (); return; } Item ItemCode = itemlist [0]; inv.description = ItemCode.IDesc; int id = Convert.ToInt32 (ITEMUID); //inv..title = spinner.SelectedItem.ToString (); using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var invlist =db.Table<InvoiceDtls> ().Where (x => x.invno == inv.invno&& x.ID==id).ToList<InvoiceDtls> (); if (invlist.Count > 0) { InvoiceDtls invItem = invlist [0]; invItem.amount = amount; invItem.netamount = netamount; invItem.tax = taxamt; invItem.taxgrp = txttax.Text; //invItem.description = codedesc [1].Trim(); invItem.description = ItemCode.IDesc; invItem.icode = codedesc [0].Trim(); //spinner.SelectedItem.ToString (); invItem.price = uprice; invItem.qty = stqQty; db.Update (invItem); }else db.Insert (inv); } //spinner.SetSelection (-1); qty.Text = ""; //price.Text = ""; ttltax.Text = ""; ttlamt.Text = ""; Toast.MakeText (this, "Item successfully added...", ToastLength.Long).Show (); }
internal void GetInvTaxInfo(InvoiceDtls[] list, string pathToDatabase, MyModel model) { List<Item> list2 = new List<Item> (); using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { list2 = db.Table<Item> ().ToList<Item> (); } var grp = from p in list group p by p.taxgrp into g select new { taxgrp = g.Key, ttltax = g.Sum (x => x.tax), ttlAmt = g.Sum (v => v.netamount) }; foreach (var g in grp) { TaxInfo taxinfo = new TaxInfo(); taxinfo.Tax = g.taxgrp.Trim(); taxinfo.TaxPer =0; var list3 = list2.Where(x => x.taxgrp == g.taxgrp).ToList(); if (list3.Count > 0) { taxinfo.TaxPer = list3[0].tax; } taxinfo.TaxAmt = g.ttltax; taxinfo.Amount = g.ttlAmt; model.TaxSumm.Add(taxinfo); } }
void StartPrint(Invoice inv,InvoiceDtls[] list,int noofcopy ) { string userid = ((GlobalvarsApp)this.Application).USERID_CODE; PrintInvHelper prnHelp = new PrintInvHelper (pathToDatabase, userid); string msg =prnHelp.OpenBTAndPrint (mmSocket, mmDevice, inv, list,noofcopy); Toast.MakeText (this, msg, ToastLength.Long).Show (); }
void PrintInv(Invoice inv,int noofcopy) { Toast.MakeText (this, "print....", ToastLength.Long).Show (); InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<InvoiceDtls> ().Where (x => x.invno==inv.invno).ToList<InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo (list); } mmDevice = null; findBTPrinter (); if (mmDevice != null) { StartPrint (inv, list,noofcopy); if (!inv.isPrinted) { updatePrintedStatus (inv); var found =listData.Where (x => x.invno == inv.invno).ToList (); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<Invoice> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } } }
private void AddBarCodeItem(Item prd ) { //TextView txtInvNo = FindViewById<TextView> (Resource.Id.txtInvno); 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 invdtls = new InvoiceDtls (); invdtls.invno = inv.invno; 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<InvoiceDtls> ().Where (x => x.invno == inv.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 (invdtls); } //spinItem.SetSelection (-1); ClearItemData (); Toast.MakeText (this, Resources.GetString(Resource.String.msg_itemadded), ToastLength.Long).Show (); }
public void PrintDetalis(Stream mmOutputStream,Invoice inv,InvoiceDtls[] invdtls) { ttlline = 0; _ttltax =0; _ttlAmt=0; string line = ""; int itemno = 1; byte[] charfont; IEnumerable<Item> itemcodes = DataHelper.GetItems (); string uom = ""; foreach (InvoiceDtls dtl in invdtls) { uom = ""; var item = from p in itemcodes where p.ICode == dtl.icode select p; if (item.ToList ().Count > 0) uom = item.ToList () [0].StdUom; if (dtl.icode.Length < 15 && dtl.description.Length < 28) { ttlline += 1; line = (itemno.ToString () + ".").PadRight (4, ' ') + dtl.icode.ToUpper ().PadRight (16, ' ') + dtl.description.ToUpper ().PadRight (29, ' ') + dtl.price.ToString ("n2").PadLeft (9, ' ') + dtl.qty.ToString ("n0").PadLeft (5, ' ') + uom.PadLeft (6, ' ') + dtl.tax.ToString ("n2").PadLeft (8, ' ') + dtl.taxgrp.PadLeft (7, ' ') + dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r"; PrintLine (line,mmOutputStream); } else if (dtl.icode.Length > 15 && dtl.description.Length < 28) { ttlline += 2; line = (itemno.ToString () + ".").PadRight (4, ' ') + dtl.icode.Substring(0,15).ToUpper ().PadRight (16, ' ') + dtl.description.ToUpper ().PadRight (29, ' ') + dtl.price.ToString ("n2").PadLeft (9, ' ') + dtl.qty.ToString ("n0").PadLeft (5, ' ') + uom.PadLeft (6, ' ') + dtl.tax.ToString ("n2").PadLeft (8, ' ') + dtl.taxgrp.PadLeft (7, ' ') + dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r"; PrintLine (line,mmOutputStream); PrintLine (dtl.icode.ToUpper().Substring(15)+"\r",mmOutputStream); }else if (dtl.description.Length >= 28) { List<string> lines = GetLine (dtl.description,28); ttlline = ttlline + lines.Count; List<string> ICodes = new List<string> (); if (dtl.icode.Length > 15) { ICodes.Add (dtl.icode.ToUpper ().Substring (0, 15)); ICodes.Add (dtl.icode.ToUpper ().Substring (15)); }else ICodes.Add (dtl.icode.ToUpper ()); for (int i = 0; i < lines.Count; i++) { ICodes.Add (""); } line = (itemno.ToString () + ".").PadRight (4, ' ') + ICodes[0].PadRight (16, ' ') + lines[0].PadRight (29, ' ') + dtl.price.ToString ("n2").PadLeft (9, ' ') + dtl.qty.ToString ("n0").PadLeft (5, ' ') + uom.PadLeft (6, ' ') + dtl.tax.ToString ("n2").PadLeft (8, ' ') + dtl.taxgrp.PadLeft (7, ' ') + dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r"; PrintLine (line,mmOutputStream); for (int i = 1; i < lines.Count; i++) { line = (itemno.ToString () + ".").PadRight (4, ' ') + ICodes[i].PadRight (16, ' ') + lines[i].PadRight (29, ' ') + "\r"; PrintLine (line,mmOutputStream); } } itemno += 1; _ttltax = _ttltax + dtl.tax; _ttlAmt = _ttlAmt + dtl.netamount; } //int remindline = 35 - ttlline; //SetLineFeed (mmOutputStream, remindline); }
private void butAddClick(object sender,EventArgs e) { GetControls (); TextView txttax = FindViewById<TextView> (Resource.Id.txttax); if (!IsValidEntry ()) return; string[] codedesc = spinItem.SelectedItem.ToString ().Split (new char[]{ '|' }); var itemlist = items.Where (x => x.ICode == codedesc [0].Trim()).ToList<Item> (); if (itemlist.Count == 0) { Toast.MakeText (this, Resources.GetString(Resource.String.msg_invaliditem), ToastLength.Long).Show (); return; } Item ItemCode = itemlist [0]; int qtytye = spinQty.SelectedItemPosition; double stqQty = Convert.ToDouble(txtqty.Text); if (qtytye == 1) //return stqQty = stqQty * -1; double uprice = Convert.ToDouble(txtprice.Text); if (qtytye == 2) //FOC uprice = 0; double taxval = taxper;//Convert.ToDouble(taxper.Text); double amount = Math.Round((stqQty * uprice),2); double netamount = amount; bool taxinclusice = isInclusive;// isincl.Checked; 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); } using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { InvoiceDtls invdtl = new InvoiceDtls (); if (IsEdit) { var list = db.Table<InvoiceDtls> ().Where (x => x.invno == inv.invno && x.ID == IDdtls).ToList<InvoiceDtls> (); if (list.Count > 0) { invdtl = list [0]; } } invdtl.invno =inv.invno; invdtl.amount = amount; invdtl.icode = codedesc [0].Trim();// spinner.SelectedItem.ToString (); invdtl.price = uprice; invdtl.qty = stqQty; invdtl.tax = taxamt; invdtl.taxgrp = txttax.Text; invdtl.netamount = netamount; invdtl.description = ItemCode.IDesc; invdtl.isincludesive = taxinclusice; if (IsEdit) db.Update(invdtl); else db.Insert (invdtl); } IsEdit = false; IDdtls = -1; spinItem.Enabled = true; butFindItem.Enabled = true; //spinner.SetSelection (-1); txtqty.Text = ""; txtInvMode.Text = "NEW"; //txtprice.Text = ""; //txtttltax.Text = ""; //txtttlamt.Text = ""; ClearItemData (); RefreshItemList (); }
void populate(List<InvoiceDtls> list) { list.Clear(); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list2 = db.Table<InvoiceDtls>().Where(x=>x.invno==inv.invno) .OrderByDescending(x=>x.ID) .ToList<InvoiceDtls>(); ttlamt = 0; ttltax = 0; foreach(var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } InvoiceDtls inv1 = new InvoiceDtls (); inv1.icode = "TAX"; inv1.netamount = ttltax; InvoiceDtls inv2 = new InvoiceDtls (); inv2.icode = "AMOUNT"; inv2.netamount = ttlamt; list.Add (inv1); list.Add (inv2); } }
void DeleteItem(InvoiceDtls invdtls) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table<InvoiceDtls>().Where(x=>x.invno==invdtls.invno&& x.ID==invdtls.ID).ToList<InvoiceDtls>(); if (list.Count > 0) { db.Delete (list [0]); RefreshItemList (); // var arrlist= listData.Where(x=>x.invno==invdtls.invno&& x.ID==invdtls.ID).ToList<InvoiceDtls>(); // if (arrlist.Count > 0) { // listData.Remove (arrlist [0]); // SetViewDlg viewdlg = SetViewDelegate; // listView.Adapter = new GenericListAdapterEx<InvoiceDtls> (this, listData, Resource.Layout.InvDtlItemViewCS, viewdlg); // } } } }
void Printreceipt() { InvoiceDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<InvoiceDtls> ().Where (x => x.invno==inv.invno).ToList<InvoiceDtls>(); list = new InvoiceDtls[ls.Count]; ls.CopyTo (list); } //mmDevice = null; //findBTPrinter (); IPrintDocument prtInv = PrintDocManager.GetPrintDocument<PrintInvoice>(); prtInv.SetDocument (inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy (1); prtInv.SetCallingActivity (this); if (prtInv.StartPrint ()) { updatePrintedStatus (inv); } else { Toast.MakeText (this, prtInv.GetErrMsg(), ToastLength.Long).Show (); } }
void populate(List<InvoiceDtls> list) { list.Clear (); using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var list2 = db.Table<InvoiceDtls> () .Where (x => x.invno == inv.invno) .OrderByDescending(x=>x.ID) .ToList<InvoiceDtls> (); ttlamt = 0; ttltax = 0; foreach (var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add (item); } double roundVal = 0; double ttlNet = Utility.AdjustToNear (ttlamt + ttltax, ref roundVal); InvoiceDtls inv1 = new InvoiceDtls (); inv1.icode = "TAX"; inv1.netamount = ttlamt; inv1.description = "TOTAL EXCL GST"; InvoiceDtls inv2 = new InvoiceDtls (); inv2.icode = "AMOUNT"; inv2.netamount = ttltax; inv2.description = "TOTAL 6% GST" ; InvoiceDtls inv3 = new InvoiceDtls (); inv3.icode = "TAX"; inv3.netamount = ttlamt + ttltax; inv3.description = "TOTAL INCL GST" ; // InvoiceDtls inv4 = new InvoiceDtls (); // inv4.icode = "AMOUNT"; // inv4.netamount = roundVal; // inv4.description = "ROUNDING ADJUST"; // InvoiceDtls inv5 = new InvoiceDtls (); // inv5.icode = "AMOUNT"; // inv5.netamount = ttlNet; // inv5.description = "NET TOTAL"; list.Add (inv1); list.Add (inv2); list.Add (inv3); //list.Add (inv4); //list.Add (inv5); } }
//Bluetooth Printer -Mini Bluetooth Printer public void BluetoothMini(BluetoothSocket mmSocket,BluetoothDevice mmDevice,Invoice inv,InvoiceDtls[] list,int noofcopy) { msg = ""; Stream mmOutputStream; //TextView txtv = FindViewById<TextView> (Resource.Id.textView2); try { UUID uuid = UUID.FromString ("00001101-0000-1000-8000-00805F9B34FB"); mmSocket = mmDevice.CreateInsecureRfcommSocketToServiceRecord (uuid); if (mmSocket == null) { //txtv.Text = "Error creating sockect"; msg = "Error creating sockect"; //errmsg.Append(msg); return; } //txtv.Text = mmDevice.BondState.ToString (); if (mmDevice.BondState == Bond.Bonded) { //errmsg.Append("Start to connect\n"); //mmSocket.Connect (); TrytoConnect(mmSocket); Thread.Sleep (300); //mmInputStream = mmSocket.InputStream; //errmsg.Append("connected\n"); mmOutputStream = mmSocket.OutputStream; byte[] charfont; charfont = new Byte[] { 27, 64 }; //Char font 9x17 mmOutputStream.Write(charfont, 0, charfont.Length); if (apara.PaperSize=="58mm") { charfont = new Byte[] { 27, 33, 1 }; //Char font 9x17 //charfont = new Byte[] { 27, 77, 1 }; //Char font 9x17 mmOutputStream.Write(charfont, 0, charfont.Length); } if (apara.PaperSize=="80mm") { charfont = new Byte[] { 27, 33, 0 }; //Char font 12x24 //charfont = new Byte[] { 27, 77, 1 }; //Char font 9x17 mmOutputStream.Write(charfont, 0, charfont.Length); } charfont = new Byte[] { 28, 38 }; mmOutputStream.Write(charfont, 0, charfont.Length); //charfont = new Byte[] { 28, 67,0,48 }; // mmOutputStream.Write(charfont, 0, charfont.Length); //charfont = new Byte[] { 27, 82, 15 }; //Char font 9x17 // mmOutputStream.Write(charfont, 0, charfont.Length); string test = ""; //errmsg.Append("Set printer\n"); PrintInvoice (inv, list, ref test); //var encoding = Encoding.GetEncoding(936); //byte[] source = Encoding.Unicode.GetBytes(text); //byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source); //errmsg.Append("Start Endcoidng\n"); byte[] cc = Encoding.GetEncoding("GB18030").GetBytes(test); for (int i=0; i<noofcopy;i++) { int rem; int result =Math.DivRem(cc.Length, 2048, out rem); int pos =0; for(int line= 0;line<result;line++) { IsStreamCanWrite (mmOutputStream); mmOutputStream.Write (cc, pos, 2048); pos += 2048; } if (rem >0) mmOutputStream.Write (cc, pos, rem); //mmOutputStream.BeginWrite(cc,0,cc.Length, //mmOutputStream.Write (cc, 0, cc.Length); Thread.Sleep (3000); //mmOutputStream.Flush (); } Thread.Sleep (300); charfont = new Byte[] { 28, 46 }; mmOutputStream.Write(charfont, 0, charfont.Length); mmOutputStream.Close (); //mmInputStream.Close(); mmSocket.Close (); msg ="Printing...."; } else { //txtv.Text = "Device not connected"; msg= "Device not connected"; //errmsg.Append(msg); } } catch (Exception ex) { msg = ex.Message; } }
void populate(List<InvoiceDtls> list) { comp = DataHelper.GetCompany (pathToDatabase); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list1 = db.Table<Invoice>().Where(x=>x.invno==invno).ToList<Invoice>(); var list2 = db.Table<InvoiceDtls>().Where(x=>x.invno==invno).ToList<InvoiceDtls>(); var list3 = db.Table<Trader>().Where(x=>x.CustCode==CUSTCODE).ToList<Trader>(); double ttlamt = 0; double ttltax = 0; if (list3.Count > 0) { CUSTNAME = list3 [0].CustName; } foreach(var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } if (list1.Count > 0) { list1 [0].amount = ttlamt; db.Update (list1 [0]); } // InvoiceDtls inv1 = new InvoiceDtls (); // inv1.icode = "TAX"; // inv1.netamount = ttltax; // InvoiceDtls inv2 = new InvoiceDtls (); // inv2.icode = "AMOUNT"; // inv2.netamount = ttlamt; // // list.Add (inv1); // list.Add (inv2); double roundVal = 0; double ttlNet = Utility.AdjustToNear (ttlamt + ttltax, ref roundVal); InvoiceDtls inv1 = new InvoiceDtls (); inv1.icode = "TAX"; inv1.netamount = ttlamt; inv1.description = "TOTAL EXCL GST"; InvoiceDtls inv2 = new InvoiceDtls (); inv2.icode = "AMOUNT"; inv2.netamount = ttltax; inv2.description = "TOTAL 6% GST" ; InvoiceDtls inv3 = new InvoiceDtls (); inv3.icode = "TAX"; inv3.netamount = ttlamt + ttltax; inv3.description = "TOTAL INCL GST" ; InvoiceDtls inv4 = new InvoiceDtls (); inv4.icode = "AMOUNT"; inv4.netamount = roundVal; inv4.description = "ROUNDING ADJUST"; InvoiceDtls inv5 = new InvoiceDtls (); inv5.icode = "AMOUNT"; inv5.netamount = ttlNet; inv5.description = "NET TOTAL"; list.Add (inv1); list.Add (inv2); list.Add (inv3); if (TRXTYPE == "CASH") { list.Add (inv4); list.Add (inv5); } } }
void populate(List <InvoiceDtls> list) { comp = DataHelper.GetCompany(pathToDatabase); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list1 = db.Table <Invoice>().Where(x => x.invno == invno).ToList <Invoice>(); var list2 = db.Table <InvoiceDtls>().Where(x => x.invno == invno).ToList <InvoiceDtls>(); var list3 = db.Table <Trader>().Where(x => x.CustCode == CUSTCODE).ToList <Trader>(); double ttlamt = 0; double ttltax = 0; if (list3.Count > 0) { CUSTNAME = list3 [0].CustName; } foreach (var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } if (list1.Count > 0) { list1 [0].amount = ttlamt; db.Update(list1 [0]); } // InvoiceDtls inv1 = new InvoiceDtls (); // inv1.icode = "TAX"; // inv1.netamount = ttltax; // InvoiceDtls inv2 = new InvoiceDtls (); // inv2.icode = "AMOUNT"; // inv2.netamount = ttlamt; // // list.Add (inv1); // list.Add (inv2); double roundVal = 0; double ttlNet = Utility.AdjustToNear(ttlamt + ttltax, ref roundVal); InvoiceDtls inv1 = new InvoiceDtls(); inv1.icode = "TAX"; inv1.netamount = ttlamt; inv1.description = "TOTAL EXCL GST"; InvoiceDtls inv2 = new InvoiceDtls(); inv2.icode = "AMOUNT"; inv2.netamount = ttltax; inv2.description = "TOTAL 6% GST"; InvoiceDtls inv3 = new InvoiceDtls(); inv3.icode = "TAX"; inv3.netamount = ttlamt + ttltax; inv3.description = "TOTAL INCL GST"; InvoiceDtls inv4 = new InvoiceDtls(); inv4.icode = "AMOUNT"; inv4.netamount = roundVal; inv4.description = "ROUNDING ADJUST"; InvoiceDtls inv5 = new InvoiceDtls(); inv5.icode = "AMOUNT"; inv5.netamount = ttlNet; inv5.description = "NET TOTAL"; list.Add(inv1); list.Add(inv2); list.Add(inv3); if (TRXTYPE == "CASH") { list.Add(inv4); list.Add(inv5); } } }
private void butSaveClick(object sender, EventArgs e) { TextView txtInvNo = FindViewById <TextView> (Resource.Id.txtInvnp); Spinner spinner = FindViewById <Spinner> (Resource.Id.txtcode); EditText qty = FindViewById <EditText> (Resource.Id.txtqty); EditText price = FindViewById <EditText> (Resource.Id.txtprice); TextView txttax = FindViewById <TextView> (Resource.Id.txttax); EditText ttlamt = FindViewById <EditText> (Resource.Id.txtamount); EditText ttltax = FindViewById <EditText> (Resource.Id.txttaxamt); if (spinner.SelectedItem == null) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invaliditem), ToastLength.Long).Show(); spinner.RequestFocus(); return; } if (string.IsNullOrEmpty(qty.Text)) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invalidqty), ToastLength.Long).Show(); qty.RequestFocus(); return; } if (string.IsNullOrEmpty(price.Text)) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invalidprice), ToastLength.Long).Show(); price.RequestFocus(); return; } string[] codedesc = spinner.SelectedItem.ToString().Split(new char[] { '|' }); var itemlist = items.Where(x => x.ICode == codedesc [0].Trim()).ToList <Item> (); if (itemlist.Count == 0) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invaliditem), ToastLength.Long).Show(); return; } Item ItemCode = itemlist [0]; double stqQty = Convert.ToDouble(qty.Text); double uprice = Convert.ToDouble(price.Text); //double uprice= Utility.GetUnitPrice (trd,ItemCode); double taxval = taxper; //Convert.ToDouble(taxper.Text); double amount = Math.Round((stqQty * uprice), 2); double netamount = amount; bool taxinclusice = isInclusive; // isincl.Checked; 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 = txtInvNo.Text; inv.amount = amount; inv.icode = codedesc [0].Trim(); // spinner.SelectedItem.ToString (); inv.price = uprice; inv.qty = stqQty; inv.tax = taxamt; inv.taxgrp = txttax.Text; inv.netamount = netamount; inv.description = ItemCode.IDesc; int id = Convert.ToInt32(ITEMUID); //inv..title = spinner.SelectedItem.ToString (); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var invlist = db.Table <InvoiceDtls> ().Where(x => x.invno == inv.invno && x.ID == id).ToList <InvoiceDtls> (); if (invlist.Count > 0) { InvoiceDtls invItem = invlist [0]; invItem.amount = amount; invItem.netamount = netamount; invItem.tax = taxamt; invItem.taxgrp = txttax.Text; //invItem.description = codedesc [1].Trim(); invItem.description = ItemCode.IDesc; invItem.icode = codedesc [0].Trim(); //spinner.SelectedItem.ToString (); invItem.price = uprice; invItem.qty = stqQty; db.Update(invItem); } else { db.Insert(inv); } } //spinner.SetSelection (-1); qty.Text = ""; //price.Text = ""; ttltax.Text = ""; ttlamt.Text = ""; Toast.MakeText(this, Resources.GetString(Resource.String.msg_itemadded), ToastLength.Long).Show(); }
private bool PrintCNInvoice(CNNote cn,ref string test,ref double ttlAmt,ref double ttltax) { bool IsfoundInvoice =false; InvoiceDtls[] list =null; Invoice inv=null; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var lsinv= db.Table<Invoice> ().Where (x => x.invno==cn.invno).ToList<Invoice>(); if (lsinv.Count > 0) { IsfoundInvoice =true; inv = lsinv [0]; var ls = db.Table<InvoiceDtls> ().Where (x => x.invno == cn.invno).ToList<InvoiceDtls> (); list = new InvoiceDtls[ls.Count]; ls.CopyTo (list); } } if (inv != null) { PrintInvoice (inv, list, ref test,needFooter:false); foreach(InvoiceDtls itm in list) { ttlAmt = ttlAmt+ itm.netamount; ttltax = ttltax+itm.tax; } } return IsfoundInvoice; }
void populate(List<InvoiceDtls> list) { //comp = DataHelper.GetCompany (pathToDatabase); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list1 = db.Table<Invoice>().Where(x=>x.invno==invno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<Invoice>(); var list2 = db.Table<InvoiceDtls>().Where(x=>x.invno==invno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<InvoiceDtls>(); var list3 = db.Table<Trader>().Where(x=>x.CustCode==CUSTCODE&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<Trader>(); double ttlamt = 0; double ttltax = 0; if (list3.Count > 0) { CUSTNAME = list3 [0].CustName; } foreach(var item in list2) { ttlamt = ttlamt + item.netamount; ttltax = ttltax + item.tax; list.Add(item); } if (list1.Count > 0) { list1 [0].amount = ttlamt; db.Update (list1 [0]); } InvoiceDtls inv1 = new InvoiceDtls (); inv1.icode = "TAX"; inv1.netamount = ttltax; InvoiceDtls inv2 = new InvoiceDtls (); inv2.icode = "AMOUNT"; inv2.netamount = ttlamt; list.Add (inv1); list.Add (inv2); } }
void PrintInvoice(Invoice inv, InvoiceDtls[] list, ref string test,bool needFooter=true) { PrintCompHeader (ref test); PrintCustomer (ref test, inv.custcode); PrintHeader (ref test, inv); string dline = ""; double ttlAmt = 0; double ttltax = 0; int count = 0; foreach (InvoiceDtls itm in list) { count += 1; dline = dline + PrintDetail (itm, count); ttlAmt = ttlAmt + itm.netamount; ttltax = ttltax + itm.tax; } test += dline; PrintTotal (ref test, ttlAmt, ttltax); PrintTaxSumm (ref test, list); if (needFooter) { PrintFooter (ref test); test += "\nTHANK YOU\n\n\n\n\n\n\n\n"; }else test += "\n\n"; }
public string OpenBTAndPrint(BluetoothSocket mmSocket,BluetoothDevice mmDevice,Invoice inv,InvoiceDtls[] list,int noofcopy ) { string msg = ""; BluetoothMini (mmSocket, mmDevice, inv, list, noofcopy); return msg; }
internal string GetInvoiceText_Template(string templatefilename,string pathToDatabase,string userID,Invoice inv, InvoiceDtls[] list) { string template = GetTemplateFile(templatefilename, pathToDatabase); if (string.IsNullOrEmpty (template)) return ""; MyModel model = new MyModel (); model.Customer = GetCustomer(inv.custcode,model,pathToDatabase); model.PrintDate = DateTime.Now; model.UserID = userID; model.Invoicehdr = inv; model.InvDtls = new List<InvoiceDtls> (); model.TaxSumm = new List<TaxInfo> (); foreach (var item in list) { model.InvDtls.Add (item); } GetInvTaxInfo (list, pathToDatabase, model); VelocityEngine fileEngine = new VelocityEngine(); fileEngine.Init(); VelocityContext context = new VelocityContext(); StreamWriter ws = new StreamWriter(new MemoryStream()); context.Put("util", new CustomTool()); context.Put("model", model); fileEngine.Evaluate(context, ws, null, template); string text = ""; ws.Flush(); byte[] data = new byte[ws.BaseStream.Length-2]; ws.BaseStream.Position = 2; int nread = ws.BaseStream.Read(data, 0, data.Length); text = Encoding.UTF8.GetString(data, 0, nread); ws.Close(); return text; }