Exemple #1
0
        internal virtual string GetInvoiceSumm(DateTime printdate1, DateTime printdate2)
        {
            string text       = "";
            bool   isSamedate = printdate1 == printdate2;

            PrintSummHeader(printdate1, printdate2, ref text, isSamedate);
            var invs = DataHelper.GetInvoices(printdate1, printdate2);

            var grp = from inv in invs
                      group inv by inv.invdate
                      into g select new { key = g.Key, results = g };

            double ttlcash   = 0;
            double ttlInv    = 0;
            double ttltax    = 0;
            double ttlamt    = 0;
            double subttltax = 0;
            double subttlamt = 0;
            bool   multiType = false;
            string line      = "";
            int    cont      = 0;

            foreach (var g in grp)               //group by date
            {
                var list   = g.results.OrderBy(x => x.invno);
                var typgrp = from ty in list
                             group ty by ty.trxtype into tg
                             select new { key = tg.Key, results = tg };

                if (!isSamedate)
                {
                    text = text + g.key.ToString("dd-MM-yyyy") + "\n";
                    text = text + "---------- \n";
                }
                multiType = (typgrp.Count() > 1);
                foreach (var tygrp in typgrp)                    //group by trxtype
                {
                    text = text + "[ " + tygrp.key.ToUpper() + " ]\n";
                    var list2 = tygrp.results.OrderBy(x => x.invno);
                    subttltax = 0;
                    subttlamt = 0;
                    cont      = 0;
                    foreach (Invoice inv in list2)
                    {
                        cont      += 1;
                        ttltax    += inv.taxamt;
                        ttlamt    += inv.amount;
                        subttltax += inv.taxamt;
                        subttlamt += inv.amount;
                        if (tygrp.key.ToUpper() == "CASH")
                        {
                            ttlcash = ttlcash + inv.amount + inv.taxamt;
                        }
                        else
                        {
                            ttlInv = ttlInv + inv.amount + inv.taxamt;
                        }
                        line = (cont.ToString() + ".").PadRight(4, ' ') +
                               inv.invno.PadRight(16, ' ') +
                               //inv.trxtype.PadRight (8, ' ') +
                               inv.taxamt.ToString("n2").PadLeft(10, ' ') +
                               inv.amount.ToString("n2").PadLeft(12, ' ') + "\n";
                        text = text + line;
                    }
                    //if (multiType) {
                    if (typgrp.Count() > 1)
                    {
                        text = text + PrintSubTotal(subttltax, subttlamt);
                    }
                    //	}
                    text = text + "\n";
                }
            }

            double ttlCNTax    = 0;
            double ttlCNAmt    = 0;
            double ttlCNCODTax = 0;
            double ttlCNCODAmt = 0;
            double ttlCN       = 0;
            double ttlCNCOD    = 0;
            var    cns         = DataHelper.GetCNNote(printdate1, printdate2);

            foreach (CNNote cn in cns)
            {
                if (cn.trxtype == "CASH")
                {
                    ttlCNCODTax = ttlCNCODTax + cn.taxamt;
                    ttlCNCODAmt = ttlCNCODAmt + cn.amount;
                }
                else
                {
                    ttlCNTax = ttlCNTax + cn.taxamt;
                    ttlCNAmt = ttlCNAmt + cn.amount;
                }
            }
            ttlCN    = ttlCNTax + ttlCNAmt;
            ttlCNCOD = ttlCNCODTax + ttlCNCODAmt;

            double ttl         = ttlamt + ttltax;
            double cashCollect = ttlcash - ttlCNCOD;

            PrintSummFooter(ref text, ttlcash, ttlInv, ttltax, ttlamt, ttlCN, ttlCNCOD, ttl, cashCollect);

            return(text);
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            if (!((GlobalvarsApp)this.Application).ISLOGON)
            {
                Finish();
            }
            SetTitle(Resource.String.title_doedit);
            SetContentView(Resource.Layout.CreateDO);
            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            EventManagerFacade.Instance.GetEventManager().AddListener(this);

            DONO   = Intent.GetStringExtra("dono") ?? "AUTO";
            doInfo = DataHelper.GetDO(pathToDatabase, DONO);
            if (doInfo == null)
            {
                base.OnBackPressed();
            }
            // Create your application here
            _date   = DateTime.Today;
            spinner = FindViewById <Spinner> (Resource.Id.newinv_custcode);
            Spinner  spinnerType = FindViewById <Spinner> (Resource.Id.newinv_type);
            Button   butSave     = FindViewById <Button> (Resource.Id.newinv_bsave);
            Button   butNew      = FindViewById <Button> (Resource.Id.newinv_cancel);
            Button   butFind     = FindViewById <Button> (Resource.Id.newinv_bfind);
            EditText remark      = FindViewById <EditText> (Resource.Id.newinv_custname);

            spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected);
            butSave.Click        += butSaveClick;
            butNew.Click         += butCancelClick;
            TextView invno   = FindViewById <TextView> (Resource.Id.newinv_no);
            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();
            };


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

            dataAdapter2 = ArrayAdapter.CreateFromResource(
                this, Resource.Array.term, Resource.Layout.spinner_item);


            dataAdapter = new ArrayAdapter <String> (this, Resource.Layout.spinner_item, icodes);
            dataAdapter.SetDropDownViewResource(Resource.Layout.SimpleSpinnerDropDownItemEx);
            dataAdapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter     = dataAdapter;
            spinnerType.Adapter = dataAdapter2;

            remark.RequestFocus();
            LoadData();
        }
