Exemple #1
0
        private void SetViewDelegate(View view, object clsobj)
        {
            CNNoteDtls item   = (CNNoteDtls)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;
            }
        }
Exemple #2
0
        public void PrintCNTaxSumm(ref string test,CNNoteDtls[] 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 = "";
            }
        }
Exemple #3
0
        void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            CNNoteDtls 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.cnno, item.ID);
                }
            };
            menu.Show();
        }
Exemple #4
0
        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);
                }
            }
        }
Exemple #5
0
        public string PrintCNDetail(CNNoteDtls itm, int count)
        {
            string test   = "";
            string desc   = itm.description;
            string pline2 = 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);
        }
Exemple #6
0
        void Printreceipt()
        {
            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 ();
            IPrintDocument prtInv = PrintDocManager.GetPrintDocument <PrintCreditNote>();

            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();
            }
        }
Exemple #7
0
        void Delete(CNNoteDtls 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();
        }
Exemple #8
0
        void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            CNNoteDtls 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.CNAllowEdit)
            {
                menu.Menu.RemoveItem(Resource.Id.popedit);
            }
            if (!rights.CNAllowDelete)
            {
                menu.Menu.RemoveItem(Resource.Id.popdelete);
            }
            if (!rights.CNAllowAdd)
            {
                menu.Menu.RemoveItem(Resource.Id.popadd);
            }
            //if allow edit and Invoice printed, remove edit
            //printed invoice not allow to edit
            if (DataHelper.GetCNNotePrintStatus(pathToDatabase, invno, 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.cnno);
                }
                else if (arg1.Item.ItemId == Resource.Id.popedit)
                {
                    Edit(item);
                }
                else if (arg1.Item.ItemId == Resource.Id.popdelete)
                {
                    Delete(item);
                }
            };
            menu.Show();
        }
Exemple #9
0
        void Edit(CNNoteDtls inv)
        {
            //var intent = new Intent(this, typeof(CNEntryActivity));
            var intent = ActivityManager.GetActivity <CNEntryActivityEx>(this.ApplicationContext);

            intent.PutExtra("invoiceno", inv.cnno);
            intent.PutExtra("itemuid", inv.ID.ToString());
            intent.PutExtra("editmode", "EDIT");
            intent.PutExtra("customer", CUSTNAME);
            intent.PutExtra("custcode", CUSTCODE);
            StartActivity(intent);
        }
Exemple #10
0
        void populate(List <CNNoteDtls> list)
        {
            list.Clear();
            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                var list2 = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno)
                            .OrderByDescending(x => x.ID)
                            .ToList <CNNoteDtls> ();

                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);


                CNNoteDtls inv1 = new CNNoteDtls();
                inv1.icode       = "TAX";
                inv1.netamount   = ttlamt;
                inv1.description = "TOTAL EXCL GST";
                CNNoteDtls inv2 = new CNNoteDtls();
                inv2.icode       = "AMOUNT";
                inv2.netamount   = ttltax;
                inv2.description = "TOTAL 6% GST";
                CNNoteDtls inv3 = new CNNoteDtls();
                inv3.icode       = "TAX";
                inv3.netamount   = ttlamt + ttltax;
                inv3.description = "TOTAL INCL GST";
                CNNoteDtls inv4 = new CNNoteDtls();
                inv4.icode       = "AMOUNT";
                inv4.netamount   = roundVal;
                inv4.description = "ROUNDING ADJUST";
                CNNoteDtls inv5 = new CNNoteDtls();
                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);
                }
            }
        }
Exemple #11
0
        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";
        }
Exemple #12
0
        public string PrintCNDetail_NTax(CNNoteDtls 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;
        }
Exemple #13
0
        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 <CNNoteDtls> ().Where(x => x.cnno == invno && x.ID == id).ToList <CNNoteDtls> ();
                if (invlist.Count > 0)
                {
                    CNNoteDtls 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();
                }
            }
        }
Exemple #14
0
 void DeleteItem(CNNoteDtls invdtls)
 {
     using (var db = new SQLite.SQLiteConnection(pathToDatabase))
     {
         var list = db.Table <CNNoteDtls>().Where(x => x.cnno == invdtls.cnno && x.ID == invdtls.ID).ToList <CNNoteDtls>();
         if (list.Count > 0)
         {
             db.Delete(list [0]);
             var arrlist = listData.Where(x => x.cnno == invdtls.cnno && x.ID == invdtls.ID).ToList <CNNoteDtls>();
             if (arrlist.Count > 0)
             {
                 listData.Remove(arrlist [0]);
                 SetViewDlg viewdlg = SetViewDelegate;
                 listView.Adapter = new GenericListAdapter <CNNoteDtls> (this, listData, Resource.Layout.InvDtlItemViewCS, viewdlg);
             }
         }
     }
 }
