Exemplo n.º 1
0
        public void PrintCustomerInv(ref string test,Invoice inv,string title ="CUSTOMER")
        {
            Trader comp = DataHelper.GetTrader (pathToDatabase, inv.custcode);
            test += "------------------------------------------\n";
            test += title+"\n";
            string tel = string.IsNullOrEmpty (comp.Tel) ? " " : comp.Tel.Trim ();
            string fax = string.IsNullOrEmpty (comp.Fax) ? " " : comp.Fax.Trim ();
            string addr1 =string.IsNullOrEmpty (comp.Addr1) ? "" : comp.Addr1.Trim ();
            string addr2 =string.IsNullOrEmpty (comp.Addr2) ? "" : comp.Addr2.Trim ();
            string addr3 =string.IsNullOrEmpty (comp.Addr3) ? "" : comp.Addr3.Trim ();
            string addr4 =string.IsNullOrEmpty (comp.Addr4) ? "" : comp.Addr4.Trim ();
            string gst =string.IsNullOrEmpty (comp.gst) ? "" : comp.gst.Trim ();

            //PrintLongText (ref test, comp.CustName.Trim ());
            PrintLongText (ref test, inv.description.ToUpper().Trim ());

            if (addr1!="")
                test += comp.Addr1.Trim () + "\n";
            if (addr2!="")
                test += comp.Addr2.Trim () + "\n";
            if (addr3!="")
                test += comp.Addr3.Trim () + "\n";
            if (addr4!="")
                test += comp.Addr4.Trim () + "\n";

            test += "TEL:" + tel+"  FAX:"+fax+"\n";
            test += "GST NO:" + gst+"\n";
            test += "------------------------------------------\n";
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            if (!((GlobalvarsApp)this.Application).ISLOGON) {
                Finish ();
            }
            SetContentView (Resource.Layout.CreateInvoice);
            EventManagerFacade.Instance.GetEventManager().AddListener(this);
            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;

            INVOICENO = Intent.GetStringExtra ("invoiceno") ?? "AUTO";
            invInfo =DataHelper.GetInvoice (pathToDatabase, INVOICENO);
            if (invInfo == null) {
                base.OnBackPressed ();
            }
            // Create your application here

            spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode);
            Spinner spinnerType = FindViewById<Spinner> (Resource.Id.newinv_type);
            Button butSave = FindViewById<Button> (Resource.Id.newinv_bsave);
            butSave.Text = "SAVE";
            Button butCancel = FindViewById<Button> (Resource.Id.newinv_cancel);
            Button butFind = FindViewById<Button> (Resource.Id.newinv_bfind);
            spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected);

            butSave.Click += butSaveClick;
            butCancel.Click += butCancelClick;

            EditText trxdate =  FindViewById<EditText> (Resource.Id.newinv_date);
            trxdate.Click += delegate(object sender, EventArgs e) {
                ShowDialog (0);
            };
            butFind.Click+= (object sender, EventArgs e) => {
                ShowCustLookUp();
            };

            apara =  DataHelper.GetAdPara (pathToDatabase);
            LoadTrader ();

            List<string> icodes = new List<string> ();
            foreach (Trader item in custs) {
                icodes.Add (item.CustCode+" | "+item.CustName);
            }

            dataAdapter = new ArrayAdapter<String> (this, Resource.Layout.spinner_item, icodes);
            dataAdapter2 =ArrayAdapter.CreateFromResource (
                this, Resource.Array.trxtype, Resource.Layout.spinner_item);

            //dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            dataAdapter.SetDropDownViewResource(Resource.Layout.SimpleSpinnerDropDownItemEx);
            dataAdapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            // attaching data adapter to spinner
            spinner.Adapter =dataAdapter;
            spinnerType.Adapter =dataAdapter2;
            LoadData ();
        }
Exemplo n.º 3
0
        public void PrintHeader(Stream mmOutputStream,Invoice inv,string pageno)
        {
            //SetLQMode (mmOutputStream,true);
            SetDoubleStrike(mmOutputStream, true);
            SetBold(mmOutputStream, true);
            SetCenter(mmOutputStream, true);
            string[] names = compInfo.CompanyName.Split (new char[] {
                '|'
            });
            string compname = (names.Length > 1) ? names [1] : names [0];
            byte[] charfont = Encoding.ASCII.GetBytes(compname);
            mmOutputStream.Write(charfont, 0, charfont.Length);
            SetBold(mmOutputStream, false);
            SetDoubleStrike(mmOutputStream, false);
            Set15CPI (mmOutputStream);
            charfont = Encoding.ASCII.GetBytes(" ("+compInfo.RegNo+")\n");
            line =1;
            mmOutputStream.Write(charfont, 0, charfont.Length);
            Set12CPI (mmOutputStream);
            Set1Per6InchLineSpacing (mmOutputStream);

            string address = GetCompAddress (compInfo);
            charfont = Encoding.ASCII.GetBytes(address);
            mmOutputStream.Write(charfont, 0, charfont.Length);
            SetCenter(mmOutputStream, false);
            SetLineFeed (mmOutputStream, 2);

            Trader cust = DataHelper.GetTrader (pathToDatabase, inv.custcode);
            //string strline = cust.CustName.ToUpper().PadRight(65, ' ') + "  TAX INVOICE\n"; line +=1;
            string strline = inv.description.ToUpper().PadRight(65, ' ') + "  TAX INVOICE\n"; line +=1;
            SetBold(mmOutputStream, true);
            charfont = Encoding.ASCII.GetBytes(strline);
            mmOutputStream.Write(charfont, 0, charfont.Length);

            SetBold(mmOutputStream, false);
            string line1 = cust.Addr1.ToUpper ().PadRight (65, ' ')  +"  INVOICE NO: " + inv.invno + "\n";
            line +=1;
            line1 = line1 + cust.Addr2.ToUpper ().PadRight (65, ' ') + "  DATE      : " + inv.invdate.ToString ("dd-MM-yyyy") + "\n";
            line +=1;
            line1 = line1 +  cust.Addr3.ToUpper().PadRight(65, ' ') + "  TERMS     : "+cust.PayCode+ "\n";
            line +=1;
            address = "TEL: " + cust.Tel + "   FAX: " + cust.Fax;
            line1 = line1 +  address .ToUpper().PadRight(65, ' ') + "  PAGE NO   : "+pageno+"\n";
            line +=1;
            address = "GST NO : " + cust.gst;
            line1 = line1 + address.PadRight(65, ' ') + " \n";
            line +=1;
            charfont = Encoding.ASCII.GetBytes(line1);
            mmOutputStream.Write(charfont, 0, charfont.Length);
            line1 = "";
            PrintCaption (ref line1);
            charfont = Encoding.ASCII.GetBytes(line1);
            mmOutputStream.Write(charfont, 0, charfont.Length);
        }