Exemple #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            if (!((GlobalvarsApp)this.Application).ISLOGON)
            {
                Finish();
            }
            SetContentView(Resource.Layout.InvDtlView);
            TRXTYPE  = Intent.GetStringExtra("trxtype") ?? "CASH";
            invno    = Intent.GetStringExtra("invoiceno") ?? "AUTO";
            CUSTCODE = Intent.GetStringExtra("custcode") ?? "AUTO";
            EDITMODE = Intent.GetStringExtra("editmode") ?? "AUTO";

            if (TRXTYPE == "CASH")
            {
                SetTitle(Resource.String.title_cashitems);
            }
            else
            {
                SetTitle(Resource.String.title_invoiceitems);
            }
            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            COMPCODE       = ((GlobalvarsApp)this.Application).COMPANY_CODE;
            rights         = Utility.GetAccessRights(pathToDatabase);



            isNotAllowEditAfterPrinted = DataHelper.GetInvoicePrintStatus(pathToDatabase, invno, rights);
            txtbarcode            = FindViewById <EditText> (Resource.Id.txtbarcode);
            txtbarcode.Visibility = ViewStates.Visible;
            Button butNew = FindViewById <Button> (Resource.Id.butnewItem);

            butNew.Click += (object sender, EventArgs e) => {
                NewItem(invno);
            };
            if (isNotAllowEditAfterPrinted)
            {
                butNew.Enabled = false;
            }
            if (!rights.InvAllowAdd)
            {
                butNew.Enabled = false;
            }

            Button butInvBack = FindViewById <Button> (Resource.Id.butInvItmBack);

            butInvBack.Click += (object sender, EventArgs e) => {
                Invoice temp = new Invoice();
                UpdateInvoiceAmount(invno, ref temp);

                if (EDITMODE.ToLower() == "new")
                {
                    DeleteInvWithEmptyInovItem();
                }
                Intent intent = null;
                if (temp.trxtype == "CASH")
                {
                    intent = ActivityManager.GetActivity <CashActivity>(this.ApplicationContext);
                }
                else
                {
                    intent = ActivityManager.GetActivity <InvoiceActivity>(this.ApplicationContext);
                }

                StartActivity(intent);
            };

            txtbarcode.SetOnKeyListener(this);
            txtbarcode.InputType = 0;
            GetData();
            populate(listData);
            listView            = FindViewById <ListView> (Resource.Id.invitemList);
            listView.ItemClick += OnListItemClick;
            //listView.Adapter = new CusotmItemListAdapter(this, listData);
            SetViewDlg viewdlg = SetViewDelegate;

            listView.Adapter = new GenericListAdapter <InvoiceDtls> (this, listData, Resource.Layout.InvDtlItemViewCS, viewdlg);
        }
