示例#1
0
        private void RequestFineFarePerVehicle(string vehicle)
        {
            string             requestFineApiUrl = Properties.Resources.RequestFineFareAPIURL;
            FineFareRequest    fineFareRequest   = new FineFareRequest(vehicle);
            var                payload           = JsonConvert.SerializeObject(fineFareRequest);
            DataResponseObject response          = (DataResponseObject)restApi.post(ipAddressServer, requestFineApiUrl, true, payload);

            if (response != null)
            {
                if (response.Status == 206)
                {
                    FineFare fineFare   = JsonConvert.DeserializeObject <FineFare>(response.Data.ToString());
                    string   chargeFare = fineFare.ChargeFare.ToString();
                    txtGrandTotal.Text = TKHelper.IDR(chargeFare);
                    string   datetimeOut = fineFare.DatetimeOut.ToString();
                    string[] temp_dt_out = datetimeOut.Split(' ');
                    waktu_keluar.Text = TKHelper.ConvertDatetime(temp_dt_out[0], temp_dt_out[1]);
                }
                else
                {
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", response.Message, ToolTipIcon.Warning);
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error);
            }
        }
示例#2
0
        private void tipe_kendaraan_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (tipe_kendaraan.SelectedIndex != 0)
            {
                var    ApiUrl      = Properties.Resources.RequestVehicleFarePassKadeAPIURL;
                string vehicleType = tipe_kendaraan.Text;
                PassKadeInVehicleFareRequest passKadeInVehicleFareRequest = new PassKadeInVehicleFareRequest(vehicleType);
                var sentParam = JsonConvert.SerializeObject(passKadeInVehicleFareRequest);

                DataResponseObject response = (DataResponseObject)restApi.post(IpAddressServer, ApiUrl, true, sentParam);
                if (response != null)
                {
                    if (response.Status == 206)
                    {
                        PassKadeInVehicleFare passKadeInVehicleFare = JsonConvert.DeserializeObject <PassKadeInVehicleFare>(response.Data.ToString());

                        txtPassKadeFare.Text = TKHelper.IDR(passKadeInVehicleFare.Fare.ToString());
                        VehicleFare          = passKadeInVehicleFare.Fare;
                        int grandTotal = VehicleFare + CargoFare;
                        txtGrandTotal.Text = TKHelper.IDR(grandTotal.ToString());

                        string[] departure = passKadeInVehicleFare.DepartureDatetime.Split(' ');
                        departureDatetime.Text = TKHelper.ConvertDatetime(departure[0], departure[1]);
                    }
                    else
                    {
                        notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", response.Message, ToolTipIcon.Error);
                    }
                }
                else
                {
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error);
                }
            }
        }
示例#3
0
 private void tarifMuatan_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if (tarifMuatan.SelectedIndex != 0)
     {
         string outloadType = tarifMuatan.Text;
         CargoFare = TKHelper.DictionaryGetValueByKey(outloadDict, outloadType);
         int grandTotal = CargoFare + VehicleFare;
         txtGrandTotal.Text = TKHelper.IDR(grandTotal.ToString());
     }
 }
示例#4
0
        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);
                }
            }
        }
示例#5
0
 private void SetGrandTotal()
 {
     GrandTotal         = PedestrianFare + CargoFare;
     txtGrandTotal.Text = TKHelper.IDR(GrandTotal.ToString());
 }
示例#6
0
        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;
                }
            }
        }