Exemplo n.º 4
0
 public void UpdateInvoiceAmount(string invno,ref Invoice inv)
 {
     using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
         var itemlist = db.Table<InvoiceDtls> ().Where (x => x.invno == invno);
         double ttlamt= itemlist.Sum (x => x.netamount);
         double ttltax= itemlist.Sum (x => x.tax);
         var invlist =db.Table<Invoice> ().Where (x => x.invno == invno).ToList<Invoice> ();
         if (invlist.Count > 0) {
             invlist [0].amount = ttlamt;
             invlist [0].taxamt = ttltax;
             inv = invlist [0];
             db.Update (invlist [0]);
         }
     }
 }
Exemplo n.º 5
0
 private void GetInvoiceText(Invoice inv, InvoiceDtls[] list)
 {
     prtcompHeader.PrintCompHeader (ref text);
     prtCustHeader.PrintCustomerInv (ref text, inv);
     prtHeader.PrintHeader_NTax (ref text, inv);
     string dline = "";
     double ttlAmt = 0;
     double ttltax = 0;
     int count = 0;
     foreach (InvoiceDtls itm in list) {
         count += 1;
         dline = dline + prtDetail.PrintDetail_NTax (itm, count);
         ttlAmt = ttlAmt + itm.netamount;
         ttltax = ttltax + itm.tax;
     }
     text += dline;
     prtTotal.PrintTotal_NTax (ref text, ttlAmt, ttltax);
     prtFooter.PrintFooter (ref text);
     text += "\nTHANK YOU\n\n\n\n\n\n\n\n";
 }
Exemplo n.º 6
0
 private void GetInvoiceText(Invoice inv, InvoiceDtls[] list)
 {
     prtcompHeader.PrintCompHeader (ref text);
     prtCustHeader.PrintCustomerInv (ref text, inv);
     prtHeader.PrintHeader (ref text, inv);
     string dline = "";
     double ttlAmt = 0;
     double ttltax = 0;
     int count = 0;
     foreach (InvoiceDtls itm in list) {
         count += 1;
         dline = dline + prtDetail.PrintDetail (itm, count);
         ttlAmt = ttlAmt + itm.netamount;
         ttltax = ttltax + itm.tax;
     }
     text += dline;
     if (inv.trxtype=="CASH")
      	 prtTotal.PrintTotalAjust (ref text, ttlAmt, ttltax);
     else prtTotal.PrintTotal (ref text, ttlAmt, ttltax);
     prtTaxSummary.PrintTaxSumm (ref text, list);
     prtFooter.PrintFooter (ref text);
     text += "\nTHANK YOU\n\n\n\n\n\n\n\n";
 }
Exemplo n.º 7
0
 void Edit(Invoice inv)
 {
     //var intent = new Intent (this, typeof(EditInvoice));
     var intent =ActivityManager.GetActivity<POSSalesActivity >(this.ApplicationContext);
     intent.PutExtra ("trxtype", inv.trxtype);
     intent.PutExtra ("invoiceno", inv.invno);
     StartActivity (intent);
 }
Exemplo n.º 8
0
 void Delete(Invoice inv)
 {
     var builder = new AlertDialog.Builder(this);
     builder.SetMessage(Resources.GetString(Resource.String.msg_confirmdelete)+"?");
     builder.SetPositiveButton("YES", (s, e) => { DeleteItem(inv); });
     builder.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ });
     builder.Create().Show();
 }
Exemplo n.º 9
0
 void loadInvouce(string invno)
 {
     using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
         var list = db.Table<Invoice> ().Where (x => x.invno == invno).ToList<Invoice> ();
         if (list.Count > 0) {
             inv = list [0];
         }
     }
 }
Exemplo n.º 10
0
        void CreateNewInv()
        {
            DateTime invdate = Utility.ConvertToDate (txtInvDate.Text);
            DateTime tmr = invdate.AddDays (1);
            AdNumDate adNum;// = DataHelper.GetNumDate (pathToDatabase, invdate);
            apara =  DataHelper.GetAdPara (pathToDatabase);
            string[] prefixs = apara.Prefix.Trim ().ToUpper ().Split(new char[]{'|'});
            string prefix = "";
            adNum = DataHelper.GetNumDate (pathToDatabase, invdate, "INV");
            if (prefixs.Length > 1) {
                prefix = prefixs [0];
            }else prefix = prefixs [0];

            invno = "";
            int runno = adNum.RunNo + 1;
            int currentRunNo =DataHelper.GetLastInvRunNo (pathToDatabase, invdate,"INVOICE");
            if (currentRunNo >= runno)
                runno = currentRunNo + 1;

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

            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                inv = new Invoice ();
                inv.invno= invno;
                inv.invdate = invdate;
                inv.trxtype = "INVOICE";
                inv.created = DateTime.Now;
                inv.amount = 0;
                inv.isUploaded = false;
                inv.remark ="";
                db.Insert (inv);
                adNum.RunNo = runno;
                if (adNum.ID >= 0)
                    db.Update (adNum);
                else
                    db.Insert (adNum);
            }
            txtInvNo.Text = inv.invno;
            txtInvDate.Text = inv.invdate.ToString ("dd-MM-yyyy");
            txtInvMode.Text = "NEW";
            IsSave = false;
            IsFirePaid = false;
            IsFirePaidOnly = false;
            EnableControLs (true, true, false, true, false);
        }
