示例#1
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);
                }
            }
        }
示例#2
0
        private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex != 0)
            {
                if (textBox1.Text != "" && textBox1.Text != "UID Card")
                {
                    if (comboBox1.SelectedIndex != 0)
                    {
                        // send data API
                        var     APIUrl = Properties.Resources.RequestUIDFareAPIURL;
                        JObject param  = new JObject();
                        param["uid"]     = textBox1.Text;
                        param["vehicle"] = comboBox1.Text;
                        var sent_param = JsonConvert.SerializeObject(param);

                        RESTAPI      api = new RESTAPI();
                        string       ip_address_server = "http://" + Properties.Settings.Default.IPAddressServer;
                        DataResponse response          = api.API_Post(ip_address_server, APIUrl, sent_param);
                        if (response != null)
                        {
                            switch (response.Status)
                            {
                            case 206:
                                //MessageBox.Show(response.Message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                foreach (JObject data in response.Data)
                                {
                                    // Duration Data Process
                                    string   duration = data["lama_parkir"].ToString();
                                    string[] temp     = duration.Split(':');
                                    txtHour.Text   = temp[0];
                                    txtMinute.Text = temp[1];
                                    txtSecond.Text = temp[2];

                                    // Total Fare Process
                                    txtGrandTotal.Text = data["tarif_parkir"].ToString();

                                    // Datetime Parking In
                                    string   datetime_in = data["waktu_masuk"].ToString();
                                    string[] temp_dt_in  = datetime_in.Split(' ');
                                    textBox3.Text = this.helper.ConvertDatetime(temp_dt_in[0], temp_dt_in[1]);

                                    // Datetime Out
                                    string   datetime_out = data["waktu_keluar"].ToString();
                                    string[] temp_dt_out  = datetime_out.Split(' ');
                                    textBox4.Text = this.helper.ConvertDatetime(temp_dt_out[0], temp_dt_out[1]);

                                    // Load Picture of face and plate number
                                    string URL_pict_face = "http://" + Properties.Settings.Default.IPAddressServer + Properties.Resources.repo + "/" + data["gambar_face"].ToString();
                                    PictFace.Load(URL_pict_face);
                                    PictFace.BackgroundImageLayout = ImageLayout.Stretch;
                                    PictFace.SizeMode = PictureBoxSizeMode.StretchImage;
                                    string URL_pict_vehicle = "http://" + Properties.Settings.Default.IPAddressServer + Properties.Resources.repo + "/" + data["gambar_plate"].ToString();
                                    PictVehicle.Load(URL_pict_vehicle);
                                    PictVehicle.BackgroundImageLayout = ImageLayout.Stretch;
                                    PictVehicle.SizeMode = PictureBoxSizeMode.StretchImage;

                                    // Total Fare Process
                                    string total_fare = data["tarif_parkir"].ToString();
                                    txtGrandTotal.Text = this.helper.IDR(total_fare);
                                }
                                break;

                            default:
                                MessageBox.Show(response.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                this.Clear();
                                break;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error : Can't establish connection to server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Silahkan Tap Kartunya Terlebih Dahulu.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.ResetComboBox();
                    return;
                }
            }
        }
示例#3
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;
                }
            }
        }