public static double getFee(MatterDTO matter, MobileTariffCodeDTO code, int duration) { try { Console.WriteLine ("Calculate Fee - amount: " + code.amount + " duration: " + duration + " units: " + code.units + " surcharge: " + matter.surchargeFactor); } catch (Exception e) { Console.WriteLine ("F****d up ... getting exception " + e.Message); return 0; } double fee = 0; if (duration > 0) { int elapsed = DivRoundUp (duration, (int) code.units); if (code.units > 0) { fee = (code.amount / 60) * code.units * elapsed; } else { fee = (code.amount / 60) * elapsed; } } else { if (code.units > 0) { fee = code.amount * code.units; } else { fee = code.amount; } } if (code.surchargeApplies) { double surcharge = fee * matter.surchargeFactor; fee = surcharge; } return fee; }
void DataDownloaded(IAsyncResult result) { isBusy = false; UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; end = DateTime.Now; var request = result.AsyncState as HttpWebRequest; WebServiceResponseDTO dto; try { HttpWebResponse response = (HttpWebResponse)request.EndGetResponse (result); Stream receiveStream = response.GetResponseStream (); StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8); string resp = readStream.ReadToEnd (); Console.WriteLine ("$$ GetTariffCodes Response stream received.\n" + resp); response.Close (); readStream.Close (); //get JSON response deserialized dto = (WebServiceResponseDTO)JsonConvert.DeserializeObject ( resp, typeof(WebServiceResponseDTO) ); if (dto != null) { Tools.SendElapsedTime (start, end, dto.activityID); } InvokeOnMainThread (delegate { BuildInterface (); selectedTariff = null; if (dto.responseCode == 0) { //insert "none" record on top... MobileTariffCodeDTO d = new MobileTariffCodeDTO (); d.id = 0; d.name = "None"; d.narration = "None"; tariffList = new List<MobileTariffCodeDTO> (); tariffList.Add (d); foreach (var t in dto.mobileTariffCodeList) { tariffList.Add (t); } BuildInterface (); if (tariffList == null || tariffList.Count == 0) { new UIAlertView ( "Activity Code Error", "No Activity codes found for matter", null, "OK" ).Show (); } } else { new UIAlertView ("Activity Code Error", dto.responseMessage, null, "OK").Show (); return; } } ); } catch (Exception ex) { Console.WriteLine ("### ERROR: " + ex.Message); isBusy = false; InvokeOnMainThread (delegate { new UIAlertView ( "Network Error", "Problem communicating with server.\nPlease try later or call GhostPractice Support", null, "Close" ).Show (); } ); } }
private void BuildSections() { var headerLabel = new UILabel (new RectangleF (0, 0, 370, 30)) { Font = UIFont.BoldSystemFontOfSize (18), BackgroundColor = ColorHelper.GetGPPurple (), TextAlignment = UITextAlignment.Center, TextColor = UIColor.White, Text = "Post Note" }; var view = new UIViewBordered (); view.Frame = new RectangleF (0, 0, 370, 30); view.Add (headerLabel); var topSection = new Section (view); Root.Add (topSection); string name = ""; if (matter != null) { name = matter.matterName; headerLabel.Text = name; } //var sec = new Section (name); // addBusySection (); if (tariffList != null && tariffList.Count > 0) { btnTar = new StyledStringElement ("Select Activity Code"); btnTar.TextColor = ColorHelper.GetGPLightPurple (); btnTar.Alignment = UITextAlignment.Center; btnTar.Accessory = UITableViewCellAccessory.DisclosureIndicator; btnTar.Tapped += delegate { if (tariffList == null) { } else { string[] btns = new string[tariffList.Count]; for (int i = 0; i < tariffList.Count; i++) { btns [i] = tariffList [i].name; } actionSheet = new UIActionSheet ("Activity Codes", null, "Cancel", null, btns) { Style = UIActionSheetStyle.Automatic }; actionSheet.Clicked += delegate (object sender, UIButtonEventArgs args) { if (args.ButtonIndex == tariffList.Count) { //ignored - cancelled } else { narration.Value = tariffList [args.ButtonIndex].narration; selectedTariff = tariffList [args.ButtonIndex]; //TODO - think about just updating the affected fields only ... lose the effect? BuildInterface (); } }; actionSheet.ShowInView (View); } }; topSection.Add (btnTar); } // narrationSection = new Section (""); if (selectedTariff == null) { narration = new EntryElement ("Narration", "Narration", null); } else { narrationSection = new Section (selectedTariff.name); narration = new EntryElement ("Narration", "", selectedTariff.narration); } narration.KeyboardType = UIKeyboardType.Default; narrationSection.Add (narration); // picker = new UIDatePicker (); //picker.Frame = new RectangleF (10f, 10f, 320f, 320f); picker.Mode = UIDatePickerMode.Date; picker.Date = DateTime.Now; var pickerSection = new Section (picker); //Root.Add (sec); Root.Add (narrationSection); Root.Add (pickerSection); BuildButtons (); }