Exemplo n.º 11
0
 void PrintInvoice(Invoice inv, InvoiceDtls[] list, ref string test,bool needFooter=true)
 {
     PrintCompHeader (ref test);
     PrintCustomer (ref test, inv.custcode);
     PrintHeader (ref test, inv);
     string dline = "";
     double ttlAmt = 0;
     double ttltax = 0;
     int count = 0;
     foreach (InvoiceDtls itm in list) {
         count += 1;
         dline = dline + PrintDetail (itm, count);
         ttlAmt = ttlAmt + itm.netamount;
         ttltax = ttltax + itm.tax;
     }
     test += dline;
     PrintTotal (ref test, ttlAmt, ttltax);
     PrintTaxSumm (ref test, list);
     if (needFooter) {
         PrintFooter (ref test);
         test += "\nTHANK YOU\n\n\n\n\n\n\n\n";
     }else test += "\n\n";
 }
Exemplo n.º 12
0
        Invoice[] GetInvoices(DateTime printdate1, DateTime printdate2)
        {
            Invoice[] invs =  {

            };
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                var list = db.Table<Invoice> ().Where (x => x.invdate >= printdate1 && x.invdate <= printdate2).OrderBy (x => x.invdate).ToList<Invoice> ();
                invs = new Invoice[list.Count];
                list.CopyTo (invs);
            }
            return invs;
        }