Exemple #15
0
        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";
        }
 void Delete(CNNoteDtls 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();
 }
        void populate(List<CNNoteDtls> 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<CNNote>().Where(x=>x.cnno==invno).ToList<CNNote>();
                var list2 = db.Table<CNNoteDtls>().Where(x=>x.cnno==invno).ToList<CNNoteDtls>();
                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]);
                }
                CNNoteDtls inv1 = new CNNoteDtls ();
                inv1.icode = "TAX";
                inv1.netamount = ttltax;
                CNNoteDtls inv2 = new CNNoteDtls ();
                inv2.icode = "AMOUNT";
                inv2.netamount = ttlamt;

                list.Add (inv1);
                list.Add (inv2);
            }
        }
 void Edit(CNNoteDtls inv)
 {
     var intent = new Intent(this, typeof(CNEntryActivity));
     intent.PutExtra ("invoiceno",inv.cnno );
     intent.PutExtra ("itemuid",inv.ID.ToString() );
     intent.PutExtra ("editmode","EDIT" );
     intent.PutExtra ("customer",CUSTNAME );
     intent.PutExtra ("custcode",CUSTCODE );
     StartActivity(intent);
 }
 void DeleteItem(CNNoteDtls inv)
 {
     using (var db = new SQLite.SQLiteConnection(pathToDatabase))
     {
         var list = db.Table<CNNoteDtls>().Where(x=>x.cnno==invno&& x.ID==inv.ID).ToList<CNNoteDtls>();
         if (list.Count > 0) {
             db.Delete (list [0]);
             var arrlist= listData.Where(x=>x.cnno==invno&& x.ID==inv.ID).ToList<CNNoteDtls>();
             if (arrlist.Count > 0) {
                 listData.Remove (arrlist [0]);
                 SetViewDlg viewdlg = SetViewDelegate;
                 listView.Adapter = new GenericListAdapter<CNNoteDtls> (this, listData, Resource.Layout.InvDtlItemView, viewdlg);
             }
         }
     }
 }
Exemple #20
0
        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, 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;
            }
            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);
            }

            CNNoteDtls inv = new CNNoteDtls();

            string[] codedesc = spinner.SelectedItem.ToString().Split(new char[] { '|' });
            inv.cnno   = 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, Resources.GetString(Resource.String.msg_invaliditem), 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 <CNNoteDtls> ().Where(x => x.cnno == inv.cnno && x.ID == id).ToList <CNNoteDtls> ();
                if (invlist.Count > 0)
                {
                    CNNoteDtls 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();
        }
Exemple #21
0
        void populate(List <CNNoteDtls> 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 <CNNote>().Where(x => x.cnno == invno).ToList <CNNote>();
                var list2 = db.Table <CNNoteDtls>().Where(x => x.cnno == invno).ToList <CNNoteDtls>();
                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]);
                }
//				CNNoteDtls inv1 = new CNNoteDtls ();
//				inv1.icode = "TAX";
//				inv1.netamount = ttltax;
//				CNNoteDtls inv2 = new CNNoteDtls ();
//				inv2.icode = "AMOUNT";
//				inv2.netamount = ttlamt;
//
//				list.Add (inv1);
//				list.Add (inv2);

                double     roundVal = 0;
                double     ttlNet   = Utility.AdjustToNear(ttlamt + ttltax, ref roundVal);
                CNNoteDtls inv1     = new CNNoteDtls();
                inv1.icode       = "TAX";
                inv1.netamount   = ttlamt;
                inv1.description = "TOTAL EXCL GST";
                CNNoteDtls inv2 = new CNNoteDtls();
                inv2.icode       = "AMOUNT";
                inv2.netamount   = ttltax;
                inv2.description = "TOTAL 6% GST";
                CNNoteDtls inv3 = new CNNoteDtls();
                inv3.icode       = "TAX";
                inv3.netamount   = ttlamt + ttltax;
                inv3.description = "TOTAL INCL GST";
                CNNoteDtls inv4 = new CNNoteDtls();
                inv4.icode       = "AMOUNT";
                inv4.netamount   = roundVal;
                inv4.description = "ROUNDING ADJUST";
                CNNoteDtls inv5 = new CNNoteDtls();
                inv5.icode       = "AMOUNT";
                inv5.netamount   = ttlNet;
                inv5.description = "NET TOTAL";


                list.Add(inv1);
                list.Add(inv2);
                list.Add(inv3);
                if (invno.IndexOf("(CS)") > -1)
                {
                    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);
            //	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);
            }

            CNNoteDtls inv = new CNNoteDtls ();
            string[] codedesc = spinner.SelectedItem.ToString ().Split (new char[]{ '|' });
            inv.cnno = 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<CNNoteDtls> ().Where (x => x.cnno == inv.cnno&& x.ID==id).ToList<CNNoteDtls> ();
                if (invlist.Count > 0) {
                    CNNoteDtls 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 ();
        }
        //        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);
                }
            }
        }
