void PrintInv(DelOrder doorder, int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); DelOrderDtls[] list; using (var db = new SQLite.SQLiteConnection(pathToDatabase)){ var ls = db.Table <DelOrderDtls> ().Where(x => x.dono == doorder.dono).ToList <DelOrderDtls>(); list = new DelOrderDtls[ls.Count]; ls.CopyTo(list); } IPrintDocument prtSO = PrintDocManager.GetPrintDocument <PrintDelOrder>(); prtSO.SetDocument(doorder); prtSO.SetDocumentDtls(list); prtSO.SetNoOfCopy(noofcopy); prtSO.SetCallingActivity(this); if (prtSO.StartPrint()) { updatePrintedStatus(doorder); var found = listData.Where(x => x.dono == doorder.dono).ToList(); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter <DelOrder> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } else { Toast.MakeText(this, prtSO.GetErrMsg(), ToastLength.Long).Show(); } }
public string PrintDODetail(DelOrderDtls itm,int count) { string test = ""; string desc = itm.description; string pline2 = desc.ToUpper ().Trim (); string scount = count.ToString ().PadRight (4, ' '); if (pline2.Length > 33) { string[] strs = pline2.Split (new char[]{ ' ' }); string tmp = ""; string sqty = itm.qty.ToString ("n").PadLeft (5, ' '); foreach (string s in strs) { if ((tmp + s + " ").Length > 33) { test = test + scount + tmp.PadRight (33, ' ') + sqty+"\n"; scount = "".PadRight (4, ' '); sqty = "".PadRight (5, ' '); tmp = s+" "; } else { tmp = tmp + s+" "; } } test = test + "".PadRight (4, ' ') + tmp + "\n"; } else { test = count.ToString ().PadRight (4, ' ') + pline2.PadRight (33, ' ')+scount+ "\n"; } return test; }
void Delete(DelOrderDtls so) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete) + "?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(so); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
void Edit(DelOrderDtls so) { //var intent = new Intent(this, typeof(DOEntryActivity)); var intent = ActivityManager.GetActivity <DOEntryActivity>(this.ApplicationContext); intent.PutExtra("invoiceno", so.dono); intent.PutExtra("itemuid", so.ID.ToString()); intent.PutExtra("editmode", "EDIT"); intent.PutExtra("customer", CUSTNAME); intent.PutExtra("custcode", CUSTCODE); StartActivity(intent); }
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { DelOrderDtls 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.DOAllowEdit) { menu.Menu.RemoveItem(Resource.Id.popedit); } if (!rights.DOAllowDelete) { menu.Menu.RemoveItem(Resource.Id.popdelete); } //if allow edit and SaleOrder printed, remove edit //printed invoice not allow to edit if (DataHelper.GetDelOderPrintStatus(pathToDatabase, item.dono, rights)) { 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.dono); } else if (arg1.Item.ItemId == Resource.Id.popedit) { Edit(item); } else if (arg1.Item.ItemId == Resource.Id.popdelete) { Delete(item); } }; menu.Show(); }
private void SetViewDelegate(View view, object clsobj) { DelOrderDtls item = (DelOrderDtls)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 = ""; view.FindViewById <TextView> (Resource.Id.invitemtaxgrp).Text = ""; view.FindViewById <TextView> (Resource.Id.invitemtax).Text = ""; view.FindViewById <TextView> (Resource.Id.invitemprice).Text = ""; view.FindViewById <TextView> (Resource.Id.invitemamt).Text = sqty; }
void DeleteItem(DelOrderDtls so) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <DelOrderDtls>().Where(x => x.dono == dono && x.ID == so.ID).ToList <DelOrderDtls>(); if (list.Count > 0) { db.Delete(list [0]); var arrlist = listData.Where(x => x.dono == dono && x.ID == so.ID).ToList <DelOrderDtls>(); if (arrlist.Count > 0) { listData.Remove(arrlist [0]); SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter <DelOrderDtls> (this, listData, Resource.Layout.InvDtlItemView, viewdlg); } } } }
private void GetDelOrderText(DelOrder delOrder, DelOrderDtls[] list) { prtcompHeader.PrintCompHeader (ref text); prtCustHeader.PrintCustomer (ref text, delOrder.custcode,"DELIVER TO"); prtHeader.PrintDOHeader (ref text, delOrder); string dline = ""; double ttlAmt = 0; double ttltax = 0; int count = 0; foreach (DelOrderDtls itm in list) { count += 1; dline = dline + prtDetail.PrintDODetail (itm, count); ttlAmt = ttlAmt + itm.qty; } text += dline; prtTotal.PrintDOTotal(ref text, ttlAmt); prtFooter.PrintFooter (ref text); text += "\nTHANK YOU\n\n\n\n\n\n\n\n"; }
private void LoadData(string sono, string uid) { TextView txtInvNo = FindViewById <TextView> (Resource.Id.txtInvnp); Spinner spinner = FindViewById <Spinner> (Resource.Id.txtcode); EditText qty = FindViewById <EditText> (Resource.Id.txtqty); int id = Convert.ToInt32(uid); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var invlist = db.Table <DelOrderDtls> ().Where(x => x.dono == sono && x.ID == id).ToList <DelOrderDtls> (); if (invlist.Count > 0) { DelOrderDtls doItem = invlist [0]; int index = dataAdapter.GetPosition(doItem.icode + " | " + doItem.description); Item item = items.Where(x => x.ICode == doItem.icode).FirstOrDefault(); spinner.SetSelection(index); qty.Text = doItem.qty.ToString(); } } }
void populate(List <DelOrderDtls> 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 <DelOrder>().Where(x => x.dono == invno).ToList <DelOrder>(); var list2 = db.Table <DelOrderDtls>().Where(x => x.dono == invno).ToList <DelOrderDtls>(); 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]); } DelOrderDtls inv1 = new DelOrderDtls(); inv1.icode = "TAX"; inv1.netamount = ttltax; DelOrderDtls inv2 = new DelOrderDtls(); inv2.icode = "AMOUNT"; inv2.netamount = ttlamt; list.Add(inv1); list.Add(inv2); } }
public string PrintDODetail(DelOrderDtls itm, int count) { string test = ""; string desc = itm.description; string pline2 = desc.ToUpper().Trim(); string scount = count.ToString().PadRight(4, ' '); if (pline2.Length > 33) { string[] strs = pline2.Split(new char[] { ' ' }); string tmp = ""; string sqty = itm.qty.ToString("n").PadLeft(5, ' '); foreach (string s in strs) { if ((tmp + s + " ").Length > 33) { test = test + scount + tmp.PadRight(33, ' ') + sqty + "\n"; scount = "".PadRight(4, ' '); sqty = "".PadRight(5, ' '); tmp = s + " "; } else { tmp = tmp + s + " "; } } test = test + "".PadRight(4, ' ') + tmp + "\n"; } else { test = count.ToString().PadRight(4, ' ') + pline2.PadRight(33, ' ') + scount + "\n"; } return(test); }
public string OpenBTAndPrintDO(BluetoothSocket mmSocket,BluetoothDevice mmDevice,DelOrder doOrder,DelOrderDtls[] list,int noofcopy ) { string msg = ""; string text = ""; PrintDO ( doOrder, list, ref text); BluetoothPrint (mmSocket, mmDevice, text, noofcopy); return msg; }
void PrintInv(DelOrder doorder,int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); DelOrderDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<DelOrderDtls> ().Where (x => x.dono==doorder.dono).ToList<DelOrderDtls>(); list = new DelOrderDtls[ls.Count]; ls.CopyTo (list); } IPrintDocument prtSO = PrintDocManager.GetPrintDocument<PrintDelOrder>(); prtSO.SetDocument (doorder); prtSO.SetDocumentDtls(list); prtSO.SetNoOfCopy (noofcopy); prtSO.SetCallingActivity (this); if (prtSO.StartPrint ()) { updatePrintedStatus (doorder); var found = listData.Where (x => x.dono == doorder.dono).ToList (); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<DelOrder> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } else { Toast.MakeText (this, prtSO.GetErrMsg(), ToastLength.Long).Show (); } }
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); 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; } double stqQty = Convert.ToDouble(qty.Text); DelOrderDtls doorder = new DelOrderDtls(); string[] codedesc = spinner.SelectedItem.ToString().Split(new char[] { '|' }); doorder.dono = txtInvNo.Text; doorder.description = codedesc [1].Trim(); doorder.icode = codedesc [0].Trim(); // spinner.SelectedItem.ToString (); doorder.qty = stqQty; var itemlist = items.Where(x => x.ICode == doorder.icode).ToList <Item> (); if (itemlist.Count == 0) { Toast.MakeText(this, "Invlaid Item Code...", ToastLength.Long).Show(); return; } int id = Convert.ToInt32(ITEMUID); //so..title = spinner.SelectedItem.ToString (); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var invlist = db.Table <DelOrderDtls> ().Where(x => x.dono == doorder.dono && x.ID == id).ToList <DelOrderDtls> (); if (invlist.Count > 0) { DelOrderDtls soItem = invlist [0]; soItem.description = codedesc [1].Trim(); soItem.icode = codedesc [0].Trim(); //spinner.SelectedItem.ToString (); soItem.qty = stqQty; db.Update(soItem); } else { db.Insert(doorder); } } //spinner.SetSelection (-1); qty.Text = ""; Toast.MakeText(this, "Item successfully added...", ToastLength.Long).Show(); }
void PrintDO(DelOrder doorder, DelOrderDtls[] list, ref string test) { PrintCompHeader (ref test); PrintCustomer (ref test, doorder.custcode); PrintDOHeader (ref test, doorder); string dline = ""; double ttlAmt = 0; double ttltax = 0; int count = 0; foreach (DelOrderDtls itm in list) { count += 1; dline = dline + PrintDODetail (itm, count); ttlAmt = ttlAmt + itm.qty; } test += dline; PrintDOTotal (ref test, ttlAmt); PrintFooter (ref test); //test += "\nTHANK YOU\n\n\n\n"; }
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); 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; } double stqQty = Convert.ToDouble(qty.Text); DelOrderDtls doorder = new DelOrderDtls (); string[] codedesc = spinner.SelectedItem.ToString ().Split (new char[]{ '|' }); doorder.dono = txtInvNo.Text; //doorder.description = codedesc [1].Trim(); doorder.icode = codedesc [0].Trim();// spinner.SelectedItem.ToString (); doorder.qty = stqQty; doorder.CompCode = compCode; doorder.BranchCode = branchCode; var itemlist = items.Where (x => x.ICode == doorder.icode).ToList<Item> (); if (itemlist.Count == 0) { Toast.MakeText (this, "Invlaid Item Code...", ToastLength.Long).Show (); return; } Item ItemCode = itemlist [0]; doorder.description = ItemCode.IDesc; int id = Convert.ToInt32 (ITEMUID); //so..title = spinner.SelectedItem.ToString (); using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var invlist =db.Table<DelOrderDtls> ().Where (x => x.dono == doorder.dono&& x.ID==id).ToList<DelOrderDtls> (); if (invlist.Count > 0) { DelOrderDtls doItem = invlist [0]; doItem.description = ItemCode.IDesc;//codedesc [1].Trim(); doItem.icode = codedesc [0].Trim(); //spinner.SelectedItem.ToString (); doItem.qty = stqQty; db.Update (doItem); }else db.Insert (doorder); } spinner.SetSelection (-1); qty.Text = ""; Toast.MakeText (this, "Item successfully added...", ToastLength.Long).Show (); }
internal string GetDelOrderText_Template(string templatefilename,string pathToDatabase, string userID, DelOrder delOrder, DelOrderDtls[] list) { //yet to implement return ""; }
void Edit(DelOrderDtls so) { //var intent = new Intent(this, typeof(DOEntryActivity)); var intent =ActivityManager.GetActivity<DOEntryActivity>(this.ApplicationContext); intent.PutExtra ("invoiceno",so.dono ); intent.PutExtra ("itemuid",so.ID.ToString() ); intent.PutExtra ("editmode","EDIT" ); intent.PutExtra ("customer",CUSTNAME ); intent.PutExtra ("custcode",CUSTCODE ); StartActivity(intent); }
void populate(List<DelOrderDtls> 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<DelOrder>().Where(x=>x.dono==dono).ToList<DelOrder>(); var list2 = db.Table<DelOrderDtls>().Where(x=>x.dono==dono).ToList<DelOrderDtls>(); 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.qty; ttltax = ttltax + item.tax; list.Add(item); } if (list1.Count > 0) { list1 [0].amount = ttlamt; db.Update (list1 [0]); } DelOrderDtls inv2 = new DelOrderDtls (); inv2.icode = "TOTAL"; inv2.qty = ttlamt; list.Add (inv2); } }
void DeleteItem(DelOrderDtls so) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table<DelOrderDtls>().Where(x=>x.dono==dono&& x.ID==so.ID).ToList<DelOrderDtls>(); if (list.Count > 0) { db.Delete (list [0]); var arrlist= listData.Where(x=>x.dono==dono&& x.ID==so.ID).ToList<DelOrderDtls>(); if (arrlist.Count > 0) { listData.Remove (arrlist [0]); SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<DelOrderDtls> (this, listData, Resource.Layout.InvDtlItemView, viewdlg); } } } }
void Delete(DelOrderDtls so) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete)+"?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(so); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
void Delete(DelOrderDtls so) { var builder = new AlertDialog.Builder(this); builder.SetMessage("Confimr to Delete?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(so); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
void PrintInv(DelOrder so,int noofcopy) { Toast.MakeText (this, "print....", ToastLength.Long).Show (); DelOrderDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<DelOrderDtls> () .Where (x => x.dono==so.dono&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<DelOrderDtls>(); list = new DelOrderDtls[ls.Count]; ls.CopyTo (list); } mmDevice = null; findBTPrinter (); if (mmDevice != null) { StartPrint (so, list,noofcopy); if (!so.isPrinted) { updatePrintedStatus (so); var found =listData.Where (x => x.dono==so.dono&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList (); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<DelOrder> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } } }
void populate(List<DelOrderDtls> list) { // comp = DataHelper.GetCompany (pathToDatabase,compCode,branchCode); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list1 = db.Table<DelOrder>().Where(x=>x.dono==invno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<DelOrder>(); var list2 = db.Table<DelOrderDtls>().Where(x=>x.dono==invno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<DelOrderDtls>(); 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]); } DelOrderDtls inv1 = new DelOrderDtls (); inv1.icode = "TAX"; inv1.netamount = ttltax; DelOrderDtls inv2 = new DelOrderDtls (); inv2.icode = "AMOUNT"; inv2.netamount = ttlamt; list.Add (inv1); list.Add (inv2); } }
void StartPrint(DelOrder so,DelOrderDtls[] list,int noofcopy ) { string userid = ((GlobalvarsApp)this.Application).USERID_CODE; PrintInvHelper prnHelp = new PrintInvHelper (pathToDatabase, userid,compCode,branchCode); //string msg =prnHelp.OpenBTAndPrintSO (mmSocket, mmDevice,so, list,noofcopy); //Toast.MakeText (this, msg, ToastLength.Long).Show (); }
void Edit(DelOrderDtls so) { var intent = new Intent(this, typeof(DOEntryActivity)); intent.PutExtra ("invoiceno",so.dono ); intent.PutExtra ("itemuid",so.ID.ToString() ); intent.PutExtra ("editmode","EDIT" ); intent.PutExtra ("customer",CUSTNAME ); intent.PutExtra ("custcode",CUSTCODE ); StartActivity(intent); }