Exemple #4
0
        void populate(List <InvoiceDtls> list)
        {
            comp = DataHelper.GetCompany(pathToDatabase);
            using (var db = new SQLite.SQLiteConnection(pathToDatabase))
            {
                //var list1 = db.Table<Invoice>().Where(x=>x.invno==invno).ToList<Invoice>();
                var list2 = db.Table <InvoiceDtls>().Where(x => x.invno == invno).ToList <InvoiceDtls>();
                //var list3 = db.Table<Trader>().Where(x=>x.CustCode==CUSTCODE).ToList<Trader>();

                double ttlamt = 0;
                double ttltax = 0;
                if (trd != null)
                {
                    CUSTNAME = trd.CustName;
                }
                foreach (var item in list2)
                {
                    ttlamt = ttlamt + item.netamount;
                    ttltax = ttltax + item.tax;
                    list.Add(item);
                }
                if (invoice != null)
                {
                    invoice.amount = ttlamt;
                    db.Update(invoice);
                }
//				InvoiceDtls inv1 = new InvoiceDtls ();
//				inv1.icode = "TAX";
//				inv1.netamount = ttltax;
//				InvoiceDtls inv2 = new InvoiceDtls ();
//				inv2.icode = "AMOUNT";
//				inv2.netamount = ttlamt;
//
//				list.Add (inv1);
//				list.Add (inv2);
                double      roundVal = 0;
                double      ttlNet   = Utility.AdjustToNear(ttlamt + ttltax, ref roundVal);
                InvoiceDtls inv1     = new InvoiceDtls();
                inv1.icode       = "TAX";
                inv1.netamount   = ttlamt;
                inv1.description = "TOTAL EXCL GST";
                InvoiceDtls inv2 = new InvoiceDtls();
                inv2.icode       = "AMOUNT";
                inv2.netamount   = ttltax;
                inv2.description = "TOTAL 6% GST";
                InvoiceDtls inv3 = new InvoiceDtls();
                inv3.icode       = "TAX";
                inv3.netamount   = ttlamt + ttltax;
                inv3.description = "TOTAL INCL GST";
                InvoiceDtls inv4 = new InvoiceDtls();
                inv4.icode       = "AMOUNT";
                inv4.netamount   = roundVal;
                inv4.description = "ROUNDING ADJUST";
                InvoiceDtls inv5 = new InvoiceDtls();
                inv5.icode       = "AMOUNT";
                inv5.netamount   = ttlNet;
                inv5.description = "NET TOTAL";


                list.Add(inv1);
                list.Add(inv2);
                list.Add(inv3);
                if (TRXTYPE == "CASH")
                {
                    list.Add(inv4);
                    list.Add(inv5);
                }
            }
        }
Exemple #5
0
        //AccessRights rights;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            if (!((GlobalvarsApp)this.Application).ISLOGON)
            {
                Finish();
            }
            SetTitle(Resource.String.title_sonew);
            SetContentView(Resource.Layout.CreateSO);
            EventManagerFacade.Instance.GetEventManager().AddListener(this);

            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            compcode       = ((GlobalvarsApp)this.Application).COMPANY_CODE;
            apara          = DataHelper.GetAdPara(pathToDatabase);
            rights         = Utility.GetAccessRights(pathToDatabase);

            // Create your application here
            _date       = DateTime.Today;
            spinner     = FindViewById <Spinner> (Resource.Id.newinv_custcode);
            spinnerBill = FindViewById <Spinner> (Resource.Id.newinv_billto);

            Button butSave     = FindViewById <Button> (Resource.Id.newinv_bsave);
            Button butNew      = FindViewById <Button> (Resource.Id.newinv_cancel);
            Button butFind     = FindViewById <Button> (Resource.Id.newinv_bfind);
            Button butBillFind = FindViewById <Button> (Resource.Id.newinv_billfind);

            butSave.Click += butSaveClick;
            butNew.Click  += butCancelClick;
            TextView invno = FindViewById <TextView> (Resource.Id.newinv_no);

            invno.Text = "AUTO";
            EditText trxdate = FindViewById <EditText> (Resource.Id.newinv_date);

            trxdate.Text = _date.ToString("dd-MM-yyyy");
//			trxdate.Click += delegate(object sender, EventArgs e) {
//				ShowDialog (0);
//			};
            if (rights.SOEditTrxDate)
            {
                trxdate.Click += delegate(object sender, EventArgs e) {
                    ShowDialog(0);
                };
            }
            else
            {
                trxdate.Enabled = false;
            }

            butFind.Click += (object sender, EventArgs e) => {
                ShowCustLookUp();
            };
            butBillFind.Click += (object sender, EventArgs e) => {
                ShowBillToLookUp();
            };


            //SqliteConnection.CreateFile(pathToDatabase);
            using (var db = new SQLite.SQLiteConnection(pathToDatabase))
            {
                items = db.Table <Trader> ().ToList <Trader> ();
            }

            var icodes  = GetCustCode(IsValidCustTo);
            var icodes2 = GetCustCode(IsValidBillTo);

            dataAdapter = new ArrayAdapter <String> (this, Resource.Layout.spinner_item, icodes);
            dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = dataAdapter;

            dataAdapter2 = new ArrayAdapter <String> (this, Resource.Layout.spinner_item, icodes2);
            dataAdapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerBill.Adapter = dataAdapter2;
        }
