protected override void OnCreate(Bundle bundle) { var class1 = ClassItem.Instance; base.OnCreate(bundle); SetContentView(Resource.Layout.AddOrEditCost); var normalCost = FindViewById <EditText>(Resource.Id.normalCost); var withDiscount = FindViewById <EditText>(Resource.Id.withDiscount); normalCost.FocusChange += (object sender, View.FocusChangeEventArgs e) => { var currentSender = sender as EditText; if (e.HasFocus && currentSender != null) { currentSender.Text = string.Empty; } }; withDiscount.FocusChange += (object sender, View.FocusChangeEventArgs e) => { var currentSender = sender as EditText; if (e.HasFocus && currentSender != null) { currentSender.Text = string.Empty; } }; var onDateChangedListener = new OnDateChangedListener(); onDateChangedListener.DateChanged += (object sender, DateChangedEventArgs e) => { var cost = class1.GetCost(e.DateTime).Value; normalCost.Text = cost.Normal.ToString(); withDiscount.Text = cost.WithDiscount.ToString(); }; var datePicker = FindViewById <DatePicker>(Resource.Id.datePicker1); datePicker.Init(DateTime.Now.Year, DateTime.Now.Month - 1, DateTime.Now.Day, onDateChangedListener); Button oK = FindViewById <Button> (Resource.Id.oK); oK.Click += delegate { decimal tempNormalCost; decimal tempWithDiscount; if (decimal.TryParse(normalCost.Text, out tempNormalCost) && decimal.TryParse(withDiscount.Text, out tempWithDiscount)) { class1.AddOrEditCost(datePicker.DateTime, new Cost { Normal = tempNormalCost, WithDiscount = tempWithDiscount }); } Finish(); }; Button cancel = FindViewById <Button> (Resource.Id.cancel); cancel.Click += delegate { Finish(); }; var tmpCost = class1.GetCost(DateTime.Today).Value; normalCost.Text = tmpCost.Normal.ToString(); withDiscount.Text = tmpCost.WithDiscount.ToString(); }
protected override void OnCreate(Bundle bundle) { var class1 = ClassItem.Instance; base.OnCreate(bundle); SetContentView(Resource.Layout.Pay); var menu = FindViewById <Spinner>(Resource.Id.menu); menu.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(menu_ItemSelected); var pupilList = class1.GetPupilList(DateTime.Today); var pupilArray = new List <string>(); foreach (var item in pupilList) { pupilArray.Add(string.Format("{0} | {1} | {2}", item.Key.LastName, item.Key.FirstName, item.Key.IsDiscount ? "л" : "")); } var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, pupilArray.ToArray()); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); menu.Adapter = adapter; var amount = FindViewById <EditText>(Resource.Id.amount); amount.FocusChange += (object sender, View.FocusChangeEventArgs e) => { var currentSender = sender as EditText; if (e.HasFocus && currentSender != null && currentSender.Text == "0") { currentSender.Text = string.Empty; } }; var onDateChangedListener = new OnDateChangedListener(); onDateChangedListener.DateChanged += (object sender, DateChangedEventArgs e) => { _dateTime = e.DateTime; if (this._currentPupil != null && this._dateTime != null) { amount.Text = class1.GetAmount(this._dateTime, this._currentPupil).ToString(); } }; var datePicker = FindViewById <DatePicker>(Resource.Id.datePicker1); datePicker.Init(DateTime.Now.Year, DateTime.Now.Month - 1, DateTime.Now.Day, onDateChangedListener); this._dateTime = DateTime.Today; Button oK = FindViewById <Button> (Resource.Id.oK); oK.Click += delegate { decimal tempAmount; if (this._currentPupil != null && this._dateTime != null && decimal.TryParse(amount.Text, out tempAmount)) { class1.Pay(this._dateTime, this._currentPupil, tempAmount); } }; Button cancel = FindViewById <Button> (Resource.Id.cancel); cancel.Click += delegate { Finish(); }; }