Exemple #24
0
        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;
        }
Exemple #25
0
        void populate(List<CNNoteDtls> list)
        {
            //	comp = DataHelper.GetCompany (pathToDatabase);
            //SqliteConnection.CreateFile(pathToDatabase);
            using (var db = new SQLite.SQLiteConnection(pathToDatabase))
            {
                var list1 = db.Table<CNNote>().Where(x=>x.cnno==invno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<CNNote>();
                var list2 = db.Table<CNNoteDtls>().Where(x=>x.cnno==invno&&x.CompCode==compCode&&x.BranchCode==branchCode).ToList<CNNoteDtls>();
                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]);
                }
                CNNoteDtls inv1 = new CNNoteDtls ();
                inv1.icode = "TAX";
                inv1.netamount = ttltax;
                CNNoteDtls inv2 = new CNNoteDtls ();
                inv2.icode = "AMOUNT";
                inv2.netamount = ttlamt;

                list.Add (inv1);
                list.Add (inv2);
            }
        }
Exemple #26
0
        void populate(List<CNNoteDtls> list)
        {
            list.Clear ();
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                var list2 = db.Table<CNNoteDtls> ().Where (x => x.cnno == inv.cnno)
                    .OrderByDescending(x=>x.ID)
                    .ToList<CNNoteDtls> ();

                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);

                CNNoteDtls inv1 = new CNNoteDtls ();
                inv1.icode = "TAX";
                inv1.netamount = ttlamt;
                inv1.description = "TOTAL EXCL GST";
                CNNoteDtls inv2 = new CNNoteDtls ();
                inv2.icode = "AMOUNT";
                inv2.netamount = ttltax;
                inv2.description = "TOTAL 6% GST" ;
                CNNoteDtls inv3 = new CNNoteDtls ();
                inv3.icode = "TAX";
                inv3.netamount = ttlamt + ttltax;
                inv3.description = "TOTAL INCL GST" ;
                CNNoteDtls inv4 = new CNNoteDtls ();
                inv4.icode = "AMOUNT";
                inv4.netamount =  roundVal;
                inv4.description = "ROUNDING ADJUST";
                CNNoteDtls inv5 = new CNNoteDtls ();
                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);
                }
            }
        }
Exemple #27
0
 void Delete(CNNoteDtls 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();
 }
Exemple #28
0
        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];

            double stqQty = Convert.ToDouble(txtqty.Text);
            double uprice = Convert.ToDouble(txtprice.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);
            }
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                CNNoteDtls invdtl = new CNNoteDtls ();

                if (IsEdit) {
                    var list = db.Table<CNNoteDtls> ().Where (x => x.cnno == inv.cnno && x.ID == IDdtls).ToList<CNNoteDtls> ();
                    if (list.Count > 0) {
                        invdtl = list [0];
                    }
                }

                invdtl.cnno =inv.cnno;
                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";
            RefreshItemList ();
        }