Exemple #6
0
        private void CreateNewSO()
        {
            SaleOrder so      = new SaleOrder();
            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  sodate   = Utility.ConvertToDate(trxdate.Text);
            DateTime  tmr      = sodate.AddDays(1);
            AdNumDate adNum    = DataHelper.GetNumDate(pathToDatabase, sodate, "SO");
            Spinner   spinner  = FindViewById <Spinner> (Resource.Id.newinv_custcode);
            TextView  txtinvno = FindViewById <TextView> (Resource.Id.newinv_no);
            TextView  custname = FindViewById <TextView> (Resource.Id.newinv_custname);
            EditText  custpo   = FindViewById <EditText> (Resource.Id.newinv_po);
            EditText  remark   = FindViewById <EditText> (Resource.Id.newinv_remark);
            string    prefix   = apara.SOPrefix.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;
            }

            string[] codes2 = spinnerBill.SelectedItem.ToString().Split(new char[] { '|' });
            string   billTo = "";

            if (codes.Length > 0)
            {
                billTo = codes2 [0].Trim();
            }

            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                string sono         = "";
                int    runno        = adNum.RunNo + 1;
                int    currentRunNo = DataHelper.GetLastSORunNo(pathToDatabase, sodate);
                if (currentRunNo >= runno)
                {
                    runno = currentRunNo + 1;
                }

                sono = prefix + sodate.ToString("yyMM") + runno.ToString().PadLeft(4, '0');

                txtinvno.Text  = sono;
                so.sodate      = sodate;
                so.trxtype     = "SO";
                so.created     = DateTime.Now;
                so.sono        = sono;
                so.billTo      = billTo;
                so.remark      = remark.Text.ToUpper();
                so.custpono    = custpo.Text.ToUpper();
                so.amount      = 0;
                so.custcode    = codes [0].Trim();
                so.description = codes [1].Trim();
                so.isUploaded  = false;

                txtinvno.Text = sono;
                db.Insert(so);
                adNum.RunNo = runno;
                if (adNum.ID >= 0)
                {
                    db.Update(adNum);
                }
                else
                {
                    db.Insert(adNum);
                }
            }

            ShowItemEntry(so, codes);
        }
Exemple #7
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			if (!((GlobalvarsApp)this.Application).ISLOGON) {
				Finish ();
			}
			SetTitle (Resource.String.title_creditnotenew);
			SetContentView (Resource.Layout.CreateCNote);
			EventManagerFacade.Instance.GetEventManager().AddListener(this);
			pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
			compcode = ((GlobalvarsApp)this.Application).COMPANY_CODE;
			apara =  DataHelper.GetAdPara (pathToDatabase);
			rights = Utility.GetAccessRights (pathToDatabase);

			// Create your application here
			_date = DateTime.Today;
			spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode);

			Button butSave = FindViewById<Button> (Resource.Id.newinv_bsave);
			Button butNew = 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;
			butNew.Click += butCancelClick;
			TextView cnno =  FindViewById<TextView> (Resource.Id.newinv_no);
			cnno.Text = "AUTO";
			EditText trxdate =  FindViewById<EditText> (Resource.Id.newinv_date);
 			trxdate.Text = _date.ToString ("dd-MM-yyyy");
//			trxdate.Click += delegate(object sender, EventArgs e) {
//				ShowDialog (0);
//			};
			if (rights.CNEditTrxDate) {
				trxdate.Click += delegate(object sender, EventArgs e) {
					ShowDialog (0);
				};
			} else
				trxdate.Enabled = false;

			butFind.Click+= (object sender, EventArgs e) => {
				ShowCustLookUp();
			};

			butFindInv.Click+= (object sender, EventArgs e) => {
				ShowInvLookUp();
			};

			pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
			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;

		}
Exemple #8
0
		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);
		}
Exemple #9
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);
                }
            }
        }