Exemplo n.º 13
0
        //Bluetooth Printer -Mini Bluetooth Printer
        public void BluetoothMini(BluetoothSocket mmSocket,BluetoothDevice mmDevice,Invoice inv,InvoiceDtls[] list,int noofcopy)
        {
            msg = "";
            Stream mmOutputStream;
            //TextView txtv = FindViewById<TextView> (Resource.Id.textView2);
            try {
                UUID uuid = UUID.FromString ("00001101-0000-1000-8000-00805F9B34FB");

                mmSocket = mmDevice.CreateInsecureRfcommSocketToServiceRecord (uuid);
                if (mmSocket == null) {
                    //txtv.Text = "Error creating sockect";
                    msg =  "Error creating sockect";
                    //errmsg.Append(msg);
                    return;
                }
                //txtv.Text = mmDevice.BondState.ToString ();
                if (mmDevice.BondState == Bond.Bonded) {
                    //errmsg.Append("Start to connect\n");

                    //mmSocket.Connect ();
                    TrytoConnect(mmSocket);

                    Thread.Sleep (300);
                    //mmInputStream = mmSocket.InputStream;
                    //errmsg.Append("connected\n");
                    mmOutputStream = mmSocket.OutputStream;
                    byte[] charfont;
                    charfont = new Byte[] { 27, 64 }; //Char font 9x17
                    mmOutputStream.Write(charfont, 0, charfont.Length);
                    if (apara.PaperSize=="58mm")
                    {
                        charfont = new Byte[] { 27, 33, 1 }; //Char font 9x17
                        //charfont = new Byte[] { 27, 77, 1 }; //Char font 9x17
                        mmOutputStream.Write(charfont, 0, charfont.Length);
                    }

                    if (apara.PaperSize=="80mm")
                    {
                        charfont = new Byte[] { 27, 33, 0 }; //Char font 12x24
                        //charfont = new Byte[] { 27, 77, 1 }; //Char font 9x17
                        mmOutputStream.Write(charfont, 0, charfont.Length);
                    }
                    charfont = new Byte[] { 28, 38 };
                    mmOutputStream.Write(charfont, 0, charfont.Length);
                    //charfont = new Byte[] { 28, 67,0,48 };
                //	mmOutputStream.Write(charfont, 0, charfont.Length);
                    //charfont = new Byte[] { 27, 82, 15 }; //Char font 9x17
                //	mmOutputStream.Write(charfont, 0, charfont.Length);
                    string test = "";
                    //errmsg.Append("Set printer\n");
                    PrintInvoice (inv, list, ref test);
                    //var encoding = Encoding.GetEncoding(936);
                    //byte[] source = Encoding.Unicode.GetBytes(text);
                    //byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
                    //errmsg.Append("Start Endcoidng\n");
                    byte[] cc = Encoding.GetEncoding("GB18030").GetBytes(test);
                    for (int i=0; i<noofcopy;i++)
                    {
                        int rem;
                        int result =Math.DivRem(cc.Length, 2048, out rem);
                        int pos =0;
                        for(int line= 0;line<result;line++)
                        {
                            IsStreamCanWrite (mmOutputStream);
                            mmOutputStream.Write (cc, pos, 2048);
                            pos += 2048;
                        }
                        if (rem >0)
                            mmOutputStream.Write (cc, pos, rem);
                        //mmOutputStream.BeginWrite(cc,0,cc.Length,
                        //mmOutputStream.Write (cc, 0, cc.Length);
                        Thread.Sleep (3000);
                        //mmOutputStream.Flush ();
                    }
                    Thread.Sleep (300);
                    charfont = new Byte[] { 28, 46 };
                    mmOutputStream.Write(charfont, 0, charfont.Length);
                    mmOutputStream.Close ();
                    //mmInputStream.Close();
                    mmSocket.Close ();
                    msg ="Printing....";
                } else {
                    //txtv.Text = "Device not connected";
                    msg= "Device not connected";
                    //errmsg.Append(msg);
                }
            } catch (Exception ex) {
                msg = ex.Message;
            }
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public void PrintDetalis(Stream mmOutputStream, Invoice inv, InvoiceDtls[] invdtls)
        {
            ttlline = 0;
            _ttltax = 0;
            _ttlAmt = 0;
            string line   = "";
            int    itemno = 1;

            byte[] charfont;
            foreach (InvoiceDtls dtl in invdtls)
            {
                if (dtl.icode.Length < 15 && dtl.description.Length < 28)
                {
                    ttlline += 1;
                    line     = (itemno.ToString() + ".").PadRight(4, ' ') +
                               dtl.icode.ToUpper().PadRight(16, ' ') +
                               dtl.description.ToUpper().PadRight(29, ' ') +
                               dtl.price.ToString("n2").PadLeft(9, ' ') +
                               dtl.qty.ToString("n0").PadLeft(5, ' ') +
                               "".PadLeft(6, ' ') +
                               dtl.tax.ToString("n2").PadLeft(8, ' ') +
                               dtl.taxgrp.PadLeft(7, ' ') +
                               dtl.amount.ToString("n2").PadLeft(10, ' ') + "\n";
                    PrintLine(line, mmOutputStream);
                }
                else if (dtl.icode.Length > 15 && dtl.description.Length < 28)
                {
                    ttlline += 2;
                    line     = (itemno.ToString() + ".").PadRight(4, ' ') +
                               dtl.icode.Substring(0, 15).ToUpper().PadRight(16, ' ') +
                               dtl.description.ToUpper().PadRight(29, ' ') +
                               dtl.price.ToString("n2").PadLeft(9, ' ') +
                               dtl.qty.ToString("n0").PadLeft(5, ' ') +
                               "".PadLeft(6, ' ') +
                               dtl.tax.ToString("n2").PadLeft(8, ' ') +
                               dtl.taxgrp.PadLeft(7, ' ') +
                               dtl.amount.ToString("n2").PadLeft(10, ' ') + "\n";
                    PrintLine(line, mmOutputStream);
                    PrintLine(dtl.icode.ToUpper().Substring(15) + "\n", mmOutputStream);
                }
                else if (dtl.description.Length > 28)
                {
                    List <string> lines = GetLine(dtl.description, 28);
                    ttlline = ttlline + lines.Count;
                    List <string> ICodes = new List <string> ();
                    if (dtl.icode.Length > 15)
                    {
                        ICodes.Add(dtl.icode.ToUpper().Substring(0, 15));
                        ICodes.Add(dtl.icode.ToUpper().Substring(15));
                    }
                    else
                    {
                        ICodes.Add(dtl.icode.ToUpper());
                    }
                    for (int i = 0; i < lines.Count; i++)
                    {
                        ICodes.Add("");
                    }

                    line = (itemno.ToString() + ".").PadRight(4, ' ') +
                           ICodes[0].PadRight(16, ' ') +
                           lines[0].PadRight(29, ' ') +
                           dtl.price.ToString("n2").PadLeft(9, ' ') +
                           dtl.qty.ToString("n0").PadLeft(5, ' ') +
                           "".PadLeft(6, ' ') +
                           dtl.tax.ToString("n2").PadLeft(8, ' ') +
                           dtl.taxgrp.PadLeft(7, ' ') +
                           dtl.amount.ToString("n2").PadLeft(10, ' ') + "\n";
                    PrintLine(line, mmOutputStream);
                    for (int i = 1; i < lines.Count; i++)
                    {
                        line = (itemno.ToString() + ".").PadRight(4, ' ') +
                               ICodes[i].PadRight(16, ' ') +
                               lines[i].PadRight(29, ' ') + "\n";
                        PrintLine(line, mmOutputStream);
                    }
                }

                itemno += 1;
                _ttltax = _ttltax + dtl.tax;
                _ttlAmt = _ttlAmt + dtl.netamount;
            }


            //int remindline = 35 - ttlline;
            //SetLineFeed (mmOutputStream, remindline);
        }
Exemplo n.º 16
0
 void PrintInv(Invoice inv,int noofcopy)
 {
     //Toast.MakeText (this, "print....", ToastLength.Long).Show ();
     InvoiceDtls[] list;
     using (var db = new SQLite.SQLiteConnection (pathToDatabase)){
         var ls= db.Table<InvoiceDtls> ().Where (x => x.invno==inv.invno).ToList<InvoiceDtls>();
         list = new InvoiceDtls[ls.Count];
         ls.CopyTo (list);
     }
     //mmDevice = null;
     //findBTPrinter ();
     IPrintDocument prtInv = PrintDocManager.GetPrintDocument<PrintInvoice>();
     prtInv.SetDocument (inv);
     prtInv.SetDocumentDtls(list);
     prtInv.SetNoOfCopy (noofcopy);
     prtInv.SetCallingActivity (this);
     if (prtInv.StartPrint ()) {
         updatePrintedStatus (inv);
         var found = listData.Where (x => x.invno == inv.invno).ToList ();
         if (found.Count > 0) {
             found [0].isPrinted = true;
             SetViewDlg viewdlg = SetViewDelegate;
             listView.Adapter = new GenericListAdapter<Invoice> (this, listData, Resource.Layout.ListItemRow, viewdlg);
         }
     } else {
         Toast.MakeText (this, prtInv.GetErrMsg(), ToastLength.Long).Show ();
     }
 }
Exemplo n.º 17
0
        public List <string> GetPrintDetalis(Invoice inv, InvoiceDtls[] invdtls)
        {
            List <string> text = new List <string>();

            ttlline = 0;
            _ttltax = 0;
            _ttlAmt = 0;
            string line   = "";
            int    itemno = 1;

            byte[]             charfont;
            Regex              re        = new Regex("\r\n$");
            string             desc      = "";
            IEnumerable <Item> itemcodes = DataHelper.GetItems();
            string             uom       = "";

            foreach (InvoiceDtls dtl in invdtls)
            {
                uom = "";
                var item = from p in itemcodes  where p.ICode == dtl.icode select p;
                if (item.ToList().Count > 0)
                {
                    uom = item.ToList() [0].StdUom;
                }

                desc = re.Replace(dtl.description, "").ToUpper();
                if (dtl.icode.Length < 15 && desc.Length < 28)
                {
                    ttlline += 1;
                    line     = (itemno.ToString() + ".").PadRight(4, ' ') +
                               dtl.icode.ToUpper().PadRight(16, ' ') +
                               desc.PadRight(29, ' ') +
                               dtl.price.ToString("n2").PadLeft(9, ' ') +
                               dtl.qty.ToString("n0").PadLeft(5, ' ') +
                               uom.PadLeft(6, ' ') +
                               dtl.tax.ToString("n2").PadLeft(8, ' ') +
                               dtl.taxgrp.PadLeft(7, ' ') +
                               dtl.amount.ToString("n2").PadLeft(10, ' ') + "\n";
                    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, ' ') + "\n";
                    text.Add(line);
                    text.Add("".PadRight(4, ' ') + dtl.icode.ToUpper().Substring(15) + "\n");
                }
                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, ' ') + "\n";
                    text.Add(line);
                    for (int i = 1; i < lines.Count; i++)
                    {
                        line = "".PadRight(4, ' ') +
                               ICodes[i].PadRight(16, ' ') +
                               lines[i].PadRight(29, ' ') + "\n";
                        text.Add(line);
                    }
                }

                itemno += 1;
                _ttltax = _ttltax + dtl.tax;
                _ttlAmt = _ttlAmt + dtl.netamount;
            }

            return(text);
        }
