public void PrintHeaderCN(ref string test,CNNote inv) { string userid = USERID; string[] titles = apara.ReceiptTitle.Split (new char[]{ ',', '|'}); string title1 = ""; string title2 = ""; title1 = "CREDIT NOTE"; string date =inv.invdate.ToString ("dd-MM-yyyy"); //string datetime = inv.invdate.ToString ("dd-MM-yyyy hh:mm tt"); string datetime = inv.invdate.ToString ("dd-MM-yyyy")+" "+inv.created.ToString ("hh:mm tt"); if (compinfo.ShowTime) { test += datetime+title1.PadLeft(41-datetime.Length,' ')+"\n"; } else { test += date+title1.PadLeft(41-date.Length,' ')+"\n"; } //test += DateTime.Now.ToString ("dd-MM-yyyy")+"TAX INVOICE".PadLeft(31,' ')+"\n"; if (!string.IsNullOrEmpty (inv.invno)) { test += "INVOICE NO : " + inv.invno.Trim ()+"\n"; } string recno = "CREDIT NOTE NO : " + inv.cnno.Trim(); //test += "RECPT NO : " + inv.invno+"\n"; test += recno+title2.PadLeft(41-recno.Length,' ')+"\n"; string issueline = "ISSUED BY: " + userid.ToUpper (); int templen = 41 - issueline.Length; string term = "("+((inv.trxtype.IndexOf("CASH")>-1)?"COD":"TERM")+")"; issueline = issueline + term.PadLeft (templen, ' ')+"\n"; test += issueline;// "ISSUED BY: " + userid.ToUpper()+"\n"; if (!string.IsNullOrEmpty (inv.remark)) { string reason = "REASON: " + inv.remark; PrintLongText (ref test, reason); } }
void OnListItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { CNNote item = listData.ElementAt(e.Position); PopupMenu menu = new PopupMenu(e.Parent.Context, e.View); menu.Inflate(Resource.Menu.popupHis); if (!rights.CNAllowPrint) { menu.Menu.RemoveItem(Resource.Id.popInvprint); menu.Menu.RemoveItem(Resource.Id.popInvprint2); } menu.MenuItemClick += (s1, arg1) => { if (arg1.Item.ItemId == Resource.Id.popInvprint) { PrintInv(item, 1); } else if (arg1.Item.ItemId == Resource.Id.popInvprint2) { PrintInv(item, 2); } else if (arg1.Item.ItemId == Resource.Id.popInvfilter) { ShowDateRangeLookUp(); } }; menu.Show(); }
void PrintInv(CNNote inv, int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); CNNoteDtls[] list; using (var db = new SQLite.SQLiteConnection(pathToDatabase)){ var ls = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno).ToList <CNNoteDtls>(); list = new CNNoteDtls[ls.Count]; ls.CopyTo(list); } IPrintDocument prtInv = PrintDocManager.GetPrintCNDocument <PrintCreditNote>(); prtInv.SetDocument(inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy(noofcopy); prtInv.SetCallingActivity(this); if (prtInv.StartPrint()) { updatePrintedStatus(inv); var found = listData.Where(x => x.cnno == inv.cnno).ToList(); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter <CNNote> (this, listData, Resource.Layout.ListItemRowCN, viewdlg); } } }
private bool PrintCNInvoice(CNNote cn, ref double ttlAmt, ref double ttltax) { bool IsfoundInvoice = false; InvoiceDtls[] list = null; Invoice inv = null; string pathToDatabase = ((GlobalvarsApp)Application.Context).DATABASE_PATH; 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) { GetInvoiceText(inv, list); foreach (InvoiceDtls itm in list) { ttlAmt = ttlAmt + itm.netamount; ttltax = ttltax + itm.tax; } } return(IsfoundInvoice); }
void Edit(CNNote cn) { //var intent = new Intent (this, typeof(EditCNNote)); var intent = ActivityManager.GetActivity <EditCNNote>(this.ApplicationContext); intent.PutExtra("cnno", cn.cnno); StartActivity(intent); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); if (!((GlobalvarsApp)this.Application).ISLOGON) { Finish (); } SetContentView (Resource.Layout.CreateCNote); EventManagerFacade.Instance.GetEventManager().AddListener(this); pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH; compCode = ((GlobalvarsApp)this.Application).COMPANY_CODE; branchCode = ((GlobalvarsApp)this.Application).BRANCH_CODE; CNNO = Intent.GetStringExtra ("cnno") ?? "AUTO"; cnInfo =DataHelper.GetCNNote (pathToDatabase,CNNO,compCode,branchCode); // Create your application here _date = DateTime.Today; spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode); Button butSave = FindViewById<Button> (Resource.Id.newinv_bsave); butSave.Text = "SAVE"; Button butCancel = FindViewById<Button> (Resource.Id.newinv_cancel); Button butFind = FindViewById<Button> (Resource.Id.newinv_bfind); Button butFindInv = FindViewById<Button> (Resource.Id.newinv_bfindinv); spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected); butSave.Click += butSaveClick; butCancel.Click += butCancelClick; TextView cnno = FindViewById<TextView> (Resource.Id.newinv_no); cnno.Enabled = false; EditText trxdate = FindViewById<EditText> (Resource.Id.newinv_date); trxdate.Click += delegate(object sender, EventArgs e) { ShowDialog (0); }; butFind.Click+= (object sender, EventArgs e) => { ShowCustLookUp(); }; butFindInv.Click+= (object sender, EventArgs e) => { ShowInvLookUp(); }; apara = DataHelper.GetAdPara (pathToDatabase,compCode,branchCode); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { items = db.Table<Trader> ().Where(x=>x.CompCode==compCode&&x.BranchCode==branchCode).ToList<Trader> (); } List<string> icodes = new List<string> (); foreach (Trader item in items) { icodes.Add (item.CustCode+" | "+item.CustName); } dataAdapter = new ArrayAdapter<String>(this,Resource.Layout.spinner_item, icodes); // Drop down layout style - list view with radio button dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); // attaching data adapter to spinner spinner.Adapter =dataAdapter; LoadData (); }
void Delete(CNNote inv) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete) + "?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(inv); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
public void PrintCNHeader(Stream mmOutputStream, CNNote inv, string pageno) { //SetLQMode (mmOutputStream,true); SetDoubleStrike(mmOutputStream, true); SetBold(mmOutputStream, true); SetCenter(mmOutputStream, true); string[] names = compInfo.CompanyName.Split(new char[] { '|' }); string compname = (names.Length > 1) ? names [1] : names [0]; byte[] charfont = Encoding.ASCII.GetBytes(compname); mmOutputStream.Write(charfont, 0, charfont.Length); SetBold(mmOutputStream, false); SetDoubleStrike(mmOutputStream, false); Set15CPI(mmOutputStream); charfont = Encoding.ASCII.GetBytes(" (" + compInfo.RegNo + ")\n"); line = 1; mmOutputStream.Write(charfont, 0, charfont.Length); Set12CPI(mmOutputStream); Set1Per6InchLineSpacing(mmOutputStream); string address = GetCompAddress(compInfo); charfont = Encoding.ASCII.GetBytes(address); mmOutputStream.Write(charfont, 0, charfont.Length); SetCenter(mmOutputStream, false); SetLineFeed(mmOutputStream, 2); Trader cust = DataHelper.GetTrader(pathToDatabase, inv.custcode); string strline = cust.CustName.ToUpper().PadRight(65, ' ') + " CREDIT NOTE\n"; line += 1; SetBold(mmOutputStream, true); charfont = Encoding.ASCII.GetBytes(strline); mmOutputStream.Write(charfont, 0, charfont.Length); SetBold(mmOutputStream, false); string line1 = cust.Addr1.ToUpper().PadRight(65, ' ') + " C/NOTE NO : " + inv.cnno + "\n"; line += 1; line1 = line1 + cust.Addr2.ToUpper().PadRight(65, ' ') + " INVOICE NO: " + inv.invno + "\n"; line += 1; line1 = line1 + cust.Addr3.ToUpper().PadRight(65, ' ') + " DATE : " + inv.invdate.ToString("dd-MM-yyyy") + "\n"; line += 1; address = "TEL: " + cust.Tel + " FAX: " + cust.Fax; line1 = line1 + address.ToUpper().PadRight(65, ' ') + " TERMS : " + cust.PayCode + "\n"; line += 1; address = "GST NO : " + cust.gst; line1 = line1 + address.PadRight(65, ' ') + " PAGE NO : " + pageno + "\n"; line += 1; charfont = Encoding.ASCII.GetBytes(line1); mmOutputStream.Write(charfont, 0, charfont.Length); line1 = ""; PrintCaption(ref line1); charfont = Encoding.ASCII.GetBytes(line1); mmOutputStream.Write(charfont, 0, charfont.Length); }
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { CNNote item = listData.ElementAt(e.Position); //var intent = new Intent(this, typeof(CNItemActivity)); //need to change var intent = ActivityManager.GetActivity <CNItemActivity>(this.ApplicationContext); intent.PutExtra("invoiceno", item.cnno); intent.PutExtra("custcode", item.custcode); StartActivity(intent); }
public static CNNote[] GetCNNote(DateTime printdate1, DateTime printdate2) { string pathToDatabase = ((GlobalvarsApp)Application.Context).DATABASE_PATH; CNNote[] invs = {}; using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var list = db.Table<CNNote> ().Where (x => x.invdate >= printdate1 && x.invdate <= printdate2).OrderBy (x => x.invdate).ToList<CNNote> (); invs = new CNNote[list.Count]; list.CopyTo (invs); } return invs; }
void ShowItemEntry (CNNote inv, string[] codes) { //var intent = new Intent (this, typeof(CNEntryActivity)); //need to change var intent =ActivityManager.GetActivity<CNEntryActivityEx>(this.ApplicationContext); intent.PutExtra ("invoiceno", inv.cnno); intent.PutExtra ("customer", codes [1].Trim ()); intent.PutExtra ("custcode",codes [0].Trim ()); intent.PutExtra ("itemuid", "-1"); intent.PutExtra ("editmode", "NEW"); StartActivity (intent); }
void OnListItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { CNNote item = listData.ElementAt(e.Position); PopupMenu menu = new PopupMenu(e.Parent.Context, e.View); menu.Inflate(Resource.Menu.popupInv); //if (!compinfo.AllowDelete) { menu.Menu.RemoveItem(Resource.Id.poppay); menu.Menu.RemoveItem(Resource.Id.popInvdelete); //} if (!rights.CNAllowAdd) { menu.Menu.RemoveItem(Resource.Id.popInvadd); } if (!rights.CNAllowEdit) { menu.Menu.RemoveItem(Resource.Id.popInvedit); } if (!rights.CNAllowPrint) { menu.Menu.RemoveItem(Resource.Id.popInvprint); menu.Menu.RemoveItem(Resource.Id.popInvprint2); } if (DataHelper.GetCNNotePrintStatus(pathToDatabase, item.cnno, rights)) { menu.Menu.RemoveItem(Resource.Id.popInvdelete); menu.Menu.RemoveItem(Resource.Id.popInvedit); } menu.MenuItemClick += (s1, arg1) => { if (arg1.Item.ItemId == Resource.Id.popInvadd) { CreateNewInvoice(); } else if (arg1.Item.ItemId == Resource.Id.popInvprint) { PrintInv(item, 1); } else if (arg1.Item.ItemId == Resource.Id.popInvprint2) { PrintInv(item, 2); } else if (arg1.Item.ItemId == Resource.Id.popInvdelete) { Delete(item); } else if (arg1.Item.ItemId == Resource.Id.popInvedit) { Edit(item); } }; menu.Show(); }
public static CNNote[] GetCNNote(DateTime printdate1, DateTime printdate2) { string pathToDatabase = ((GlobalvarsApp)Application.Context).DATABASE_PATH; CNNote[] invs = {}; using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <CNNote> ().Where(x => x.invdate >= printdate1 && x.invdate <= printdate2).OrderBy(x => x.invdate).ToList <CNNote> (); invs = new CNNote[list.Count]; list.CopyTo(invs); } return(invs); }
public void PrintCNHeader(Stream mmOutputStream,CNNote inv,string pageno) { //SetLQMode (mmOutputStream,true); SetDoubleStrike(mmOutputStream, true); SetBold(mmOutputStream, true); SetCenter(mmOutputStream, true); string[] names = compInfo.CompanyName.Split (new char[] { '|' }); string compname = (names.Length > 1) ? names [1] : names [0]; byte[] charfont = Encoding.ASCII.GetBytes(compname); mmOutputStream.Write(charfont, 0, charfont.Length); SetBold(mmOutputStream, false); SetDoubleStrike(mmOutputStream, false); Set15CPI (mmOutputStream); charfont = Encoding.ASCII.GetBytes(" ("+compInfo.RegNo+")\n"); line =1; mmOutputStream.Write(charfont, 0, charfont.Length); Set12CPI (mmOutputStream); Set1Per6InchLineSpacing (mmOutputStream); string address = GetCompAddress (compInfo); charfont = Encoding.ASCII.GetBytes(address); mmOutputStream.Write(charfont, 0, charfont.Length); SetCenter(mmOutputStream, false); SetLineFeed (mmOutputStream, 2); Trader cust = DataHelper.GetTrader (pathToDatabase, inv.custcode); string strline = cust.CustName.ToUpper().PadRight(65, ' ') + " CREDIT NOTE\n"; line +=1; SetBold(mmOutputStream, true); charfont = Encoding.ASCII.GetBytes(strline); mmOutputStream.Write(charfont, 0, charfont.Length); SetBold(mmOutputStream, false); string line1 = cust.Addr1.ToUpper ().PadRight (65, ' ') +" C/NOTE NO : " + inv.cnno + "\n"; line +=1; line1 = line1 + cust.Addr2.ToUpper ().PadRight (65, ' ') + " INVOICE NO: " + inv.invno + "\n"; line +=1; line1 = line1 + cust.Addr3.ToUpper().PadRight(65, ' ') + " DATE : " + inv.invdate.ToString ("dd-MM-yyyy") + "\n"; line +=1; address = "TEL: " + cust.Tel + " FAX: " + cust.Fax; line1 = line1 + address .ToUpper().PadRight(65, ' ') + " TERMS : "+cust.PayCode+ "\n"; line +=1; address = "GST NO : " + cust.gst; line1 = line1 + address.PadRight(65, ' ') + " PAGE NO : "+pageno+"\n"; line +=1; charfont = Encoding.ASCII.GetBytes(line1); mmOutputStream.Write(charfont, 0, charfont.Length); line1 = ""; PrintCaption (ref line1); charfont = Encoding.ASCII.GetBytes(line1); mmOutputStream.Write(charfont, 0, charfont.Length); }
public static CNNote GetCNNoteByInvNo(string pathToDatabase, string invno) { CNNote inv = null; using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list2 = db.Table <CNNote> ().ToList <CNNote>().Where(x => x.invno == invno).ToList(); if (list2.Count > 0) { inv = list2 [0]; } } return(inv); }
private bool SaveCN() { bool IsSave = false; CNNote inv = new CNNote(); EditText trxdate = FindViewById <EditText> (Resource.Id.newinv_date); if (!Utility.IsValidDateString(trxdate.Text)) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invaliddate), ToastLength.Long).Show(); return(IsSave); } DateTime invdate = Utility.ConvertToDate(trxdate.Text); Spinner spinner = FindViewById <Spinner> (Resource.Id.newinv_custcode); EditText remark = FindViewById <EditText> (Resource.Id.newinv_custname); TextView cninvno = FindViewById <TextView> (Resource.Id.newcninv_no); if (spinner.SelectedItem == null) { Toast.MakeText(this, Resources.GetString(Resource.String.msg_invalidcust), ToastLength.Long).Show(); spinner.RequestFocus(); return(IsSave); } string[] codes = spinner.SelectedItem.ToString().Split(new char[] { '|' }); if (codes.Length == 0) { return(IsSave); } using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { cnInfo.invdate = invdate; cnInfo.created = DateTime.Now; cnInfo.description = codes [1].Trim(); cnInfo.custcode = codes [0].Trim(); cnInfo.invno = cninvno.Text; cnInfo.remark = remark.Text.ToUpper(); cnInfo.trxtype = ""; if (!string.IsNullOrEmpty(cnInfo.invno)) { Invoice invInfo = DataHelper.GetInvoice(pathToDatabase, cnInfo.invno); if (invInfo != null) { cnInfo.trxtype = invInfo.trxtype; } } db.Update(cnInfo); IsSave = true; } return(IsSave); }
void LoadCashBill() { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <CNNote> ().Where(x => x.cnno == INVOICENO).ToList(); if (list.Count > 0) { inv = list [0]; txtcnno.Text = inv.cnno; txtInvDate.Text = inv.invdate.ToString("dd-MM-yyyy"); txtInvMode.Text = "NEW"; } } EnableControLs(true, true, false, true, false); }
private void GetCreditNoteText(CNNote cn, CNNoteDtls[] list) { string dline=""; int count =0; double ttlAmt = 0; double ttltax = 0; double invTtlAmt =0; double invTtlTax =0; bool IsfoundInvoice = false; string pathToDatabase = ((GlobalvarsApp)Application.Context).DATABASE_PATH; Invoice inv = null; IsfoundInvoice = PrintCNInvoice (cn,ref invTtlAmt, ref invTtlTax); if (!IsfoundInvoice) { prtcompHeader.PrintCompHeader (ref text); prtCustHeader.PrintCustomer (ref text, cn.custcode); }else inv = DataHelper.GetInvoice (pathToDatabase, cn.invno); prtHeader.PrintCNHeader (ref text, cn); foreach(CNNoteDtls itm in list) { count+=1; dline =dline+prtDetail.PrintCNDetail (itm,count); ttlAmt = ttlAmt+ itm.netamount; ttltax = ttltax+itm.tax; } text += dline; if (!IsfoundInvoice) { if (cn.trxtype=="CASH") prtTotal.PrintTotalAjust (ref text, ttlAmt, ttltax); else prtTotal.PrintTotal (ref text, ttlAmt, ttltax); } else { if (inv.trxtype=="CASH") prtTotal.PrintTotalAjust (ref text, ttlAmt, ttltax); else prtTotal.PrintTotal (ref text, ttlAmt, ttltax); } prtTaxSummary.PrintCNTaxSumm(ref text,list ); prtFooter.PrintFooter (ref text); if (IsfoundInvoice) { text += "\nTHANK YOU\n\n"; if (inv.trxtype=="CASH") prtTotal.PrintTotalAjust (ref text,ttlAmt, ttltax, invTtlAmt,invTtlTax); else prtTotal.PrintTotal (ref text,ttlAmt, ttltax, invTtlAmt,invTtlTax); text += "\n\n\n\n\n\n\n\n"; }else text += "\nTHANK YOUn\n\n\n\n\n\n\n"; }
void updatePrintedStatus(CNNote inv) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <CNNote> ().Where(x => x.cnno == inv.cnno).ToList <CNNote> (); if (list.Count > 0) { var list2 = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno).ToList <CNNoteDtls> (); if (list2.Count > 0) { list [0].isPrinted = true; db.Update(list [0]); } } } }
void updatePrintedStatus(CNNote inv) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <CNNote> ().Where(x => x.cnno == inv.cnno).ToList <CNNote> (); if (list.Count > 0) { //if only contains items then allow to update the printed status. //this to allow the invoice;s item can be added. if not can not be posted(upload) var list2 = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno).ToList <CNNoteDtls> (); if (list2.Count > 0) { list [0].isPrinted = true; db.Update(list [0]); } } } }
void DeleteItem(CNNote inv) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table <CNNote>().Where(x => x.cnno == inv.cnno).ToList <CNNote>(); if (list.Count > 0) { db.Delete(list [0]); var arrlist = listData.Where(x => x.cnno == inv.cnno).ToList <CNNote>(); if (arrlist.Count > 0) { listData.Remove(arrlist [0]); SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter <CNNote> (this, listData, Resource.Layout.ListItemRowCN, viewdlg); } } } }
public void PrintHeaderCN(ref string test, CNNote inv) { string userid = USERID; string[] titles = apara.ReceiptTitle.Split(new char[] { ',', '|' }); string title1 = ""; string title2 = ""; title1 = "CREDIT NOTE"; string date = inv.invdate.ToString("dd-MM-yyyy"); //string datetime = inv.invdate.ToString ("dd-MM-yyyy hh:mm tt"); string datetime = inv.invdate.ToString("dd-MM-yyyy") + " " + inv.created.ToString("hh:mm tt"); if (compinfo.ShowTime) { test += datetime + title1.PadLeft(41 - datetime.Length, ' ') + "\n"; } else { test += date + title1.PadLeft(41 - date.Length, ' ') + "\n"; } //test += DateTime.Now.ToString ("dd-MM-yyyy")+"TAX INVOICE".PadLeft(31,' ')+"\n"; if (!string.IsNullOrEmpty(inv.invno)) { test += "INVOICE NO : " + inv.invno.Trim() + "\n"; } string recno = "CREDIT NOTE NO : " + inv.cnno.Trim(); //test += "RECPT NO : " + inv.invno+"\n"; test += recno + title2.PadLeft(41 - recno.Length, ' ') + "\n"; string issueline = "ISSUED BY: " + userid.ToUpper(); int templen = 41 - issueline.Length; string term = "(" + ((inv.trxtype.IndexOf("CASH") > -1)?"COD":"TERM") + ")"; issueline = issueline + term.PadLeft(templen, ' ') + "\n"; test += issueline; // "ISSUED BY: " + userid.ToUpper()+"\n"; if (!string.IsNullOrEmpty(inv.remark)) { string reason = "REASON: " + inv.remark; PrintLongText(ref test, reason); } }
private void GetCreditNoteText(CNNote cn, CNNoteDtls[] list) { string dline = ""; int count = 0; double ttlAmt = 0; double ttltax = 0; double invTtlAmt = 0; double invTtlTax = 0; bool IsfoundInvoice = false; IsfoundInvoice = PrintCNInvoice(cn, ref invTtlAmt, ref invTtlTax); if (!IsfoundInvoice) { prtcompHeader.PrintCompHeader(ref text); prtCustHeader.PrintCustomer(ref text, cn.custcode); } prtHeader.PrintCNHeader_NTax(ref text, cn); foreach (CNNoteDtls itm in list) { count += 1; dline = dline + prtDetail.PrintCNDetail_NTax(itm, count); ttlAmt = ttlAmt + itm.netamount; ttltax = ttltax + itm.tax; } text += dline; prtTotal.PrintTotal_NTax(ref text, ttlAmt, ttltax); //prtTaxSummary.PrintCNTaxSumm(ref text,list ); prtFooter.PrintFooter(ref text); if (IsfoundInvoice) { text += "\nTHANK YOU\n\n"; prtTotal.PrintTotal(ref text, ttlAmt, ttltax, invTtlAmt, invTtlTax); text += "\n\n\n\n\n\n\n\n"; } else { text += "\nTHANK YOUn\n\n\n\n\n\n\n"; } }
private void SetViewDelegate(View view, object clsobj) { CNNote item = (CNNote)clsobj; view.FindViewById <TextView> (Resource.Id.invdate).Text = item.invdate.ToString("dd-MM-yy"); view.FindViewById <TextView> (Resource.Id.invno).Text = item.cnno; string trxtype = ""; if (item.trxtype == "CASH") { trxtype = "CS"; } else if (item.trxtype == "INVOICE") { trxtype = "INV"; } else { trxtype = "CN"; } //view.FindViewById<TextView> (Resource.Id.trxtype).Visibility = ViewStates.Gone; view.FindViewById <TextView>(Resource.Id.invcust).Text = item.description; //view.FindViewById<TextView> (Resource.Id.Amount).Text = item.amount.ToString("n2"); view.FindViewById <TextView> (Resource.Id.TaxAmount).Text = item.taxamt.ToString("n2"); double ttl = item.amount + item.taxamt; view.FindViewById <TextView> (Resource.Id.TtlAmount).Text = ttl.ToString("n2"); ImageView img = view.FindViewById <ImageView> (Resource.Id.printed); if (!item.isPrinted) { img.SetImageDrawable(null); //.Visibility = ViewStates.Invisible;; } if (!string.IsNullOrEmpty(item.remark)) { view.FindViewById <LinearLayout> (Resource.Id.linearLayoutRmark).Visibility = ViewStates.Visible; view.FindViewById <TextView> (Resource.Id.invremark).Text = item.remark.ToUpper(); } }
private void GetCreditNoteText(CNNote cn, CNNoteDtls[] list) { string dline=""; int count =0; double ttlAmt = 0; double ttltax = 0; double invTtlAmt =0; double invTtlTax =0; bool IsfoundInvoice = false; IsfoundInvoice = PrintCNInvoice (cn,ref invTtlAmt, ref invTtlTax); if (!IsfoundInvoice) { prtcompHeader.PrintCompHeader (ref text); prtCustHeader.PrintCustomer (ref text, cn.custcode); } prtHeader.PrintCNHeader_NTax (ref text, cn); foreach(CNNoteDtls itm in list) { count+=1; dline =dline+prtDetail.PrintCNDetail_NTax (itm,count); ttlAmt = ttlAmt+ itm.netamount; ttltax = ttltax+itm.tax; } text += dline; prtTotal.PrintTotal_NTax (ref text,ttlAmt,ttltax); //prtTaxSummary.PrintCNTaxSumm(ref text,list ); prtFooter.PrintFooter (ref text); if (IsfoundInvoice) { text += "\nTHANK YOU\n\n"; prtTotal.PrintTotal (ref text,ttlAmt, ttltax, invTtlAmt,invTtlTax); text += "\n\n\n\n\n\n\n\n"; }else text += "\nTHANK YOUn\n\n\n\n\n\n\n"; }
private void CreateNewCN() { CNNote inv = new CNNote (); EditText trxdate = FindViewById<EditText> (Resource.Id.newinv_date); if (!Utility.IsValidDateString (trxdate.Text)) { Toast.MakeText (this,Resources.GetString(Resource.String.msg_invaliddate), ToastLength.Long).Show (); return; } DateTime invdate = Utility.ConvertToDate (trxdate.Text); DateTime tmr = invdate.AddDays (1); AdNumDate adNum= DataHelper.GetNumDate (pathToDatabase, invdate,"CN"); Spinner spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode); TextView txtinvno =FindViewById<TextView> (Resource.Id.newinv_no); EditText remark = FindViewById<EditText> (Resource.Id.newinv_custname); TextView cninvno = FindViewById<TextView> (Resource.Id.newcninv_no); string prefix = apara.CNPrefix.Trim ().ToUpper (); if (spinner.SelectedItem == null) { Toast.MakeText (this, Resources.GetString(Resource.String.msg_invalidcust), ToastLength.Long).Show (); spinner.RequestFocus (); return; } string[] codes = spinner.SelectedItem.ToString().Split (new char[]{ '|' }); if (codes.Length == 0) return; Invoice invInfo = DataHelper.GetInvoice (pathToDatabase, cninvno.Text); using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { string invno = ""; int runno = adNum.RunNo + 1; int currentRunNo =DataHelper.GetLastCNRunNo (pathToDatabase, invdate); if (currentRunNo >= runno) runno = currentRunNo + 1; if (invInfo != null) { //string[] prefixs = apara.Prefix.Trim ().ToUpper ().Split(new char[]{'|'}); if (invInfo.trxtype == "CASH") { invno =prefix+ invdate.ToString ("yyMM") + runno.ToString ().PadLeft (4, '0')+"(CS)"; }else invno =prefix+ invdate.ToString ("yyMM") + runno.ToString ().PadLeft (4, '0')+"(INV)"; }else invno =prefix + invdate.ToString("yyMM") + runno.ToString().PadLeft (4, '0')+"(INV)";; txtinvno.Text= invno; inv.invdate = invdate; inv.trxtype = ""; inv.created = DateTime.Now; inv.cnno = invno; inv.description = codes [1].Trim (); inv.amount = 0; inv.custcode = codes [0].Trim (); inv.isUploaded = false; inv.remark = remark.Text.ToUpper(); inv.invno = cninvno.Text; if (invInfo != null) { inv.trxtype = invInfo.trxtype; } else { Trader trd= DataHelper.GetTrader (pathToDatabase, inv.custcode); if (trd != null) { string paycode =trd.PayCode.ToUpper ().Trim (); inv.trxtype = paycode; if (paycode.Contains ("CASH") || paycode.Contains ("COD")) { inv.trxtype = "CASH"; } } } db.Insert (inv); adNum.RunNo = runno; if (adNum.ID >= 0) db.Update (adNum); else db.Insert (adNum); } ShowItemEntry (inv, codes); }
public List <string> GetPrintCNDetalis(CNNote inv, CNNoteDtls[] 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 (CNNoteDtls 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); }
void Delete(CNNote inv) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete)+"?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(inv); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }
void PrintInv(CNNote inv,int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); CNNoteDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<CNNoteDtls> ().Where (x => x.cnno==inv.cnno).ToList<CNNoteDtls>(); list = new CNNoteDtls[ls.Count]; ls.CopyTo (list); } IPrintDocument prtInv = PrintDocManager.GetPrintCNDocument<PrintCreditNote>(); prtInv.SetDocument (inv); prtInv.SetDocumentDtls(list); prtInv.SetNoOfCopy (noofcopy); prtInv.SetCallingActivity (this); if (prtInv.StartPrint ()) { updatePrintedStatus (inv); var found =listData.Where (x => x.cnno == inv.cnno).ToList (); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<CNNote> (this, listData, Resource.Layout.ListItemRowCN, viewdlg); } } }
void DeleteItem(CNNote inv) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list = db.Table<CNNote>().Where(x=>x.cnno==inv.cnno).ToList<CNNote>(); if (list.Count > 0) { db.Delete (list [0]); var arrlist= listData.Where(x=>x.cnno==inv.cnno).ToList<CNNote>(); if (arrlist.Count > 0) { listData.Remove (arrlist [0]); SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<CNNote> (this, listData, Resource.Layout.ListItemRowCN, viewdlg); } } } }
void PrintCNHeader(ref string test,CNNote inv) { string userid = USERID; string[] titles = apara.ReceiptTitle.Split (new char[]{ ',', '|'}); string title1 = ""; string title2 = ""; title1 = "CREDIT NOTE"; string date = DateTime.Now.ToString ("dd-MM-yyyy"); string datetime = DateTime.Now.ToString ("dd-MM-yyyy hh:mm tt"); if (compinfo.ShowTime) { test += datetime+title1.PadLeft(41-datetime.Length,' ')+"\n"; } else { test += date+title1.PadLeft(41-date.Length,' ')+"\n"; } //test += DateTime.Now.ToString ("dd-MM-yyyy")+"TAX INVOICE".PadLeft(31,' ')+"\n"; string recno = "CREDIT NOTE NO : " + inv.cnno.Trim(); //test += "RECPT NO : " + inv.invno+"\n"; test += recno+title2.PadLeft(41-recno.Length,' ')+"\n"; string issueline = "ISSUED BY: " + userid.ToUpper (); int templen = 41 - issueline.Length; string term = "("+((inv.trxtype.IndexOf("CASH")>-1)?"COD":"TERM")+")"; issueline = issueline + term.PadLeft (templen, ' ')+"\n"; test += issueline;// "ISSUED BY: " + userid.ToUpper()+"\n"; test += "------------------------------------------\n"; test += "DESCRIPTION \n"; test += "NO QTY U/PRICE TAX AMT AMOUNT\n"; test += "------------------------------------------\n"; /* DESCRIPTION QTY U/PRICE AMOUNT TAXGR TAX AMT ------------------------------------------ xxxxxxxxxxxxxxxxx xxxxx xxxxxxxx xxxxxxxxx xxxxxxxxxxxxxxxxx xxxxx xxxxxxxx xxxxxxxxx 12345678901234567 12345 12345678 123456789 */ }
public string OpenBTAndPrintCN(BluetoothSocket mmSocket,BluetoothDevice mmDevice,CNNote inv,CNNoteDtls[] list,int noofcopy ) { string msg = ""; BluetoothMiniCN (mmSocket, mmDevice, inv, list, noofcopy); return msg; }
void LoadCashBill() { using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var list= db.Table<CNNote> ().Where (x => x.cnno == INVOICENO).ToList (); if (list.Count > 0) { inv = list [0]; txtcnno.Text = inv.cnno; txtInvDate.Text = inv.invdate.ToString ("dd-MM-yyyy"); txtInvMode.Text = "NEW"; } } EnableControLs (true, true, false, true, false); }
public void SetDocument(object doc) { cn = (CNNote)doc; }
void ShowItemEntry(CNNote inv, string[] codes) { //var intent = new Intent (this, typeof(CNEntryActivity)); //need to change var intent =ActivityManager.GetActivity<CNEntryActivityEx>(this.ApplicationContext); intent.PutExtra ("invoiceno", inv.cnno); intent.PutExtra ("customer", codes [1].Trim ()); intent.PutExtra ("custcode",codes [0].Trim ()); intent.PutExtra ("itemuid", "-1"); intent.PutExtra ("editmode", "NEW"); StartActivity (intent); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (!((GlobalvarsApp)this.Application).ISLOGON) { Finish(); } SetTitle(Resource.String.title_creditnoteedit); SetContentView(Resource.Layout.CreateCNote); EventManagerFacade.Instance.GetEventManager().AddListener(this); pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH; CNNO = Intent.GetStringExtra("cnno") ?? "AUTO"; cnInfo = DataHelper.GetCNNote(pathToDatabase, CNNO); // Create your application here _date = DateTime.Today; spinner = FindViewById <Spinner> (Resource.Id.newinv_custcode); Button butSave = FindViewById <Button> (Resource.Id.newinv_bsave); butSave.Text = "SAVE"; Button butCancel = FindViewById <Button> (Resource.Id.newinv_cancel); Button butFind = FindViewById <Button> (Resource.Id.newinv_bfind); Button butFindInv = FindViewById <Button> (Resource.Id.newinv_bfindinv); spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected); butSave.Click += butSaveClick; butCancel.Click += butCancelClick; TextView cnno = FindViewById <TextView> (Resource.Id.newinv_no); cnno.Enabled = false; EditText trxdate = FindViewById <EditText> (Resource.Id.newinv_date); // trxdate.Click += delegate(object sender, EventArgs e) { // ShowDialog (0); // }; //19-Nov-2015 //disable the date, for edit mode, date should not be editable //cuase running number issue. trxdate.Enabled = false; butFind.Click += (object sender, EventArgs e) => { ShowCustLookUp(); }; butFindInv.Click += (object sender, EventArgs e) => { ShowInvLookUp(); }; apara = DataHelper.GetAdPara(pathToDatabase); //SqliteConnection.CreateFile(pathToDatabase); using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { items = db.Table <Trader> ().ToList <Trader> (); } List <string> icodes = new List <string> (); foreach (Trader item in items) { icodes.Add(item.CustCode + " | " + item.CustName.Trim()); } dataAdapter = new ArrayAdapter <String>(this, Resource.Layout.spinner_item, icodes); // Drop down layout style - list view with radio button //dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); dataAdapter.SetDropDownViewResource(Resource.Layout.SimpleSpinnerDropDownItemEx); // attaching data adapter to spinner spinner.Adapter = dataAdapter; LoadData(); }
internal string GetCreditNoteText_Template(string templatefilename, string pathToDatabase, string userID, CNNote cn, CNNoteDtls[] list) { //yet to implement return(""); }
void updatePrintedStatus(CNNote inv) { using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var list = db.Table<CNNote> ().Where (x => x.cnno == inv.cnno).ToList<CNNote> (); if (list.Count > 0) { //if only contains items then allow to update the printed status. //this to allow the invoice;s item can be added. if not can not be posted(upload) var list2 = db.Table<CNNoteDtls> ().Where (x => x.cnno == inv.cnno).ToList<CNNoteDtls> (); if (list2.Count > 0) { list [0].isPrinted = true; db.Update (list [0]); } } } }
public void BluetoothMiniCN(BluetoothSocket mmSocket,BluetoothDevice mmDevice,CNNote inv,CNNoteDtls[] list,int noofcopy ) { msg = ""; Stream mmOutputStream; try { UUID uuid = UUID.FromString ("00001101-0000-1000-8000-00805F9B34FB"); mmSocket = mmDevice.CreateInsecureRfcommSocketToServiceRecord (uuid); if (mmSocket == null) { msg = "Error creating sockect"; return; } if (mmDevice.BondState == Bond.Bonded) { TrytoConnect(mmSocket); Thread.Sleep (300); 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); string test = ""; double invTtlAmt =0; double invTtlTax =0; bool IsfoundInvoice =PrintCNInvoice(inv,ref test,ref invTtlAmt,ref invTtlTax ); if (!IsfoundInvoice){ PrintCompHeader (ref test); PrintCustomer (ref test,inv.custcode); } PrintCNHeader (ref test,inv); string dline=""; double ttlAmt =0; double ttltax =0; int count =0; foreach(CNNoteDtls itm in list) { count+=1; dline =dline+PrintCNDetail (itm,count); ttlAmt = ttlAmt+ itm.netamount; ttltax = ttltax+itm.tax; } test += dline; PrintTotal (ref test,ttlAmt,ttltax); PrintCNTaxSumm(ref test,list ); PrintFooter (ref test); if (IsfoundInvoice) { test += "\nTHANK YOU\n\n"; PrintTotal (ref test,ttlAmt, ttltax, invTtlAmt,invTtlTax); test += "n\n\n\n\n\n\n\n"; }else test += "\nTHANK YOUn\n\n\n\n\n\n\n"; //byte[] cc =ASCIIEncoding.ASCII.GetBytes(test); byte[] cc = Encoding.GetEncoding("GB18030").GetBytes(test); int bLen= cc.Length; 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); mmOutputStream.Close (); //mmInputStream.Close(); mmSocket.Close (); msg ="Printing...."; } else { //txtv.Text = "Device not connected"; msg= "Device not connected"; } } catch (Exception ex) { msg = ex.Message; } // return msg; }
public void SetDocument(object doc) { inv = (CNNote)doc; }
CNNote[] GetCNNote(DateTime printdate1, DateTime printdate2) { CNNote[] invs = { }; using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var list = db.Table<CNNote> ().Where (x => x.invdate >= printdate1 && x.invdate <= printdate2).OrderBy (x => x.invdate).ToList<CNNote> (); invs = new CNNote[list.Count]; list.CopyTo (invs); } return invs; }
public List<string> GetPrintCNDetalis(CNNote inv,CNNoteDtls[] 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 (CNNoteDtls 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; }
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; }
public void PrintCNHeader_NTax(ref string test, CNNote cn) { PrintHeaderCN(ref test, cn); printCaption_NTax(ref test); }
void Edit(CNNote cn) { //var intent = new Intent (this, typeof(EditCNNote)); var intent =ActivityManager.GetActivity<EditCNNote>(this.ApplicationContext); intent.PutExtra ("cnno", cn.cnno); StartActivity (intent); }
void ShowItemEntry(CNNote inv, string[] codes) { var intent = new Intent (this, typeof(CNEntryActivity)); //need to change intent.PutExtra ("invoiceno", inv.cnno); intent.PutExtra ("customer", codes [1].Trim ()); intent.PutExtra ("itemuid", "-1"); intent.PutExtra ("editmode", "NEW"); StartActivity (intent); }
void updatePrintedStatus(CNNote inv) { using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { var list = db.Table<CNNote> ().Where (x => x.cnno == inv.cnno).ToList<CNNote> (); if (list.Count > 0) { var list2 = db.Table<CNNoteDtls> ().Where (x => x.cnno == inv.cnno).ToList<CNNoteDtls> (); if (list2.Count > 0) { list [0].isPrinted = true; db.Update (list [0]); } } } if (!string.IsNullOrEmpty (inv.invno)) updateInvPrintedStatus (inv.invno); }
void PrintInv(CNNote inv,int noofcopy) { Toast.MakeText (this, "print....", ToastLength.Long).Show (); CNNoteDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<CNNoteDtls> ().Where (x => x.cnno==inv.cnno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<CNNoteDtls>(); list = new CNNoteDtls[ls.Count]; ls.CopyTo (list); } mmDevice = null; findBTPrinter (); if (mmDevice != null) { StartPrint (inv, list,noofcopy); } }
private void CreateNewCN() { CNNote inv = new CNNote (); EditText trxdate = FindViewById<EditText> (Resource.Id.newinv_date); if (!Utility.IsValidDateString (trxdate.Text)) { Toast.MakeText (this,"Invalid Transaction Date format...", ToastLength.Long).Show (); return; } DateTime invdate = Utility.ConvertToDate (trxdate.Text); DateTime tmr = invdate.AddDays (1); AdNumDate adNum= DataHelper.GetNumDate (pathToDatabase, invdate,"CN",compCode,branchCode); Spinner spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode); TextView txtinvno =FindViewById<TextView> (Resource.Id.newinv_no); TextView custname = FindViewById<TextView> (Resource.Id.newinv_custname); TextView cninvno = FindViewById<TextView> (Resource.Id.newcninv_no); string prefix = apara.CNPrefix.Trim ().ToUpper (); if (spinner.SelectedItem == null) { Toast.MakeText (this, "No Customer code selected...", ToastLength.Long).Show (); spinner.RequestFocus (); return; } string[] codes = spinner.SelectedItem.ToString().Split (new char[]{ '|' }); if (codes.Length == 0) return; using (var db = new SQLite.SQLiteConnection (pathToDatabase)) { string invno = ""; int runno = adNum.RunNo + 1; int currentRunNo =DataHelper.GetLastCNRunNo (pathToDatabase, invdate,compCode,branchCode); if (currentRunNo >= runno) runno = currentRunNo + 1; invno =prefix + invdate.ToString("yyMM") + runno.ToString().PadLeft (4, '0'); txtinvno.Text= invno; inv.invdate = invdate; inv.trxtype = "CN"; inv.created = DateTime.Now; inv.cnno = invno; inv.description = custname.Text; inv.amount = 0; inv.custcode = codes [0].Trim (); inv.isUploaded = false; inv.invno = cninvno.Text; inv.CompCode = compCode; inv.BranchCode = branchCode; db.Insert (inv); adNum.RunNo = runno; if (adNum.ID >= 0) db.Update (adNum); else db.Insert (adNum); } ShowItemEntry (inv, codes); }
private void GetCreditNoteText(CNNote cn, CNNoteDtls[] list) { string dline = ""; int count = 0; double ttlAmt = 0; double ttltax = 0; double invTtlAmt = 0; double invTtlTax = 0; bool IsfoundInvoice = false; string pathToDatabase = ((GlobalvarsApp)Application.Context).DATABASE_PATH; Invoice inv = null; IsfoundInvoice = PrintCNInvoice(cn, ref invTtlAmt, ref invTtlTax); if (!IsfoundInvoice) { prtcompHeader.PrintCompHeader(ref text); prtCustHeader.PrintCustomer(ref text, cn.custcode); } else { inv = DataHelper.GetInvoice(pathToDatabase, cn.invno); } prtHeader.PrintCNHeader(ref text, cn); foreach (CNNoteDtls itm in list) { count += 1; dline = dline + prtDetail.PrintCNDetail(itm, count); ttlAmt = ttlAmt + itm.netamount; ttltax = ttltax + itm.tax; } text += dline; if (!IsfoundInvoice) { if (cn.trxtype == "CASH") { prtTotal.PrintTotalAjust(ref text, ttlAmt, ttltax); } else { prtTotal.PrintTotal(ref text, ttlAmt, ttltax); } } else { if (inv.trxtype == "CASH") { prtTotal.PrintTotalAjust(ref text, ttlAmt, ttltax); } else { prtTotal.PrintTotal(ref text, ttlAmt, ttltax); } } prtTaxSummary.PrintCNTaxSumm(ref text, list); prtFooter.PrintFooter(ref text); if (IsfoundInvoice) { text += "\nTHANK YOU\n\n"; if (inv.trxtype == "CASH") { prtTotal.PrintTotalAjust(ref text, ttlAmt, ttltax, invTtlAmt, invTtlTax); } else { prtTotal.PrintTotal(ref text, ttlAmt, ttltax, invTtlAmt, invTtlTax); } text += "\n\n\n\n\n\n\n\n"; } else { text += "\nTHANK YOUn\n\n\n\n\n\n\n"; } }
private static double GetCNSumTotal(CNNote[] invs,string trxtype,List<CNNoteDtls> itemlist,Item[] itemCodes,ModelSumm model) { double total = 0; var sum1 = from p in invs where p.trxtype == trxtype group p by 1 into g select new { amt = g.Sum (x => x.amount), tax = g.Sum (x => x.taxamt), grplist = g.ToList() }; if (sum1.Count() >0) total = sum1.FirstOrDefault().amt + sum1.FirstOrDefault().tax; List<string> invnosTmp = new List<string>(); foreach (var grptmp in sum1) { foreach (var lst in grptmp.grplist){ invnosTmp.Add(lst.invno); } } var itemlistCS = from p in itemlist where invnosTmp.Contains(p.cnno) select p; List<TaxSumm> taxsummCS = GetSubCNTaxSumm(itemCodes, itemlistCS.ToList()); if (trxtype=="CASH") model.CNCSTaxSumm = taxsummCS; else model.CNInvTaxSumm = taxsummCS; return total; }
void Edit(CNNote cn) { var intent = new Intent (this, typeof(EditCNNote)); intent.PutExtra ("cnno", cn.cnno); StartActivity (intent); }
void StartPrint(CNNote inv,CNNoteDtls[] list,int noofcopy ) { string userid = ((GlobalvarsApp)this.Application).USERID_CODE; PrintInvHelper prnHelp = new PrintInvHelper (pathToDatabase, userid,compCode,branchCode); string msg =prnHelp.OpenBTAndPrintCN (mmSocket, mmDevice, inv, list,noofcopy); Toast.MakeText (this, msg, ToastLength.Long).Show (); }
// void PrintInvSumm(DateTime printdate1,DateTime printdate2) // { // mmDevice = null; // findBTPrinter (); // // if (mmDevice == null) // return; // // string userid = ((GlobalvarsApp)this.Application).USERID_CODE; // PrintInvHelper prnHelp = new PrintInvHelper (pathToDatabase, userid); // string msg = prnHelp.PrintInvSumm(mmSocket, mmDevice,printdate1,printdate2); // Toast.MakeText (this, msg, ToastLength.Long).Show (); // // } void PrintInv(CNNote inv,int noofcopy) { //Toast.MakeText (this, "print....", ToastLength.Long).Show (); CNNoteDtls[] list; using (var db = new SQLite.SQLiteConnection (pathToDatabase)){ var ls= db.Table<CNNoteDtls> ().Where (x => x.cnno==inv.cnno).ToList<CNNoteDtls>(); list = new CNNoteDtls[ls.Count]; ls.CopyTo (list); } mmDevice = null; findBTPrinter (); if (mmDevice != null) { StartPrint (inv, list,noofcopy); updatePrintedStatus (inv); var found =listData.Where (x => x.cnno == inv.cnno).ToList (); if (found.Count > 0) { found [0].isPrinted = true; SetViewDlg viewdlg = SetViewDelegate; listView.Adapter = new GenericListAdapter<CNNote> (this, listData, Resource.Layout.ListItemRow, viewdlg); } } }
private bool PrintCNInvoice(CNNote cn,ref double ttlAmt,ref double ttltax) { bool IsfoundInvoice =false; InvoiceDtls[] list =null; Invoice inv=null; string pathToDatabase = ((GlobalvarsApp)Application.Context).DATABASE_PATH; 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) { GetInvoiceText (inv, list); foreach(InvoiceDtls itm in list) { ttlAmt = ttlAmt+ itm.netamount; ttltax = ttltax+itm.tax; } } return IsfoundInvoice; }
void Delete(CNNote inv) { var builder = new AlertDialog.Builder(this); builder.SetMessage("Confimr to Delete?"); builder.SetPositiveButton("YES", (s, e) => { DeleteItem(inv); }); builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ }); builder.Create().Show(); }