public CreditNoteViewModel() { try { MessageBoxCaption = "Credit Note"; TaxInvoice = false; nepDate = new DateConverter(GlobalClass.TConnectionString); PIN = new ParkingIn(); POUT = new ParkingOut(); CurDate = DateTime.Today; CurTime = DateTime.Now.ToString("hh:mm tt"); timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += timer_Tick; timer.Start(); NewCommand = new RelayCommand(ExeucteNew); LoadData = new RelayCommand(ExecuteLoad); SaveCommand = new RelayCommand(ExecuteSave, CanExecuteSave); UndoCommand = new RelayCommand(ExecuteUndo); PrintCommand = new RelayCommand(ExecutePrint, CanExecutePrint); SetAction(ButtonAction.Init); this.PropertyChanged += CreditNoteViewModel_PropertyChanged; } catch (Exception ex) { MessageBox.Show(GlobalClass.GetRootException(ex).Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }
public POutWithoutSlipVM() { try { MessageBoxCaption = "Exit Without Slip"; TaxInvoice = false; CanChangeInvoiceType = true; nepDate = new DateConverter(GlobalClass.TConnectionString); PIN = new ParkingIn(); InDate = DateTime.Today.Date; InTime = DateTime.Now; POUT = new ParkingOut(); CurDate = DateTime.Today; CurTime = DateTime.Now.ToString("hh:mm tt"); timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += timer_Tick; timer.Start(); LoadData = new RelayCommand(ExecuteLoad); NewCommand = new RelayCommand(ExecuteNew); SaveCommand = new RelayCommand(ExecuteSave, CanExecuteSave); UndoCommand = new RelayCommand(ExecuteUndo); PrintCommand = new RelayCommand(ExecutePrint, CanExecutePrint); SetAction(ButtonAction.Init); using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { VTypeList = new ObservableCollection <VehicleType>(conn.Query <VehicleType>("SELECT VTypeID, Description FROM VehicleType")); } } catch (Exception ex) { MessageBox.Show(GlobalClass.GetRootException(ex).Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }
public ParkingInViewModel(Dispatcher _D) { MessageBoxCaption = "Entrance"; d = _D; nepDate = new DateConverter(GlobalClass.TConnectionString); Parking = new ParkingIn(); SelectedParkingIn = new ParkingIn(); Vehicle = new VehicleType(); timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += timer_Tick; timer.Start(); try { using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { string strSql = "SELECT VTypeID, [Description],(SELECT SUM(Capacity) FROM PARKINGAREA WHERE VehicleType = VTypeID) Capacity, [UID], ButtonImage from VehicleType"; VTypeList = new ObservableCollection <VehicleType>(conn.Query <VehicleType>(strSql)); foreach (VehicleType vtype in VTypeList) { if (vtype.ButtonImage == null) { continue; } vtype.ImageSource = Imaging.BinaryToImage(vtype.ButtonImage); } PAOccupencyList = new ObservableCollection <ParkingArea>(conn.Query <ParkingArea>("SELECT PA_ID, PA_NAME, Capacity, VehicleType, MinVacantLot From ParkingArea")); foreach (ParkingArea pa in PAOccupencyList) { var VType = VTypeList.First(x => x.VTypeID == pa.VehicleType); pa.VType = VType; VType.PAOccupencyList.Add(pa); } } NewCommand = new RelayCommand(ExecuteNew); SaveCommand = new RelayCommand(ExecuteSave); UndoCommand = new RelayCommand(ExecuteUndo); RefreshDependencyCommand = new RelayCommand(RefreshDependency); PrintCommand = new RelayCommand(ExecutePrint); SetAction(ButtonAction.Init); SqlDependency.Start(GlobalClass.DataConnectionString); DoDependency(); } catch (Exception ex) { // var abc = new System.Windows.Media.Geometry(); MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }
public FunctionResponse ValidateStaffOrStamp(BarCodeTransfer barCodeTransfer) { ParkingOut POUT = barCodeTransfer.POUT; ParkingIn PIN = barCodeTransfer.PIN; try { using (SqlConnection conn = new SqlConnection(GlobalClass.DataConnectionString)) { if (POUT.STAFF_BARCODE != "STAMP") { POUT.STAFF_BARCODE = conn.ExecuteScalar <string>("SELECT BARCODE FROM tblStaff WHERE STATUS = 0 AND BCODE = '" + POUT.STAFF_BARCODE + "'"); if (string.IsNullOrEmpty(POUT.STAFF_BARCODE)) { return(new FunctionResponse() { status = "error", Message = "Invalid Barcode. Please Try Again." }); } if (GlobalClass.AllowMultiVehicleForStaff == 0) { if (conn.ExecuteScalar <int> ( string.Format ( @"SELECT COUNT(*) FROM ( SELECT INDATE + CAST(INTIME AS TIME) INTIME, OUTDATE + CAST(OUTTIME AS TIME) OUTTIME FROM ParkingInDetails PID JOIN ParkingOutDetails POD ON PID.PID =POD.PID AND PID.FYID = POD.FYID WHERE POD.STAFF_BARCODE = '{0}' ) A WHERE (INTIME < '{1}' AND OUTTIME > '{1}') OR (INTIME > '{1}' AND OUTTIME > '{1}')", POUT.STAFF_BARCODE, PIN.InDate.Add(DateTime.Parse(PIN.InTime).TimeOfDay) ) ) > 0) { return(new FunctionResponse() { status = "error", Message = "Staff already parked one vehicle during current vehile's parked period. Staff are not allowed to park multiple vehicle at a time" }); } } } } POUT.CashAmount = 0; return(ExecuteSave(barCodeTransfer)); //if (StaffBarcode != null) // StaffBarcode.Close(); } catch (Exception ex) { POUT.STAFF_BARCODE = null; return(new FunctionResponse() { status = "error", Message = ex.Message }); } }
private void ExecuteUndo(object obj) { InvoiceNo = string.Empty; RefBillNo = string.Empty; Remarks = string.Empty; TaxInvoice = false; PIN = new ParkingIn(); POUT = new ParkingOut(); SetAction(ButtonAction.Init); OnPropertyChanged("IsEntryMode"); }
void CreditNoteViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (_action == ButtonAction.New) { if (e.PropertyName == "RefBillNo" || e.PropertyName == "TaxInvoice") { PIN = new ParkingIn(); POUT = new ParkingOut(); } } }
public async void ExecuteFinishCommand() { try { if (PIN == null || POUT == null) { DependencyService.Get <IMessage>().ShortAlert("No Vehicle to exit"); return; } if (POUT.PID == 0 || PIN.PID == 0) { DependencyService.Get <IMessage>().ShortAlert("No vehicle entered to exit."); return; } var ans = await App.Current.MainPage.DisplayAlert("Confirm", "Are you sure to Exit Vehicle?", "Yes", "No"); if (!ans) { return; } IsLoading = true; var transferData = new BarCodeTransfer() { barcode = Barcode, Vouchers = Vouchers, mDiscount = mDiscount, PIN = PIN, POUT = POUT, Session = GlobalClass.User.Session }; var res = await ParkingDetailsConnection.SavePOUT(transferData); if (res.status == "ok") { DependencyService.Get <IMessage>().ShortAlert("Vehicle exited Successfully"); POUT = new ParkingOut(); PIN = new ParkingIn(); Vouchers = new List <Voucher>(); mDiscount = new MemberDiscount(); } else if (res.status == "error") { DependencyService.Get <IMessage>().ShortAlert(res.Message); } else { DependencyService.Get <IMessage>().ShortAlert("Error: Server Connection Problem"); } IsLoading = false; } catch (Exception ex) { IsLoading = false; DependencyService.Get <IMessage>().ShortAlert(ex.Message); } }
private void ExecuteUndo(object obj) { FocusedElement = (short)Focusable.Barcode; TaxInvoice = false; InvoiceNo = string.Empty; CanChangeInvoiceType = true; PIN = new ParkingIn(); InDate = DateTime.Today.Date; InTime = DateTime.Now; POUT = new ParkingOut(); SetAction(ButtonAction.Init); OnPropertyChanged("IsEntryMode"); PoleDisplay.WriteToDisplay(POUT.ChargedAmount, PoleDisplayType.AMOUNT); }
private void Initialize() { this.webcamImage = webcam; this.camera = new Webcam(this); this.restApi = new RESTAPI(); this.parkingIn = new ParkingIn(); autoComplete = new AutoCompleteStringCollection(); this.ip_address_server = Properties.Settings.Default.IPAddressServer; StartLiveCamera(); this.MifareCard = new MifareCard(this); this.MifareCard.RunMain(); InitDataVehicleType(); }
public HomePageVM() { Test = "Test"; IsLoading = false; LoadingMessage = "Loading!! Please wait....."; Barcode = ""; LoadCommand = new Command(ExecuteLoad); FinishCommand = new Command(ExecuteFinishCommand); StampCommand = new Command(ExecuteStampCommand); StaffCommand = new Command(ExecuteStaffCommand); BackCommand = new Command(ExecuteBackCommand); ViewStaffBarcode = new Command(ExecuteViewStaffBarcode); PIN = new ParkingIn(); POUT = new ParkingOut(); ParkingDetails = new BarCodeTransfer(); Vouchers = new List <Voucher>(); mDiscount = new MemberDiscount(); StaffBarcode = ""; }
private void Initialize() { this.webcamImage = webcam; if (Properties.Settings.Default.WebcamEnabled) { this.camera = new Webcam(this); } this.restApi = new RESTAPI(); this.database = new DBConnect(); this.parkingIn = new ParkingIn(); autoComplete = new AutoCompleteStringCollection(); nonCash.Checked = true; ip_address_server = Properties.Settings.Default.IPAddressServer; StartLiveCamera(); this.bni = new BNI(); this.mifareCard = new MifareCard(this); this.mifareCard.RunMain(); // initialize vehicle type options try { comboBox1.Items.Add("- Pilih Tipe Kendaraan -"); string masterDataFile = TKHelper.GetApplicationExecutableDirectoryName() + Constant.PATH_FILE_MASTER_DATA_PARKING_OUT; using (StreamReader reader = new StreamReader(masterDataFile)) { string json = reader.ReadToEnd(); dynamic vehicleTypes = JsonConvert.DeserializeObject(json); foreach (var types in vehicleTypes["VehicleTypes"]) { comboBox1.Items.Add(types); } comboBox1.SelectedIndex = 0; } } catch (Exception ex) { Console.WriteLine(ex.Message); notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_FETCH_VEHICLE_TYPE_DATA, ToolTipIcon.Error); } }
public async void ExecuteStaffCommand() { try { //IsStaffBarcode = false; if (string.IsNullOrEmpty(StaffBarcode)) { DependencyService.Get <IMessage>().ShortAlert("Invalid Barcode. Please Try Again"); return; } POUT.SESSION_ID = GlobalClass.User.Session; POUT.STAFF_BARCODE = StaffBarcode; var transferData = new BarCodeTransfer() { barcode = Barcode, Vouchers = Vouchers, mDiscount = mDiscount, PIN = PIN, POUT = POUT, Session = GlobalClass.User.Session }; var res = await ParkingDetailsConnection.SaveStaffOrStampPOUT(transferData); if (res.status == "ok") { IsStaffBarcode = false; DependencyService.Get <IMessage>().ShortAlert("Vehicle exited Successfully"); POUT = new ParkingOut(); PIN = new ParkingIn(); Vouchers = new List <Voucher>(); mDiscount = new MemberDiscount(); } else if (res.status == "error") { DependencyService.Get <IMessage>().ShortAlert(res.Message); } } catch (Exception ex) { DependencyService.Get <IMessage>().ShortAlert(ex.Message); } }
private void ExecuteNew(object obj) { SetAction(ButtonAction.New); Parking = new ParkingIn(); }
private void ExecuteUndo(object obj) { SetAction(ButtonAction.Init); Parking = new ParkingIn(); }
public FunctionResponse CheckParkingSlip(BarCodeTransfer transferData) { try { string barcode = transferData.barcode; ParkingOut POUT = new ParkingOut(); decimal ChargedHours = 0; decimal ChargedAmount = 0; using (SqlConnection conn = new SqlConnection(ConnectionDbInfo.ConnectionString)) { try { if (transferData.POUT != null && (transferData.POUT.PID) != 0) { transferData.POUT.SaveLog(conn); } } catch { } var PINS = conn.Query <ParkingIn>(@"SELECT PID, VehicleType, InDate, InMiti, InTime, PlateNo, Barcode, UID FROM ParkingInDetails WHERE((BARCODE <> '' AND BARCODE = @barcode) OR(ISNULL(PLATENO, '') <> '' AND ISNULL(PlateNo, '') = @barcode)) AND FYID = @fyid", new { barcode, fyid = GlobalClass.FYID }); if (PINS.Count() <= 0) { return(new FunctionResponse() { status = "error", Message = "Invalid barcode readings." }); } ParkingIn PIN = PINS.First(); PIN.VType = conn.Query <VehicleType>(string.Format("SELECT VTypeId, Description FROM VehicleType WHERE VTypeId = {0}", PIN.VehicleType)).First(); var POUTS = conn.Query <ParkingOut>(string.Format("SELECT * FROM ParkingOutDetails WHERE PID = {0} AND FYID = {1}", PIN.PID, GlobalClass.FYID)); if (POUTS.Count() > 0) { return(new FunctionResponse() { status = "error", Message = "Entity already exited" }); } POUT.Rate_ID = (int)conn.ExecuteScalar("SELECT RATE_ID FROM RATEMASTER WHERE IsDefault = 1"); DateTime ServerTime = conn.ExecuteScalar <DateTime>("SELECT GETDATE()"); POUT.OutDate = ServerTime.Date; POUT.OutTime = ServerTime.ToString("hh:mm:ss tt"); POUT.OutMiti = conn.ExecuteScalar <String>("SELECT MITI FROM DATEMITI WHERE AD = @AD", new { AD = ServerTime.Date }); POUT.Interval = GetInterval(PIN.InDate, POUT.OutDate, PIN.InTime, POUT.OutTime); POUT.PID = PIN.PID; CalculateParkingCharge(conn, PIN.InDate.Add(DateTime.Parse(PIN.InTime).TimeOfDay), POUT.OutDate.Add(DateTime.Parse(POUT.OutTime).TimeOfDay), POUT.Rate_ID, PIN.VehicleType, ref ChargedAmount, ref ChargedHours); POUT.ChargedHours = ChargedHours; POUT.ChargedAmount = ChargedAmount; POUT.CashAmount = POUT.ChargedAmount; PIN.Barcode = string.Empty; bool IsHoliday = conn.ExecuteScalar <int>("SELECT COUNT(*) FROM Holiday WHERE HolidayDate = @HolidayDate", new { HolidayDate = POUT.OutDate }) > 0; return(new FunctionResponse() { status = "ok", result = new BarCodeTransfer() { barcode = barcode, Vouchers = new List <Voucher>(), mDiscount = new MemberDiscount(), POUT = POUT, PIN = PIN, IsHoliday = IsHoliday } }); } } catch (Exception ex) { return(new FunctionResponse() { status = "error", Message = ex.Message }); } }
List <dynamic> GetTimeSpentInEachSession(TimeSpan InTime, TimeSpan OutTime, MembershipScheme scheme, ParkingIn PIN) { DateTime Start = PIN.InDate; DateTime End = PIN.InDate; TimeSpan Minute = new TimeSpan(0, 1, 0); List <dynamic> TimeSpentInEachSession = new List <dynamic>(); foreach (var session in scheme.ValidHoursList) { TimeSpan TimeSpent = new TimeSpan(0, 0, 0); if (InTime >= session.Start && InTime <= session.End) { if (OutTime <= session.End.Add(Minute)) { TimeSpent = OutTime.Subtract(InTime); End = PIN.InDate.Add(OutTime); } else { TimeSpent = session.End.Add(Minute).Subtract(InTime); End = PIN.InDate.Add(session.End.Add(Minute)); } Start = PIN.InDate.Add(InTime); } else if (InTime < session.Start) { if (OutTime <= session.End.Add(Minute)) { TimeSpent = OutTime.Subtract(session.Start); End = PIN.InDate.Add(OutTime); } else { TimeSpent = session.End.Add(Minute).Subtract(session.Start); End = PIN.InDate.Add(session.End.Add(Minute)); } Start = PIN.InDate.Add(session.Start); } TimeSpentInEachSession.Add(new { session.SkipValidityPeriod, session.IgnoreLimit, TimeSpent = Convert.ToInt32(TimeSpent.TotalMinutes), Start, End }); } return(TimeSpentInEachSession); }
public FunctionResponse ValidateMember(BarCodeTransfer obj) { try { string barcode = obj.barcode; List <Voucher> Vouchers = obj.Vouchers; MemberDiscount mDiscount = obj.mDiscount; ParkingIn PIN = obj.PIN; ParkingOut POUT = obj.POUT; if (mDiscount != null && !string.IsNullOrEmpty(mDiscount.MemberId)) { return new FunctionResponse() { status = "error", Message = "Member already accepted." } } ; TimeSpan InTime = DateTime.Parse(PIN.InTime).TimeOfDay; TimeSpan OutTime = DateTime.Parse(POUT.OutTime).TimeOfDay; decimal DiscountAmount = 0; decimal DiscountHour = 0; int Interval; using (SqlConnection conn = new SqlConnection(GlobalClass.DataConnectionString)) { Member m = conn.Query <Member>("SELECT MemberId, MemberName, SchemeId, ExpiryDate, ActivationDate, Barcode, Address FROM Members WHERE Barcode = @MemberId ", new { MemberId = barcode.ToString() }).FirstOrDefault(); if (m == null) { return(new FunctionResponse() { status = "error", Message = "The member does not exists." }); } else if (m.ActivationDate > POUT.OutDate || m.ExpiryDate < POUT.OutDate) { return(new FunctionResponse() { status = "error", Message = "The membership is expired or not yet activated." }); } MembershipScheme scheme = conn.Query <MembershipScheme>("SELECT * FROM MembershipScheme WHERE SchemeId = @SchemeId", m).FirstOrDefault(); if (scheme == null) { return(new FunctionResponse() { status = "error", Message = "Membership scheme does not exists." }); } else if (!scheme.ValidOnWeekends && POUT.OutDate.DayOfWeek == DayOfWeek.Saturday) { return(new FunctionResponse() { status = "error", Message = "The Membership is not valid on Weekends" }); } else if (!scheme.ValidOnHolidays && conn.ExecuteScalar <int>("SELECT COUNT(*) FROM Holiday WHERE HolidayDate = @HolidayDate", new { HolidayDate = POUT.OutDate }) > 0) { return(new FunctionResponse() { status = "error", Message = "The Membership is not valid on Public Holidays" }); } List <dynamic> TimeSpentInEachSession = GetTimeSpentInEachSession(InTime, OutTime, scheme, PIN); Interval = conn.ExecuteScalar <int>("SELECT ISNULL(SUM(MDD.Interval - MDD.SkipInterval),0) Interval FROM MemberDiscountDetail MDD JOIN ParkingOutDetails POD ON MDD.PID = POD.PID WHERE MemberId = @MemberId AND POD.OutDate = @OutDate", new { MemberId = m.MemberId, OutDate = POUT.OutDate }); if (Interval >= scheme.Limit && !TimeSpentInEachSession.Any(x => x.SkipValidityPeriod && x.TimeSpent > 0)) { return(new FunctionResponse() { status = "error", Message = "Free Entrance for the Member has exceeded for day." }); } mDiscount = new MemberDiscount { MemberId = m.MemberId, SchemeId = m.SchemeId, FYID = POUT.FYID, PID = PIN.PID, }; POUT.BILLTO = m.MemberName; POUT.BILLTOADD = m.Address; if (TimeSpentInEachSession.Any(x => x.SkipValidityPeriod)) { mDiscount.SkipInterval = TimeSpentInEachSession.Where(x => x.SkipValidityPeriod).Sum(x => x.TimeSpent); } int DiscountInterval = scheme.Limit - Interval + mDiscount.SkipInterval; foreach (dynamic session in TimeSpentInEachSession.Where(x => x.TimeSpent > 0)) { if (session.IgnoreLimit) { CalculateParkingCharge(conn, session.Start, session.End, POUT.Rate_ID, PIN.VehicleType, ref DiscountAmount, ref DiscountHour); DiscountInterval -= session.TimeSpent; } else { CalculateParkingCharge(conn, session.Start, (DiscountInterval < session.TimeSpent) ? session.Start.AddMinutes(DiscountInterval) : session.End, POUT.Rate_ID, PIN.VehicleType, ref DiscountAmount, ref DiscountHour); DiscountInterval -= (DiscountInterval < session.TimeSpent) ? DiscountInterval : session.TimeSpent; } mDiscount.Interval += DiscountHour * 60; mDiscount.DiscountAmount += DiscountAmount * scheme.Discount / 100; DiscountHour = 0; DiscountAmount = 0; } POUT.CashAmount = POUT.ChargedAmount = POUT.ChargedAmount - mDiscount.DiscountAmount; obj.mDiscount = mDiscount; return(new FunctionResponse() { status = "ok", result = obj }); } //if (POUT.CashAmount == 0) // ExecuteSave(null); //PoleDisplay.WriteToDisplay(POUT.CashAmount, PoleDisplayType.AMOUNT); }catch (Exception ex) { return(new FunctionResponse() { status = "error", Message = ex.Message }); } }
public FunctionResponse ValidateVoucher(BarCodeTransfer obj) { try { string barcode = obj.barcode; List <Voucher> Vouchers = obj.Vouchers; MemberDiscount mDiscount = obj.mDiscount; ParkingIn PIN = obj.PIN; ParkingOut POUT = obj.POUT; if (Vouchers.Any(x => x.Barcode.ToUpper() == barcode.ToUpper().ToString())) { return new FunctionResponse() { status = "error", Message = "Voucher already accepted." } } ; using (SqlConnection conn = new SqlConnection(GlobalClass.DataConnectionString)) { Voucher v = conn.Query <Voucher>("SELECT VoucherNo, Barcode, VoucherId, Value, ExpDate, ValidStart, ValidEnd, ScannedTime FROM ParkingVouchers WHERE Barcode = @Barcode", new { Barcode = barcode.ToString() }).FirstOrDefault(); if (v == null) { return(new FunctionResponse() { status = "error", Message = "InValid Voucher" }); } else if (v.ScannedTime == null) { return(new FunctionResponse() { status = "error", Message = "Voucher already redeemed." }); } else if (!VoucherTypes.Any(x => x.VoucherId == v.VoucherId && x.VehicleType == PIN.VehicleType)) { return(new FunctionResponse() { status = "error", Message = "The Voucher is not valid for current Entrance Type." }); } else if (v.ExpDate < CurDate) { return(new FunctionResponse() { status = "error", Message = "Voucher has expired." }); } else { TimeSpan outTime = Convert.ToDateTime(POUT.OutTime).TimeOfDay; if (v.ValidStart < v.ValidEnd) { if (outTime < v.ValidStart || outTime > v.ValidEnd) { return(new FunctionResponse() { status = "error", Message = "Voucher is not valid for current Shift." }); } } else { if (outTime < v.ValidStart && outTime > v.ValidEnd) { return(new FunctionResponse() { status = "error", Message = "Voucher is not valid for current Shift." }); } } v.Value = (POUT.ChargedAmount > v.Value) ? v.Value : POUT.ChargedAmount; POUT.CashAmount = POUT.CashAmount - v.Value; //PIN.Barcode = string.Empty; Vouchers.Add(v); return(new FunctionResponse() { status = "ok", result = obj }); //if (POUT.CashAmount == 0) // ExecuteSave(null); //PoleDisplay.WriteToDisplay(POUT.CashAmount, PoleDisplayType.AMOUNT); } } }catch (Exception ex) { return(new FunctionResponse() { status = "error", Message = ex.Message }); } }
private void vehicleType_SelectionChangeCommitted(object sender, EventArgs e) { if (vehicleType.SelectedIndex != 0) { // send data API var APIUrl = Properties.Resources.RequestDataParkingFreePassAPIURL; string barcodeData = barcode.Text.ToString(); string uidType = TKHelper.GetUidType(barcodeData); FreePassRequest freePassRequest = new FreePassRequest(uidType, barcodeData); var sent_param = JsonConvert.SerializeObject(freePassRequest); DataResponseObject response = (DataResponseObject)restApi.post(ip_address_server, APIUrl, true, sent_param); if (response != null) { switch (response.Status) { case 206: parkingIn = JsonConvert.DeserializeObject <ParkingIn>(response.Data.ToString()); txtGrandTotal.Text = TKHelper.IDR(parkingIn.Fare.ToString()); string[] datetimeIn = parkingIn.DatetimeIn.Split(' '); timeIn.Text = TKHelper.ConvertDatetime(datetimeIn[0], datetimeIn[1]); string[] datetimeOut = parkingIn.DatetimeOut.Split(' '); timeOut.Text = TKHelper.ConvertDatetime(datetimeOut[0], datetimeOut[1]); // Load Picture of face and plate number string faceImage = parkingIn.FaceImage; if (string.IsNullOrEmpty(faceImage)) { PictFace.Image = Properties.Resources.no_image; } else { try { string URL_pict_face = Constant.URL_PROTOCOL + Properties.Settings.Default.IPAddressServer + Properties.Resources.repo + "/" + faceImage; PictFace.Load(URL_pict_face); } catch (Exception) { PictFace.Image = Properties.Resources.no_image; } } PictFace.BackgroundImageLayout = ImageLayout.Stretch; PictFace.SizeMode = PictureBoxSizeMode.StretchImage; string plateNumberImage = parkingIn.PlateNumberImage; if (string.IsNullOrEmpty(plateNumberImage)) { PictVehicle.Image = Properties.Resources.no_image; } else { try { string URL_pict_vehicle = Constant.URL_PROTOCOL + Properties.Settings.Default.IPAddressServer + Properties.Resources.repo + "/" + parkingIn.PlateNumberImage; PictVehicle.Load(URL_pict_vehicle); } catch (Exception) { PictVehicle.Image = Properties.Resources.no_image; } } PictVehicle.BackgroundImageLayout = ImageLayout.Stretch; PictVehicle.SizeMode = PictureBoxSizeMode.StretchImage; break; default: notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", response.Message, ToolTipIcon.Error); Clear(); break; } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error); } } }
public async void ExecuteLoad() { try { if (string.IsNullOrEmpty(Barcode)) { DependencyService.Get <IMessage>().ShortAlert("Enter Correct barcode "); return; } IsLoading = true; var res = new FunctionResponse(); if (Barcode.ToString().StartsWith("#")) { if (POUT.PID == 0) { DependencyService.Get <IMessage>().ShortAlert("Voucher cannot be accepted. No Vehicle barcode scanned."); IsLoading = false; return; } if (Vouchers.Any(x => x.Barcode.ToUpper() == Barcode.ToUpper().ToString())) { DependencyService.Get <IMessage>().ShortAlert("Voucher already Accepted."); IsLoading = false; return; } var transferData = new BarCodeTransfer() { barcode = Barcode.ToUpper(), Vouchers = Vouchers, mDiscount = mDiscount, PIN = PIN, POUT = POUT }; res = await ParkingDetailsConnection.UploadVoucherCode(transferData); if (res.status == "ok") { DependencyService.Get <IMessage>().ShortAlert("Voucher Discount applied Successfully"); } } else if (Barcode.ToUpper().ToString().StartsWith(GlobalClass.MemberBarcodePrefix)) { if (POUT.PID == 0) { DependencyService.Get <IMessage>().LongAlert("MemberCard cannot be accepted. No Vehicle barcode scanned."); IsLoading = false; return; } if (mDiscount != null && !string.IsNullOrEmpty(mDiscount.MemberId)) { DependencyService.Get <IMessage>().ShortAlert("Member already Accepted."); IsLoading = false; return; } var transferData = new BarCodeTransfer() { barcode = Barcode.ToUpper(), Vouchers = Vouchers, mDiscount = mDiscount, PIN = PIN, POUT = POUT }; res = await ParkingDetailsConnection.UploadMemberCode(transferData); if (res.status == "ok") { DependencyService.Get <IMessage>().ShortAlert("Member Discount applied successfully"); } } else { var transferData = new BarCodeTransfer() { barcode = Barcode.ToUpper(), PIN = PIN, POUT = POUT }; res = await ParkingDetailsConnection.LoadParkingOutAsync(transferData); if (res.status == "error") { PIN = new ParkingIn(); POUT = new ParkingOut(); Vouchers = new List <Voucher>(); mDiscount = new MemberDiscount(); } if (res.status == "ok") { DependencyService.Get <IMessage>().ShortAlert("Details Loaded Successfully"); } } if (res.status == "ok") { ParkingDetails = JsonConvert.DeserializeObject <BarCodeTransfer>(res.result.ToString()); if (ParkingDetails != null) { PIN = ParkingDetails.PIN; POUT = ParkingDetails.POUT; POUT.UID = GlobalClass.User.UID; POUT.SESSION_ID = GlobalClass.User.Session; Vouchers = ParkingDetails.Vouchers; mDiscount = ParkingDetails.mDiscount; Barcode = ""; } } else { DependencyService.Get <IMessage>().ShortAlert(res.Message); } IsLoading = false; }catch (Exception ex) { IsLoading = false; DependencyService.Get <IMessage>().ShortAlert(ex.Message); } }
private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { if (comboBox1.SelectedIndex != 0) { if (textBox1.Text != "" && textBox1.Text != "Barcode/UID Kartu") { // send data API var APIUrl = Properties.Resources.RequestUIDFareAPIURL; string uidType = TKHelper.GetUidType(UIDCard); string vehicle = comboBox1.Text.ToString(); RequestFareRequest requestFare = new RequestFareRequest(uidType, UIDCard, vehicle); var sent_param = JsonConvert.SerializeObject(requestFare); DataResponseObject response = (DataResponseObject)restApi.post(ip_address_server, APIUrl, true, sent_param); if (response != null) { switch (response.Status) { case 206: parkingIn = JsonConvert.DeserializeObject <ParkingIn>(response.Data.ToString()); txtHour.Text = TKHelper.GetValueTime(parkingIn.ParkDuration, "hour"); txtMinute.Text = TKHelper.GetValueTime(parkingIn.ParkDuration, "minute"); txtSecond.Text = TKHelper.GetValueTime(parkingIn.ParkDuration, "second"); txtGrandTotal.Text = TKHelper.IDR(parkingIn.Fare.ToString()); string[] datetimeIn = parkingIn.DatetimeIn.Split(' '); textBox3.Text = TKHelper.ConvertDatetime(datetimeIn[0], datetimeIn[1]); string[] datetimeOut = parkingIn.DatetimeOut.Split(' '); textBox4.Text = TKHelper.ConvertDatetime(datetimeOut[0], datetimeOut[1]); // Load Picture of face and plate number string faceImage = parkingIn.FaceImage; if (string.IsNullOrEmpty(faceImage)) { PictFace.Image = Properties.Resources.no_image; } else { try { string URL_pict_face = Constant.URL_PROTOCOL + Properties.Settings.Default.IPAddressServer + Properties.Resources.repo + "/" + faceImage; PictFace.Load(URL_pict_face); } catch (Exception) { PictFace.Image = Properties.Resources.no_image; } } PictFace.BackgroundImageLayout = ImageLayout.Stretch; PictFace.SizeMode = PictureBoxSizeMode.StretchImage; string plateNumberImage = parkingIn.PlateNumberImage; if (string.IsNullOrEmpty(plateNumberImage)) { PictVehicle.Image = Properties.Resources.no_image; } else { try { string URL_pict_vehicle = Constant.URL_PROTOCOL + Properties.Settings.Default.IPAddressServer + Properties.Resources.repo + "/" + parkingIn.PlateNumberImage; PictVehicle.Load(URL_pict_vehicle); } catch (Exception) { PictVehicle.Image = Properties.Resources.no_image; } } PictVehicle.BackgroundImageLayout = ImageLayout.Stretch; PictVehicle.SizeMode = PictureBoxSizeMode.StretchImage; break; default: notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", response.Message, ToolTipIcon.Error); Clear(); break; } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error); } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.WARNING_MESSAGE_UNTAPPED_CARD, ToolTipIcon.Error); this.ResetComboBox(); return; } } }