Exemplo n.º 18
0
        private bool SaveInvoice()
        {
            bool lSave = false;
            Invoice inv = new Invoice ();
            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 lSave;
            }
            DateTime invdate = Utility.ConvertToDate (trxdate.Text);
            Spinner spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode);
            //Spinner spinner2 = FindViewById<Spinner> (Resource.Id.newinv_type);
            TextView txtinvno =FindViewById<TextView> (Resource.Id.newinv_no);
            EditText txtcustname = FindViewById<EditText> (Resource.Id.newinv_custname);
            EditText remark = FindViewById<EditText> (Resource.Id.newinv_remark);

            if (spinner.SelectedItem == null) {
                Toast.MakeText (this, Resources.GetString(Resource.String.msg_invalidcust), ToastLength.Long).Show ();
                spinner.RequestFocus ();
                return lSave;
            }

            string[] codes = spinner.SelectedItem.ToString().Split (new char[]{ '|' });
            if (codes.Length == 0)
                return lSave;

            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {

                invInfo.invdate = invdate;
                invInfo.trxtype = TRXTYPE;//spinner2.SelectedItem.ToString ();
                invInfo.created = DateTime.Now;
                invInfo.description = codes [1].Trim ();
                invInfo.remark = remark.Text.ToUpper ();
                //inv.amount = 0;
                invInfo.custcode = codes [0].Trim ();
                invInfo.isUploaded = false;

                if (codes [0].Trim () == "COD" || codes [0].Trim () == "CASH") {
                    inv.description = txtcustname.Text.ToUpper ();
                }

                db.Update (invInfo);
                lSave = true;
            }

            return lSave;
        }
Exemplo n.º 19
0
        public string OpenBTAndPrint(BluetoothSocket mmSocket,BluetoothDevice mmDevice,Invoice inv,InvoiceDtls[] list,int noofcopy )
        {
            string msg = "";

            BluetoothMini (mmSocket, mmDevice, inv, list, noofcopy);
            return msg;
        }
Exemplo n.º 20
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            if (!((GlobalvarsApp)this.Application).ISLOGON) {
                Finish ();
            }
            INVOICENO= Intent.GetStringExtra ("invoiceno")??"AUTO";
            TRXTYPE= Intent.GetStringExtra ("trxtype") ?? "CASH";
            if (TRXTYPE == "CASH") {
                SetTitle (Resource.String.title_cashedit);
            } else {
                SetTitle (Resource.String.title_invoiceedit);
            }
            SetContentView (Resource.Layout.CreateInvoice);
            EventManagerFacade.Instance.GetEventManager().AddListener(this);
            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            rights = Utility.GetAccessRights (pathToDatabase);

            invInfo =DataHelper.GetInvoice (pathToDatabase, INVOICENO);
            if (invInfo == null) {
                base.OnBackPressed ();
            }
            // Create your application here

            spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode);
            spinnerType = FindViewById<Spinner> (Resource.Id.newinv_type);
            Button butSave = FindViewById<Button> (Resource.Id.newinv_bsave);
            butSave.Text = Resources.GetString(Resource.String.but_save);// "SAVE";
            Button butCancel = FindViewById<Button> (Resource.Id.newinv_cancel);
            Button butFind = FindViewById<Button> (Resource.Id.newinv_bfind);
            spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected);

            butSave.Click += butSaveClick;
            butCancel.Click += butCancelClick;
            spinnerType.Enabled = false;

            EditText trxdate =  FindViewById<EditText> (Resource.Id.newinv_date);
            //			trxdate.Click += delegate(object sender, EventArgs e) {
            //				ShowDialog (0);
            //			};
            //19-Nov-2015
            //disable the date, for edit mode, date should not be editable
            //cuase running number issue.
            trxdate.Enabled = false;

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

            apara =  DataHelper.GetAdPara (pathToDatabase);
            LoadTrader ();

            List<string> icodes = new List<string> ();
            int counter = 0;
            foreach (Trader item in custs) {
                icodes.Add (item.CustCode+" | "+item.CustName.Trim());
                if (item.CustCode.Trim() == "COD" || item.CustCode.Trim() == "CASH") {
                    CashPos = counter;
                }
                counter += 1;
            }

            dataAdapter = new ArrayAdapter<String> (this, Resource.Layout.spinner_item, icodes);
            dataAdapter2 =ArrayAdapter.CreateFromResource (
                this, Resource.Array.trxtype, Resource.Layout.spinner_item);

            //dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            dataAdapter.SetDropDownViewResource(Resource.Layout.SimpleSpinnerDropDownItemEx);
            dataAdapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            // attaching data adapter to spinner
            spinner.Adapter =dataAdapter;
            spinnerType.Adapter =dataAdapter2;
            LoadData ();
        }
