예제 #1
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;

		}
예제 #2
0
 void findBTPrinter()
 {
     string printername = apara.PrinterName.Trim ().ToUpper ();
     Utility util = new Utility ();
     string msg = "";
     mmDevice = util.FindBTPrinter (printername,ref  msg);
     Toast.MakeText (this, msg, ToastLength.Long).Show ();
 }
예제 #3
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);
		}