Exemple #29
0
        private void AddBarCodeItem(Item prd )
        {
            //TextView txtcnno =  FindViewById<TextView> (Resource.Id.txtInvnp);
            double stqQty = 1;
            double uprice= Utility.GetUnitPrice (trd, prd);
            double taxval = prd.tax;
            double amount = Math.Round((stqQty * uprice),2);
            double netamount = amount;
            bool taxinclusice = prd.isincludesive;
            double taxamt = 0;
            if (taxinclusice) {
                double percent = (taxval/100) + 1;
                double amt2 =Math.Round( amount / percent,2,MidpointRounding.AwayFromZero);
                taxamt = amount - amt2;
                netamount = amount - taxamt;

            } else {
                taxamt = Math.Round(amount * (taxval / 100),2,MidpointRounding.AwayFromZero);
            }

            CNNoteDtls invdtls = new CNNoteDtls ();
            invdtls.cnno = inv.cnno;
            invdtls.amount = amount;
            invdtls.icode = prd.ICode;
            invdtls.price = uprice;
            invdtls.qty = stqQty;
            invdtls.tax = taxamt;
            invdtls.taxgrp = prd.taxgrp;
            invdtls.netamount = netamount;
            invdtls.description = prd.IDesc;
            //int id = Convert.ToInt32 (ITEMUID);
            //inv..title = spinner.SelectedItem.ToString ();
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                var list =db.Table<CNNoteDtls> ().Where (x => x.cnno == inv.cnno && x.icode == prd.ICode).ToList ();
                if (list.Count > 0) {
                    list [0].qty = list [0].qty + 1;
                    stqQty = list [0].qty;
                    amount = Math.Round((stqQty * uprice),2);
                    netamount = amount;
                    if (taxinclusice) {
                        double percent = (taxval/100) + 1;
                        double amt2 =Math.Round( amount / percent,2,MidpointRounding.AwayFromZero);
                        taxamt = amount - amt2;
                        netamount = amount - taxamt;

                    } else {
                        taxamt = Math.Round(amount * (taxval / 100),2,MidpointRounding.AwayFromZero);
                    }
                    list [0].tax = taxamt;
                    list [0].amount =amount;
                    list [0].netamount = netamount;

                    db.Update (list [0]);
                }else db.Insert (invdtls);
            }
            spinItem.SetSelection (-1);
            Toast.MakeText (this, Resources.GetString(Resource.String.msg_itemadded), ToastLength.Long).Show ();
        }
Exemple #30
0
 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);
     }
 }
Exemple #31
0
 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 ();
 }
Exemple #32
0
 void Edit(CNNoteDtls inv)
 {
     //var intent = new Intent(this, typeof(CNEntryActivity));
     var intent =ActivityManager.GetActivity<CNEntryActivityEx>(this.ApplicationContext);
     intent.PutExtra ("invoiceno",inv.cnno );
     intent.PutExtra ("itemuid",inv.ID.ToString() );
     intent.PutExtra ("editmode","EDIT" );
     intent.PutExtra ("customer",CUSTNAME );
     intent.PutExtra ("custcode",CUSTCODE );
     StartActivity(intent);
 }
Exemple #33
0
 internal string GetCreditNoteText_Template(string templatefilename,string pathToDatabase,string userID,CNNote cn, CNNoteDtls[] list)
 {
     //yet to implement
     return "";
 }
Exemple #34
0
        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];

            double stqQty       = Convert.ToDouble(txtqty.Text);
            double uprice       = Convert.ToDouble(txtprice.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);
            }
            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                CNNoteDtls invdtl = new CNNoteDtls();

                if (IsEdit)
                {
                    var list = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno && x.ID == IDdtls).ToList <CNNoteDtls> ();
                    if (list.Count > 0)
                    {
                        invdtl = list [0];
                    }
                }

                invdtl.cnno          = inv.cnno;
                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";
            RefreshItemList();
        }
        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;
        }