Exemplo n.º 21
0
        void PrintHeader(ref string test,Invoice inv)
        {
            string userid = USERID;
            string[] titles = apara.ReceiptTitle.Split (new char[]{ ',', '|'});
            string title1 = "";
            string title2 = "";

            if (titles.Length ==1)
                title1 = titles [0].ToUpper ();
            if (titles.Length > 1) {
                title1 = titles [0].ToUpper ();
                title2 = titles [1].ToUpper ();
            }
            if (titles.Length == 0 || title1=="")
                title1 = "TAX INVOICE";

            string date = DateTime.Now.ToString ("dd-MM-yyyy");
            string datetime = DateTime.Now.ToString ("dd-MM-yyyy hh:mm tt");
            if (compinfo.ShowTime) {
                test += datetime+title1.PadLeft(41-datetime.Length,' ')+"\n";
            } else {
                test += date+title1.PadLeft(41-date.Length,' ')+"\n";
            }
            //test += DateTime.Now.ToString ("dd-MM-yyyy")+"TAX INVOICE".PadLeft(31,' ')+"\n";
            string recno = "RECPT NO : " + inv.invno.Trim();
            //test += "RECPT NO : " + inv.invno+"\n";
            test += recno+title2.PadLeft(41-recno.Length,' ')+"\n";
            string issueline = "ISSUED BY: " + userid.ToUpper ();
            int templen = 41 - issueline.Length;
            string term = "("+((inv.trxtype.IndexOf("CASH")>-1)?"COD":"TERM")+")";
            issueline = issueline + term.PadLeft (templen, ' ')+"\n";
            test += issueline;// "ISSUED BY: " + userid.ToUpper()+"\n";
            test += "------------------------------------------\n";
            test += "DESCRIPTION                               \n";
            test += "NO       QTY  U/PRICE    TAX AMT    AMOUNT\n";
            test += "------------------------------------------\n";
            /*
            DESCRIPTION       QTY    U/PRICE    AMOUNT
                              TAXGR  TAX AMT
            ------------------------------------------
            xxxxxxxxxxxxxxxxx xxxxx xxxxxxxx xxxxxxxxx
            xxxxxxxxxxxxxxxxx xxxxx xxxxxxxx xxxxxxxxx
            12345678901234567 12345 12345678 123456789
              */
        }
Exemplo n.º 22
0
        public List<string> GetPrintDetalis(Invoice inv,InvoiceDtls[] invdtls)
        {
            List<string> text = new List<string>();
            ttlline = 0;
            _ttltax =0;
            _ttlAmt=0;
            string line = "";
            int itemno = 1;
            byte[] charfont;
            Regex re = new Regex("\r\r$");
            string desc = "";
            IEnumerable<Item> itemcodes = DataHelper.GetItems ();
            string uom = "";
            foreach (InvoiceDtls dtl in invdtls) {
                uom = "";
                var item = from p in itemcodes	where p.ICode == dtl.icode select p;
                if (item.ToList ().Count > 0)
                    uom = item.ToList () [0].StdUom;
                desc = re.Replace(dtl.description, "").ToUpper();
                if (dtl.icode.Length < 15 && desc.Length < 28) {
                    ttlline += 1;
                    line = (itemno.ToString () + ".").PadRight (4, ' ') +
                        dtl.icode.ToUpper ().PadRight (16, ' ') +
                        desc.PadRight (29, ' ') +
                        dtl.price.ToString ("n2").PadLeft (9, ' ') +
                        dtl.qty.ToString ("n0").PadLeft (5, ' ') +
                        uom.PadLeft (6, ' ') +
                        dtl.tax.ToString ("n2").PadLeft (8, ' ') +
                        dtl.taxgrp.PadLeft (7, ' ') +
                        dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r";
                    text.Add(line);
                } else if (dtl.icode.Length > 15 && desc.Length < 28) {
                    ttlline += 2;
                    line = (itemno.ToString () + ".").PadRight (4, ' ') +
                        dtl.icode.Substring(0,15).ToUpper ().PadRight (16, ' ') +
                        desc.PadRight (29, ' ') +
                        dtl.price.ToString ("n2").PadLeft (9, ' ') +
                        dtl.qty.ToString ("n0").PadLeft (5, ' ') +
                        uom.PadLeft (6, ' ') +
                        dtl.tax.ToString ("n2").PadLeft (8, ' ') +
                        dtl.taxgrp.PadLeft (7, ' ') +
                        dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r";
                    text.Add(line);
                    text.Add("".PadRight (4, ' ') +dtl.icode.ToUpper ().Substring (15) + "\r");

                }else if (desc.Length >= 28) {
                    List<string> lines = GetLine (desc,28);
                    ttlline = ttlline + lines.Count;
                    List<string> ICodes = new List<string> ();
                    if (dtl.icode.Length > 15) {
                        ICodes.Add (dtl.icode.ToUpper ().Substring (0, 15));
                        ICodes.Add (dtl.icode.ToUpper ().Substring (15));
                    }else ICodes.Add (dtl.icode.ToUpper ());
                    for (int i = 0; i < lines.Count; i++) {
                        ICodes.Add ("");
                    }

                    line = (itemno.ToString () + ".").PadRight (4, ' ') +
                        ICodes[0].PadRight (16, ' ') +
                        lines[0].PadRight (29, ' ') +
                        dtl.price.ToString ("n2").PadLeft (9, ' ') +
                        dtl.qty.ToString ("n0").PadLeft (5, ' ') +
                        uom.PadLeft (6, ' ') +
                        dtl.tax.ToString ("n2").PadLeft (8, ' ') +
                        dtl.taxgrp.PadLeft (7, ' ') +
                        dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r";
                    text.Add(line);
                    for (int i = 1; i < lines.Count; i++) {
                        line = "".PadRight (4, ' ') +
                            ICodes[i].PadRight (16, ' ') +
                            lines[i].PadRight (29, ' ') +  "\r";
                        text.Add(line);
                    }
                }

                itemno += 1;
                _ttltax = _ttltax + dtl.tax;
                _ttlAmt = _ttlAmt + dtl.netamount;
            }

            return text;
        }
Exemplo n.º 23
0
 //        void ShowPaidment()
 //        {
 //            var dialog = CashDialog.NewInstance();
 //            string[] codes = spinCust.SelectedItem.ToString ().Split (new char[]{ '|' });
 //            if (codes.Length < 2) {
 //                Toast.MakeText (this, Resources.GetString (Resource.String.msg_invalidcust), ToastLength.Long).Show ();
 //                return;
 //            }
 //            dialog.Amount =ttlamt+ttltax;
 //            dialog.CustName = codes [1];
 //            dialog.InvNo = txtInvNo.Text;
 //            dialog.Remark = string.IsNullOrEmpty (inv.remark) ? "" : inv.remark;
 //            dialog.Show(FragmentManager, "dialogPaid");
 //
 //        }
 void CancelReceipt()
 {
     DeleteInv ();
     ttlamt = 0;
     ttltax = 0;
     inv = new Invoice ();
     ClearData ();
     ClearAllData ();
     EnableControLs (false, false, true, false, true);
     RefreshItemList ();
 }
Exemplo n.º 24
0
        public int GetTotalDtlLineCount(Invoice inv,InvoiceDtls[] invdtls)
        {
            int ttlline = 0;
            foreach (InvoiceDtls dtl in invdtls) {
                if (dtl.icode.Length < 15 && dtl.description.Length < 28) {
                    ttlline += 1;
                } else if (dtl.icode.Length > 15 && dtl.description.Length < 28) {
                    ttlline += 2;
                }else if (dtl.description.Length > 28) {
                    List<string> lines = GetLine (dtl.description,29);
                    ttlline = ttlline + lines.Count;
                }
            }

            return ttlline;
        }
Exemplo n.º 25
0
 void LoadInvoice()
 {
     if (INVOICENO == "") {
         if (INVACTION == "create") {
             CreateCashBill ();
         } else {
             EnableControLs (false, false, true, false, true);
             inv = new Invoice ();
         }
     }
     else {
         loadInvouce (INVOICENO);
         if (inv != null) {
             txtInvMode.Text = "EDIT";
             txtInvNo.Text = inv.invno;
             txtInvDate.Text = inv.invdate.ToString ("dd-MM-yyyy");
             txtRemark.Text = inv.remark.ToUpper ();
             if (!string.IsNullOrEmpty (inv.custcode)) {
                 int pos1 = dAdapterCust.GetPosition (inv.custcode + " | " + inv.description.Trim ());
                 if (pos1 > 0)
                     spinCust.SetSelection (pos1);
                 else
                     spinCust.SetSelection (0);
             } else
                 spinCust.SetSelection (0);
             EnableControLs (true, false, true, true, false);
         } else {
             EnableControLs (false, false, true, false, true);
             inv = new Invoice ();
         }
     }
 }
Exemplo n.º 26
0
        public void PrintDetalis(Stream mmOutputStream,Invoice inv,InvoiceDtls[] invdtls)
        {
            ttlline = 0;
            _ttltax =0;
            _ttlAmt=0;
            string line = "";
            int itemno = 1;
            byte[] charfont;
            IEnumerable<Item> itemcodes = DataHelper.GetItems ();
            string uom = "";
            foreach (InvoiceDtls dtl in invdtls) {
                uom = "";
                var item = from p in itemcodes	where p.ICode == dtl.icode select p;
                if (item.ToList ().Count > 0)
                    uom = item.ToList () [0].StdUom;

                if (dtl.icode.Length < 15 && dtl.description.Length < 28) {
                    ttlline += 1;
                    line = (itemno.ToString () + ".").PadRight (4, ' ') +
                            dtl.icode.ToUpper ().PadRight (16, ' ') +
                            dtl.description.ToUpper ().PadRight (29, ' ') +
                            dtl.price.ToString ("n2").PadLeft (9, ' ') +
                            dtl.qty.ToString ("n0").PadLeft (5, ' ') +
                            uom.PadLeft (6, ' ') +
                            dtl.tax.ToString ("n2").PadLeft (8, ' ') +
                            dtl.taxgrp.PadLeft (7, ' ') +
                            dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r";
                    PrintLine (line,mmOutputStream);
                } else if (dtl.icode.Length > 15 && dtl.description.Length < 28) {
                    ttlline += 2;
                    line = (itemno.ToString () + ".").PadRight (4, ' ') +
                            dtl.icode.Substring(0,15).ToUpper ().PadRight (16, ' ') +
                            dtl.description.ToUpper ().PadRight (29, ' ') +
                            dtl.price.ToString ("n2").PadLeft (9, ' ') +
                            dtl.qty.ToString ("n0").PadLeft (5, ' ') +
                            uom.PadLeft (6, ' ') +
                            dtl.tax.ToString ("n2").PadLeft (8, ' ') +
                            dtl.taxgrp.PadLeft (7, ' ') +
                            dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r";
                    PrintLine (line,mmOutputStream);
                    PrintLine (dtl.icode.ToUpper().Substring(15)+"\r",mmOutputStream);
                }else if (dtl.description.Length >= 28) {
                    List<string> lines = GetLine (dtl.description,28);
                    ttlline = ttlline + lines.Count;
                    List<string> ICodes = new List<string> ();
                    if (dtl.icode.Length > 15) {
                        ICodes.Add (dtl.icode.ToUpper ().Substring (0, 15));
                        ICodes.Add (dtl.icode.ToUpper ().Substring (15));
                    }else ICodes.Add (dtl.icode.ToUpper ());
                    for (int i = 0; i < lines.Count; i++) {
                        ICodes.Add ("");
                    }

                    line = (itemno.ToString () + ".").PadRight (4, ' ') +
                        ICodes[0].PadRight (16, ' ') +
                        lines[0].PadRight (29, ' ') +
                        dtl.price.ToString ("n2").PadLeft (9, ' ') +
                        dtl.qty.ToString ("n0").PadLeft (5, ' ') +
                        uom.PadLeft (6, ' ') +
                        dtl.tax.ToString ("n2").PadLeft (8, ' ') +
                        dtl.taxgrp.PadLeft (7, ' ') +
                        dtl.amount.ToString("n2") .PadLeft(10, ' ') + "\r";
                    PrintLine (line,mmOutputStream);
                    for (int i = 1; i < lines.Count; i++) {
                        line = (itemno.ToString () + ".").PadRight (4, ' ') +
                            ICodes[i].PadRight (16, ' ') +
                            lines[i].PadRight (29, ' ') +  "\r";
                        PrintLine (line,mmOutputStream);
                    }

                }

                itemno += 1;
                _ttltax = _ttltax + dtl.tax;
                _ttlAmt = _ttlAmt + dtl.netamount;
            }

            //int remindline = 35 - ttlline;
            //SetLineFeed (mmOutputStream, remindline);
        }