Exemple #36
0
        void populate(List<CNNoteDtls> 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<CNNote>().Where(x=>x.cnno==invno).ToList<CNNote>();
                var list2 = db.Table<CNNoteDtls>().Where(x=>x.cnno==invno).ToList<CNNoteDtls>();
                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]);
                }
            //				CNNoteDtls inv1 = new CNNoteDtls ();
            //				inv1.icode = "TAX";
            //				inv1.netamount = ttltax;
            //				CNNoteDtls inv2 = new CNNoteDtls ();
            //				inv2.icode = "AMOUNT";
            //				inv2.netamount = ttlamt;
            //
            //				list.Add (inv1);
            //				list.Add (inv2);

                double roundVal = 0;
                double ttlNet = Utility.AdjustToNear (ttlamt + ttltax, ref roundVal);
                CNNoteDtls inv1 = new CNNoteDtls ();
                inv1.icode = "TAX";
                inv1.netamount = ttlamt;
                inv1.description = "TOTAL EXCL GST";
                CNNoteDtls inv2 = new CNNoteDtls ();
                inv2.icode = "AMOUNT";
                inv2.netamount = ttltax;
                inv2.description = "TOTAL 6% GST" ;
                CNNoteDtls inv3 = new CNNoteDtls ();
                inv3.icode = "TAX";
                inv3.netamount = ttlamt + ttltax;
                inv3.description = "TOTAL INCL GST" ;
                CNNoteDtls inv4 = new CNNoteDtls ();
                inv4.icode = "AMOUNT";
                inv4.netamount =  roundVal;
                inv4.description = "ROUNDING ADJUST";
                CNNoteDtls inv5 = new CNNoteDtls ();
                inv5.icode = "AMOUNT";
                inv5.netamount = ttlNet;
                inv5.description = "NET TOTAL";

                list.Add (inv1);
                list.Add (inv2);
                list.Add (inv3);
                if (invno.IndexOf("(CS)") >-1) {
                    list.Add (inv4);
                    list.Add (inv5);
                }
            }
        }
Exemple #37
0
        private void AddBarCodeItem(Item prd)
        {
            //TextView txtcnno =  FindViewById<TextView> (Resource.Id.txtInvnp);
            double stqQty       = 1;
            double uprice       = Utility.GetUnitPrice(trd, prd);
            double taxval       = prd.tax;
            double amount       = Math.Round((stqQty * uprice), 2);
            double netamount    = amount;
            bool   taxinclusice = prd.isincludesive;
            double taxamt       = 0;

            if (taxinclusice)
            {
                double percent = (taxval / 100) + 1;
                double amt2    = Math.Round(amount / percent, 2, MidpointRounding.AwayFromZero);
                taxamt    = amount - amt2;
                netamount = amount - taxamt;
            }
            else
            {
                taxamt = Math.Round(amount * (taxval / 100), 2, MidpointRounding.AwayFromZero);
            }

            CNNoteDtls invdtls = new CNNoteDtls();

            invdtls.cnno        = inv.cnno;
            invdtls.amount      = amount;
            invdtls.icode       = prd.ICode;
            invdtls.price       = uprice;
            invdtls.qty         = stqQty;
            invdtls.tax         = taxamt;
            invdtls.taxgrp      = prd.taxgrp;
            invdtls.netamount   = netamount;
            invdtls.description = prd.IDesc;
            //int id = Convert.ToInt32 (ITEMUID);
            //inv..title = spinner.SelectedItem.ToString ();
            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                var list = db.Table <CNNoteDtls> ().Where(x => x.cnno == inv.cnno && x.icode == prd.ICode).ToList();
                if (list.Count > 0)
                {
                    list [0].qty = list [0].qty + 1;
                    stqQty       = list [0].qty;
                    amount       = Math.Round((stqQty * uprice), 2);
                    netamount    = amount;
                    if (taxinclusice)
                    {
                        double percent = (taxval / 100) + 1;
                        double amt2    = Math.Round(amount / percent, 2, MidpointRounding.AwayFromZero);
                        taxamt    = amount - amt2;
                        netamount = amount - taxamt;
                    }
                    else
                    {
                        taxamt = Math.Round(amount * (taxval / 100), 2, MidpointRounding.AwayFromZero);
                    }
                    list [0].tax       = taxamt;
                    list [0].amount    = amount;
                    list [0].netamount = netamount;

                    db.Update(list [0]);
                }
                else
                {
                    db.Insert(invdtls);
                }
            }
            spinItem.SetSelection(-1);
            Toast.MakeText(this, Resources.GetString(Resource.String.msg_itemadded), ToastLength.Long).Show();
        }
        public string OpenBTAndPrintCN(BluetoothSocket mmSocket,BluetoothDevice mmDevice,CNNote inv,CNNoteDtls[] list,int noofcopy )
        {
            string msg = "";

            BluetoothMiniCN (mmSocket, mmDevice, inv, list, noofcopy);

            return msg;
        }
Exemple #39
0
        void Printreceipt()
        {
            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 ();
            IPrintDocument prtInv = PrintDocManager.GetPrintDocument<PrintCreditNote>();
            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 ();
            }
        }
Exemple #40
0
        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);
                }
            }
        }