Exemplo n.º 27
0
        private static double GetSumTotal(Invoice[] invs,string trxtype,List<InvoiceDtls> itemlist,Item[] itemCodes,ModelSumm model)
        {
            double total = 0;
            var sum1 = from p in invs
                    where p.trxtype == trxtype
            group p by 1 into g
            select new {
                amt = g.Sum (x => x.amount),
                tax = g.Sum (x => x.taxamt),
                grplist = g.ToList()
            };

            if (sum1.Count() >0)
                total = sum1.FirstOrDefault().amt + sum1.FirstOrDefault().tax;

            List<string> invnosTmp = new List<string>();
            foreach (var grptmp in sum1)
            {
                foreach (var lst in grptmp.grplist){
                    invnosTmp.Add(lst.invno);
                }
            }

            var itemlistCS = from p in itemlist
                    where invnosTmp.Contains(p.invno)
                select p;

            List<TaxSumm> taxsummCS = GetSubTaxSumm(itemCodes, itemlistCS.ToList());
            if (trxtype=="CASH")
                model.CSTaxSumm = taxsummCS;
            else model.InvTaxSumm = taxsummCS;

            return total;
        }
Exemplo n.º 28
0
        private void CreateNewInvoice()
        {
            Invoice inv = new Invoice ();
            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);
            Spinner spinner = FindViewById<Spinner> (Resource.Id.newinv_custcode);
            Spinner spinner2 = FindViewById<Spinner> (Resource.Id.newinv_type);
            TextView txtinvno =FindViewById<TextView> (Resource.Id.newinv_no);
            EditText remark = FindViewById<EditText> (Resource.Id.newinv_remark);
            EditText custname = FindViewById<EditText> (Resource.Id.newinv_custname);
            string[] prefixs = apara.Prefix.Trim ().ToUpper ().Split(new char[]{'|'});
            string prefix = "";
            string trxtype = spinner2.SelectedItem.ToString ();
            //			if (trxtype == "CASH") {
            //				adNum = DataHelper.GetNumDate (pathToDatabase, invdate, "CS");
            //				if (prefixs.Length > 1) {
            //					prefix = prefixs [1];
            //				}else prefix = prefixs [0];
            //			} else {
                adNum = DataHelper.GetNumDate (pathToDatabase, invdate, "INV");
                prefix = prefixs [0];
            //}

            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;

            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {

                string invno = "";
                int runno = adNum.RunNo + 1;
                int currentRunNo =DataHelper.GetLastInvRunNo (pathToDatabase, invdate,spinner2.SelectedItem.ToString ());
                if (currentRunNo >= runno)
                    runno = currentRunNo + 1;

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

                txtinvno.Text= invno;
                inv.invdate = invdate;
                inv.trxtype = "INVOICE";//spinner2.SelectedItem.ToString ();
                inv.created = DateTime.Now;
                inv.invno = invno;
                inv.description = codes [1].Trim ();//custname.Text;
                inv.amount = 0;
                inv.custcode = codes [0].Trim ();
                inv.isUploaded = false;
                inv.remark = remark.Text.ToUpper();
                if (codes [0].Trim () == "COD" || codes [0].Trim () == "CASH") {
                    inv.description = custname.Text.ToUpper ();
                }
                txtinvno.Text = invno;
                db.Insert (inv);
                adNum.RunNo = runno;
                if (adNum.ID >= 0)
                    db.Update (adNum);
                else
                    db.Insert (adNum);
            }

            ShowItemEntry (inv, codes);
        }
Exemplo n.º 29
0
 void DeleteItem(Invoice inv)
 {
     using (var db = new SQLite.SQLiteConnection(pathToDatabase))
     {
         var list = db.Table<Invoice>().Where(x=>x.invno==inv.invno).ToList<Invoice>();
         var list2 = db.Table<InvoiceDtls>().Where(x=>x.invno==inv.invno).ToList<InvoiceDtls>();
         if (list.Count > 0) {
             db.Delete (list [0]);
             db.Delete (list2);
             var arrlist= listData.Where(x=>x.invno==inv.invno).ToList<Invoice>();
             if (arrlist.Count > 0) {
                 listData.Remove (arrlist [0]);
                 SetViewDlg viewdlg = SetViewDelegate;
                 listView.Adapter = new GenericListAdapter<Invoice> (this, listData, Resource.Layout.ListItemRow, viewdlg);
             }
         }
     }
 }
Exemplo n.º 30
0
        void ShowItemEntry(Invoice inv, string[] codes)
        {
            string COMPCODE = ((GlobalvarsApp)this.Application).COMPANY_CODE;
            var intent =ActivityManager.GetActivity<EntryActivityEx>(this.ApplicationContext);
            //var intent = new Intent (this, typeof(EntryActivity));

            intent.PutExtra ("trxtype", inv.trxtype);
            intent.PutExtra ("invoiceno", inv.invno);
            intent.PutExtra ("customer", codes [1].Trim ());
            intent.PutExtra ("custcode",codes [0].Trim ());
            intent.PutExtra ("itemuid", "-1");
            intent.PutExtra ("editmode", "NEW");
            StartActivity (intent);
        }
Exemplo n.º 31
0
 void payment(Invoice inv)
 {
     //			var intent = new Intent (this, typeof(Payment));
     //			double ttl = inv.amount + inv.taxamt;
     //			intent.PutExtra ("amount", ttl.ToString());
     //			StartActivity (intent);
     var dialog = CashDialog.NewInstance();
     dialog.Amount =inv.amount + inv.taxamt;
     dialog.Show(FragmentManager, "dialogPaid");
 }
Exemplo n.º 32
0
 public void SetDocument(object doc)
 {
     inv = (Invoice)doc;
 }
Exemplo n.º 33
0
 void updatePrintedStatus(Invoice inv)
 {
     using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
         var list = db.Table<Invoice> ().Where (x => x.invno == inv.invno).ToList<Invoice> ();
         if (list.Count > 0) {
             //if only contains items then allow to update the printed status.
             //this to allow the invoice;s item can be added. if not can not be posted(upload)
             var list2 = db.Table<InvoiceDtls> ().Where (x => x.invno == inv.invno).ToList<InvoiceDtls> ();
             if (list2.Count > 0) {
                 list [0].isPrinted = true;
                 db.Update (list [0]);
             }
         }
     }
 }
Exemplo n.º 34
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);
		}