Exemplo n.º 1
0
        public bool ValidateRegistrationNumber()
        {
            bool result = false;

            if (App.Current.Properties.ContainsKey("apitoken"))
            {
                CustomerVehicle obj_CustomerVehicle = new CustomerVehicle();
                obj_CustomerVehicle.CustomerID              = CustomerID;
                obj_CustomerVehicle.CustomerVehicleID       = 0;
                obj_CustomerVehicle.CustomerVehicleMapperID = 0;
                obj_CustomerVehicle.RegistrationNumber      = txtRegNumber.Text.Trim();

                var json    = JsonConvert.SerializeObject(obj_CustomerVehicle);
                var content = new StringContent(json, Encoding.UTF8, "application/json");
                dal_Vehicle = new DALVehicle();
                OCustomerVehicle resultObj = dal_Vehicle.ValidateRegistrationNumber(Convert.ToString(App.Current.Properties["apitoken"]), obj_CustomerVehicle);

                if (resultObj.CustomerVehicleID != 0)
                {
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public bool ValidateRegistrationNumber()
        {
            IsOnline = VerifyInternet();
            bool result = false;

            if (IsOnline)
            {
                if (App.Current.Properties.ContainsKey("apitoken"))
                {
                    CustomerVehicle obj_CustomerVehicle = new CustomerVehicle();
                    obj_CustomerVehicle.CustomerID              = CustomerID;
                    obj_CustomerVehicle.CustomerVehicleID       = CustomerVehicleID;
                    obj_CustomerVehicle.CustomerVehicleMapperID = CustomerVehicleMapperID;
                    obj_CustomerVehicle.RegistrationNumber      = txtRegNumber.Text.Trim();

                    var json    = JsonConvert.SerializeObject(obj_CustomerVehicle);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    OCustomerVehicle resultObj = dal_Vehicle.ValidateRegistrationNumber(Convert.ToString(App.Current.Properties["apitoken"]), obj_CustomerVehicle);

                    if (resultObj.CustomerVehicleID != 0)
                    {
                        result = false;
                    }
                    else
                    {
                        result = true;
                    }
                }
            }
            else
            {
                DisplayAlert("", "Please check your network connectivity", "Ok");
            }
            return(result);
        }
Exemplo n.º 3
0
        public void rbRegistrationNumber(object sender, CheckedChangedEventArgs e)
        {
            if (e.Value)
            {
                IsOnline = VerifyInternet();
                if (IsOnline)
                {
                    OCustomerVehicle customerVehicle = ((RadioButton)sender).BindingContext as OCustomerVehicle;
                    VehicleTypeID      = customerVehicle.VehicleTypeID;
                    CustomerVehicleID  = customerVehicle.CustomerVehicleID;
                    RegistrationNumber = customerVehicle.RegistrationNumber;

                    objOCustomerVehicle.VehicleTypeID      = VehicleTypeID;
                    objOCustomerVehicle.Model              = customerVehicle.Model;
                    objOCustomerVehicle.CustomerVehicleID  = CustomerVehicleID;
                    objOCustomerVehicle.RegistrationNumber = RegistrationNumber;
                    objOCustomerVehicle.VehicleImage       = customerVehicle.VehicleImage;

                    GetVehicleDueAmount(CustomerVehicleID);
                }
                else
                {
                    DisplayAlert("", "Please check your network connectivity", "Ok");
                }
            }
        }
        public List <OCustomerVehicle> GetListOfCustomerVehicleWithType(CustomerVehicle objCustomerVehicle)
        {
            DALExceptionManagment   objExceptionlog          = new DALExceptionManagment();
            List <OCustomerVehicle> obj_listOCustomerVehicle = new List <OCustomerVehicle>();
            OCustomerVehicle        obj_OCustomerVehicle     = new OCustomerVehicle();
            string resultMsg = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("CTAPP_PROC_GETLISTOFCUSTOMERVEHICLEWITHTYPE", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerID", objCustomerVehicle.CustomerID);
                        sqlcmd_obj.Parameters.AddWithValue("@VehicleTypeID", objCustomerVehicle.VehicleTypeID);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            for (int i = 0; i < resultdt.Rows.Count; i++)
                            {
                                obj_OCustomerVehicle = new OCustomerVehicle();
                                obj_OCustomerVehicle.CustomerVehicleMapperID = Convert.ToInt32(resultdt.Rows[i]["CustomerVehicleMapperID"]);
                                obj_OCustomerVehicle.CustomerVehicleID       = Convert.ToInt32(resultdt.Rows[i]["CustomerVehicleID"]);
                                obj_OCustomerVehicle.CustomerID             = Convert.ToInt32(resultdt.Rows[i]["CustomerID"]);
                                obj_OCustomerVehicle.VehicleTypeCode        = Convert.ToString(resultdt.Rows[i]["VehicleTypeCode"]);
                                obj_OCustomerVehicle.VehicleTypeID          = Convert.ToInt32(resultdt.Rows[i]["VehicleTypeID"]);
                                obj_OCustomerVehicle.RegistrationNumber     = Convert.ToString(resultdt.Rows[i]["RegistrationNumber"]);
                                obj_OCustomerVehicle.RegistrationNumberType = Convert.ToString(resultdt.Rows[i]["RegistrationNumberType"]);
                                obj_OCustomerVehicle.VehicleImage           = "resource://InstaConsumer.Resources." + Convert.ToString(resultdt.Rows[i]["VehicleImage"]);
                                obj_OCustomerVehicle.Make                = resultdt.Rows[i]["Make"] == null ? "" : Convert.ToString(resultdt.Rows[i]["Make"]);
                                obj_OCustomerVehicle.Model               = resultdt.Rows[i]["Model"] == null ? "" : Convert.ToString(resultdt.Rows[i]["Model"]);
                                obj_OCustomerVehicle.Color               = resultdt.Rows[i]["Color"] == null ? "" : Convert.ToString(resultdt.Rows[i]["Color"]);
                                obj_OCustomerVehicle.IsPrimaryVehicle    = resultdt.Rows[i]["IsPrimaryVehicle"] == null ? false : Convert.ToBoolean(resultdt.Rows[i]["IsPrimaryVehicle"]);
                                obj_OCustomerVehicle.PrimaryVehicleImage = "resource://InstaConsumer.Resources." + Convert.ToString(resultdt.Rows[i]["PrimaryVehicleImage"]);
                                obj_OCustomerVehicle.IsActive            = resultdt.Rows[i]["IsActive"] == null ? true : Convert.ToBoolean(resultdt.Rows[i]["IsActive"]);
                                obj_OCustomerVehicle.Name                = Convert.ToString(resultdt.Rows[i]["Name"]);
                                obj_OCustomerVehicle.PhoneNumber         = Convert.ToString(resultdt.Rows[i]["PhoneNumber"]);
                                //obj_OCustomerVehicle.CheckedFlag = resultdt.Rows[i]["CheckedFlag"] == null ? false : Convert.ToBoolean(resultdt.Rows[i]["CheckedFlag"]);
                                obj_listOCustomerVehicle.Add(obj_OCustomerVehicle);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objExceptionlog.InsertException(ex.Message, "DALVehicle", "Proc: " + "CTAPP_PROC_GETLISTOFCUSTOMERVEHICLEWITHTYPE", "GetListOfCustomerVehicleWithType");
                throw;
            }
            return(obj_listOCustomerVehicle);
        }
Exemplo n.º 5
0
        public BuyAPass(OCustomerVehicle obj_OCustomerVehicle)
        {
            InitializeComponent();
            ShowLoading(true);
            dal_Pass                = new DALPass();
            dal_Vehicle             = new DALVehicle();
            dal_Customer            = new DALCustomer();
            dal_LocationParkingLots = new DALLocationParkingLots();

            objOCustomerVehicle = obj_OCustomerVehicle;
            VehicleTypeID       = obj_OCustomerVehicle.VehicleTypeID;
            LocationID          = obj_OCustomerVehicle.LocationID;
            CustomerID          = obj_OCustomerVehicle.CustomerID;

            ShowLoading(false);
        }
        public OCustomerVehicle InsertCustomerVehicle(CustomerVehicle objCustomerVehicle)
        {
            DALExceptionManagment objExceptionlog      = new DALExceptionManagment();
            OCustomerVehicle      obj_OCustomerVehicle = new OCustomerVehicle();
            string resultMsg = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("CTAPP_PROC_INSERTUPDATECUSTOMERVEHICLE", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerVehicleID", 0);
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerVehicleMapperID", 0);
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerID", objCustomerVehicle.CustomerID);
                        sqlcmd_obj.Parameters.AddWithValue("@VehicleTypeCode", objCustomerVehicle.VehicleTypeCode);
                        sqlcmd_obj.Parameters.AddWithValue("@Make", objCustomerVehicle.Make);
                        sqlcmd_obj.Parameters.AddWithValue("@Model", objCustomerVehicle.Model);
                        sqlcmd_obj.Parameters.AddWithValue("@Color", objCustomerVehicle.Color);
                        sqlcmd_obj.Parameters.AddWithValue("@RegistrationNumber", objCustomerVehicle.RegistrationNumber);
                        sqlcmd_obj.Parameters.AddWithValue("@IsPrimaryVehicle", objCustomerVehicle.IsPrimaryVehicle);
                        sqlcmd_obj.Parameters.AddWithValue("@IsActive", true);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            obj_OCustomerVehicle.CustomerVehicleID = Convert.ToInt32(resultdt.Rows[0]["CustomerVehicleID"]);
                            obj_OCustomerVehicle.VehicleTypeID     = Convert.ToInt32(resultdt.Rows[0]["VehicleTypeID"]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objExceptionlog.InsertException(ex.Message, "DALVehicle", "Proc: " + "CTAPP_PROC_INSERTUPDATECUSTOMERVEHICLE", "InsertCustomerVehicle");
                throw;
            }
            return(obj_OCustomerVehicle);
        }
Exemplo n.º 7
0
        public OCustomerVehicle InsertCustomerVehicle(string accessToken, CustomerVehicle objCustomerVehicle)
        {
            OCustomerVehicle obj_OCustomerVehicle = new OCustomerVehicle();

            try
            {
                string baseUrl = Convert.ToString(App.Current.Properties["BaseURL"]);
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    // Add the Authorization header with the AccessToken.
                    client.DefaultRequestHeaders.Add("Authorization", "bearer  " + accessToken);
                    // create the URL string.
                    string url = "api/InstaConsumer/InsertCustomerVehicle";
                    // make the request

                    var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = client.PostAsync(url, content).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        string jsonString = response.Content.ReadAsStringAsync().Result;
                        if (jsonString != null)
                        {
                            APIResponse apiResult = JsonConvert.DeserializeObject <APIResponse>(jsonString);

                            if (apiResult.Result)
                            {
                                obj_OCustomerVehicle = JsonConvert.DeserializeObject <OCustomerVehicle>(Convert.ToString(apiResult.Object));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(obj_OCustomerVehicle);
        }
        public OCustomerVehicle ValidateRegistrationNumber(CustomerVehicle objCustomerVehicle)
        {
            DALExceptionManagment objExceptionlog     = new DALExceptionManagment();
            OCustomerVehicle      obj_CustomerVehicle = new OCustomerVehicle();
            string resultMsg = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("CTAPP_PROC_VALIDATEREGISTRATIONNUMBER", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerID", objCustomerVehicle.CustomerID);
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerVehicleID", objCustomerVehicle.CustomerVehicleID);
                        sqlcmd_obj.Parameters.AddWithValue("@CustomerVehicleMapperID", objCustomerVehicle.CustomerVehicleMapperID);
                        sqlcmd_obj.Parameters.AddWithValue("@RegistrationNumber", objCustomerVehicle.RegistrationNumber);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            obj_CustomerVehicle.CustomerVehicleID = Convert.ToInt32(resultdt.Rows[0]["CustomerVehicleID"]);
                        }
                        else
                        {
                            obj_CustomerVehicle.CustomerVehicleID = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objExceptionlog.InsertException(ex.Message, "DALVehicle", "Proc: " + "CTAPP_PROC_VALIDATEREGISTRATIONNUMBER", "ValidateRegistrationNumber");
                throw;
            }
            return(obj_CustomerVehicle);
        }
Exemplo n.º 9
0
        //Floating Lable Code End

        public UpdateVehicle(OCustomerVehicle customerVehicle)
        {
            InitializeComponent();
            ShowLoading(true);
            dal_Vehicle          = new DALVehicle();
            dal_Customer         = new DALCustomer();
            txtMake.Text         = customerVehicle.Make;
            txtModel.Text        = customerVehicle.Model;
            txtColor.Text        = customerVehicle.Color;
            txtRegNumber.Text    = customerVehicle.RegistrationNumber;
            swtPrimary.IsToggled = customerVehicle.IsPrimaryVehicle;
            swtActive.IsToggled  = customerVehicle.IsActive;

            CustomerVehicleMapperID = customerVehicle.CustomerVehicleMapperID;
            CustomerVehicleID       = customerVehicle.CustomerVehicleID;
            VehicleTypeID           = customerVehicle.VehicleTypeID;
            CustomerID      = customerVehicle.CustomerID;
            VehicleTypeCode = customerVehicle.VehicleTypeCode;

            if (customerVehicle.VehicleTypeCode == "2W")
            {
                svgTwo.Source   = "resource://InstaConsumer.Resources.blue_circle_bike.svg";
                svgFour.Source  = "resource://InstaConsumer.Resources.grey_circle_car.svg";
                VehicleTypeCode = VehicleTypeCodes.TwoWheeler;
            }
            else if (customerVehicle.VehicleTypeCode == "4W")
            {
                svgTwo.Source   = "resource://InstaConsumer.Resources.grey_circle_bike.svg";
                svgFour.Source  = "resource://InstaConsumer.Resources.blue_circle_car.svg";
                VehicleTypeCode = VehicleTypeCodes.FourWheeler;
            }

            ShowLoading(false);

            //Floating Lable Code Start
            lblMake.TranslationX = lblModel.TranslationX = lblColor.TranslationX = lblRegNumber.TranslationX = 10;
            lblMake.FontSize     = lblModel.FontSize = lblColor.FontSize = lblRegNumber.FontSize = _placeholderFontSize;
            lblMake.TextColor    = lblModel.TextColor = lblColor.TextColor = lblRegNumber.TextColor = Color.Gray;

            if (string.IsNullOrEmpty(txtMake.Text))
            {
                TransitionToPlaceholder(true);
            }
            else
            {
                TransitionToTitle(true);
            }
            if (string.IsNullOrEmpty(txtModel.Text))
            {
                TransitionToPlaceholder_Model(true);
            }
            else
            {
                TransitionToTitle_Model(true);
            }
            if (string.IsNullOrEmpty(txtColor.Text))
            {
                TransitionToPlaceholder_Color(true);
            }
            else
            {
                TransitionToTitle_Color(true);
            }
            if (string.IsNullOrEmpty(txtRegNumber.Text))
            {
                TransitionToPlaceholder_RegNumber(true);
            }
            else
            {
                TransitionToTitle_RegNumber(true);
            }

            txtMake.Focus();
            //Floating Lable Code End
        }
Exemplo n.º 10
0
        private async void btn_UpdateVehicleClicked(object sender, EventArgs e)
        {
            IsOnline = VerifyInternet();
            if (IsOnline)
            {
                btnUpdateVehicle.IsVisible = false;
                ShowLoading(true);

                CustomerPaymentHistoryDetails obj = GetLotParkingDetailsByVehicleID();

                if (obj.CustomerParkingSlotID != 0)
                {
                    if (obj.StatusID != 5 && obj.StatusID != 6)
                    {
                        btnUpdateVehicle.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Unable to update Vehicle Info", "Ok");
                        return;
                    }
                    else
                    {
                        if (swtActive.IsToggled)
                        {
                            btnUpdateVehicle.IsVisible = true;
                            ShowLoading(false);
                            DisplayAlert("", "Unable to update Vehicle Info", "Ok");
                            return;
                        }
                    }

                    CustomerVehicle objCustomerVehicle = new CustomerVehicle();
                    objCustomerVehicle.CustomerVehicleMapperID = CustomerVehicleMapperID;
                    objCustomerVehicle.CustomerVehicleID       = CustomerVehicleID;
                    objCustomerVehicle.CustomerID       = CustomerID;
                    objCustomerVehicle.VehicleTypeCode  = VehicleTypeCode;
                    objCustomerVehicle.IsPrimaryVehicle = swtPrimary.IsToggled;
                    objCustomerVehicle.IsActive         = swtActive.IsToggled;
                    objCustomerVehicle.CreatedBy        = "CHECKIN";

                    if (App.Current.Properties.ContainsKey("apitoken"))
                    {
                        var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                        var content = new StringContent(json, Encoding.UTF8, "application/json");
                        OCustomerVehicle resultObj = dal_Vehicle.UpdateCustomerVehicle(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerVehicle);

                        if (resultObj.CustomerVehicleID != 0)
                        {
                            btnUpdateVehicle.IsVisible = true;
                            ShowLoading(false);
                            int CustomerID = 0;
                            if (App.Current.Properties.ContainsKey("CustomerID"))
                            {
                                CustomerID = Convert.ToInt32(App.Current.Properties["CustomerID"]);
                            }

                            await Navigation.PushAsync(new MyVehicles());
                        }
                    }
                    else
                    {
                        btnUpdateVehicle.IsVisible = true;
                        ShowLoading(false);
                    }
                }

                if (txtMake.Text == "" || txtMake.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Brand of your Vehicle", "Ok");
                    return;
                }

                var regexName = new Regex("^[a-zA-Z ]*$");
                if (!regexName.IsMatch(txtMake.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter only alphabets for Vehicle Brand", "Ok");
                    return;
                }

                if (txtModel.Text == "" || txtModel.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Model of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z0-9 ]*$");
                if (!regexName.IsMatch(txtModel.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please do not enter special characters for Vehicle Model", "Ok");
                    return;
                }

                if (txtColor.Text == "" || txtColor.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Color of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z ]*$");
                if (!regexName.IsMatch(txtColor.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please do not enter special characters for Vehicle Color", "Ok");
                    return;
                }

                if (txtRegNumber.Text == "" || txtRegNumber.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Registration Number of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z0-9]*$");
                if (!regexName.IsMatch(txtRegNumber.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter only alphabets and numbers in Registration Number", "Ok");
                    return;
                }

                if (ValidRegistrationNumber(txtRegNumber.Text.Trim()))
                {
                    if (ValidateRegistrationNumber())
                    {
                        btnUpdateVehicle.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "This Registration Number already exists!", "Ok");
                    }
                    else
                    {
                        CustomerVehicle objCustomerVehicle = new CustomerVehicle();
                        objCustomerVehicle.CustomerVehicleMapperID = CustomerVehicleMapperID;
                        objCustomerVehicle.CustomerVehicleID       = CustomerVehicleID;
                        objCustomerVehicle.CustomerID         = CustomerID;
                        objCustomerVehicle.VehicleTypeCode    = VehicleTypeCode;
                        objCustomerVehicle.Make               = txtMake.Text.Trim();
                        objCustomerVehicle.Model              = txtModel.Text.Trim();
                        objCustomerVehicle.Color              = txtColor.Text.Trim();
                        objCustomerVehicle.RegistrationNumber = txtRegNumber.Text.Trim();
                        objCustomerVehicle.IsPrimaryVehicle   = swtPrimary.IsToggled;
                        objCustomerVehicle.IsActive           = swtActive.IsToggled;
                        objCustomerVehicle.CreatedBy          = "NORMAL";

                        if (App.Current.Properties.ContainsKey("apitoken"))
                        {
                            var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                            var content = new StringContent(json, Encoding.UTF8, "application/json");
                            OCustomerVehicle resultObj = dal_Vehicle.UpdateCustomerVehicle(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerVehicle);

                            if (resultObj.CustomerVehicleID != 0)
                            {
                                App.Current.Properties["Vehicle"]            = true;
                                App.Current.Properties["VehicleTypeID"]      = resultObj.VehicleTypeID;
                                App.Current.Properties["CustomerVehicleID"]  = resultObj.CustomerVehicleID;
                                App.Current.Properties["RegistrationNumber"] = txtRegNumber.Text.Trim();
                                await Application.Current.SavePropertiesAsync();

                                btnUpdateVehicle.IsVisible = true;
                                ShowLoading(false);
                                int CustomerID = 0;
                                if (App.Current.Properties.ContainsKey("CustomerID"))
                                {
                                    CustomerID = Convert.ToInt32(App.Current.Properties["CustomerID"]);
                                }

                                await Navigation.PushAsync(new MyVehicles());
                            }
                        }
                        else
                        {
                            btnUpdateVehicle.IsVisible = true;
                            ShowLoading(false);
                        }
                    }
                }
                else
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please provide valid vehicle Registration Number ", "Ok");
                }
            }
            else
            {
                await DisplayAlert("", "Please check your network connectivity", "Ok");

                return;
            }
        }
        public GeneratePass(PassPrice obj_passPrice, List <Location> location, OCustomerVehicle obj_CustomerVehicle, bool isMulti)
        {
            InitializeComponent();
            ShowLoading(true);

            lst_Location = new List <Location>();

            objCustomerVehicle = obj_CustomerVehicle;
            objLocation        = location;
            objpassPrice       = obj_passPrice;

            lblPriceDisplay.Text = "₹ " + Convert.ToString(Convert.ToDouble(objpassPrice.Price + objpassPrice.DueAmount)) + " /-";

            this.BindingContext = objpassPrice;

            PassType = obj_passPrice.PassTypeName.ToUpper();

            dal_Pass = new DALPass();
            IsMulti  = isMulti;
            if (isMulti)
            {
                string str = string.Empty;
                for (int i = 0; i < location.Count; i++)
                {
                    str = str + location[i].LocationName + ", ";

                    objLoc = new Location();
                    objLoc.LocationNumber = i + 1;
                    objLoc.LocationName   = location[i].LocationName;
                    lst_Location.Add(objLoc);
                }
                LocationName = str.Substring(0, str.Length - 2).Trim();
            }
            else
            {
                LocationName = location[0].LocationName;

                objLoc = new Location();
                objLoc.LocationNumber = 1;
                objLoc.LocationName   = location[0].LocationName;
                lst_Location.Add(objLoc);
            }

            lstLocation.ItemsSource    = lst_Location;
            lblModel.Text              = obj_CustomerVehicle.Model;
            lblRegistrationNumber.Text = obj_CustomerVehicle.RegistrationNumber;
            imgVehicle.Source          = obj_CustomerVehicle.VehicleImage;

            DateTime startDate = DateTime.Now;

            if (obj_passPrice.PassCode.ToUpper() == "DP")
            {
                lblLineStation.IsVisible = true;
                lblStation.IsVisible     = true;
                lblAllStation.IsVisible  = false;
                lstLocation.IsVisible    = true;
                StartDate  = startDate;
                ExpiryDate = startDate;
            }
            else if (obj_passPrice.PassCode.ToUpper() == "2W WP" || obj_passPrice.PassCode.ToUpper() == "4W WP")
            {
                lblLineStation.IsVisible = true;
                lblStation.IsVisible     = true;
                lblAllStation.IsVisible  = false;
                lstLocation.IsVisible    = true;
                StartDate  = startDate;
                ExpiryDate = startDate.AddDays((Convert.ToInt32(obj_passPrice.Duration) - 1));
            }
            else if (obj_passPrice.PassCode.ToUpper() == "2W ALL STATION" || obj_passPrice.PassCode.ToUpper() == "4W ALL STATION")
            {
                IsMultiLot = true;
                lblLineStation.IsVisible = false;
                lblStation.IsVisible     = false;
                lblAllStation.IsVisible  = true;
                lstLocation.IsVisible    = false;
                StartDate  = startDate;
                ExpiryDate = startDate.AddDays((Convert.ToInt32(obj_passPrice.Duration) - 1));
            }
            else
            {
                lblLineStation.IsVisible = true;
                lblStation.IsVisible     = true;
                lblAllStation.IsVisible  = false;
                lstLocation.IsVisible    = true;
                StartDate  = startDate;
                ExpiryDate = startDate.AddDays((Convert.ToInt32(obj_passPrice.Duration) - 1));
            }

            if (obj_passPrice.PassTypeCode == "EP")// Event Pass
            {
                lblLineStation.IsVisible = true;
                lblStation.IsVisible     = true;
                lblAllStation.IsVisible  = false;

                obj_passPrice.Duration = (obj_passPrice.Duration == null || obj_passPrice.Duration == "0" || obj_passPrice.Duration == "") ? "0" : obj_passPrice.Duration;

                // EP Start Date Validation
                if (DateTime.Now.Date >= Convert.ToDateTime(obj_passPrice.StartDate).Date&& DateTime.Now.Date <= Convert.ToDateTime(obj_passPrice.EndDate).Date)
                {
                    obj_passPrice.StartDate = DateTime.Now.Date;
                }

                StartDate  = Convert.ToDateTime(obj_passPrice.StartDate);
                ExpiryDate = Convert.ToDateTime(obj_passPrice.EndDate);
            }

            lblFrom.Text = StartDate.ToString("d MMM yyyy, hh:mm tt", CultureInfo.CreateSpecificCulture("en-US"));
            lblTo.Text   = ExpiryDate.ToString("d MMM yyyy, hh:mm tt", CultureInfo.CreateSpecificCulture("en-US"));
            string fromdatesplit = lblFrom.Text.Split(',')[0];
            string fromtimesplit = lblFrom.Text.Split(',')[1];

            lblFrom.Text     = fromdatesplit;
            lblFromTime.Text = "06:00 AM";
            string toDatesplit = lblTo.Text.Split(',')[0];
            string toTimesplit = lblTo.Text.Split(',')[1];

            lblTo.Text     = toDatesplit;
            lblToTime.Text = "10:00 PM";

            price = obj_passPrice.Price;

            ShowLoading(false);
        }
Exemplo n.º 12
0
        public void GetListOfCustomerVehicleWithType(int VehicleTypeID)
        {
            try
            {
                IsOnline = VerifyInternet();

                if (IsOnline)
                {
                    if (App.Current.Properties.ContainsKey("CustomerID"))
                    {
                        if (Convert.ToInt32(App.Current.Properties["CustomerID"]) != 0)
                        {
                            using (HttpClient client = new HttpClient())
                            {
                                client.BaseAddress = new Uri(Convert.ToString(App.Current.Properties["BaseURL"]));
                                // We want the response to be JSON.
                                client.DefaultRequestHeaders.Accept.Clear();
                                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                                List <KeyValuePair <string, string> > postData = new List <KeyValuePair <string, string> >();
                                postData.Add(new KeyValuePair <string, string>("grant_type", "password"));
                                postData.Add(new KeyValuePair <string, string>("username", "Kiran"));
                                postData.Add(new KeyValuePair <string, string>("password", "1234"));
                                FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
                                // Post to the Server and parse the response.
                                var response = client.PostAsync("Token", content).Result;
                                if (response.IsSuccessStatusCode)
                                {
                                    var        jsonString   = response.Content.ReadAsStringAsync();
                                    OAuthToken responseData = JsonConvert.DeserializeObject <OAuthToken>(jsonString.Result);
                                    string     Access_Token = responseData.access_token;
                                    App.Current.Properties["apitoken"] = Access_Token;
                                }
                            }

                            if (App.Current.Properties.ContainsKey("apitoken"))
                            {
                                CustomerVehicle obj_CustomerVehicle = new CustomerVehicle();
                                obj_CustomerVehicle.CustomerID    = Convert.ToInt32(App.Current.Properties["CustomerID"]);
                                obj_CustomerVehicle.VehicleTypeID = Convert.ToInt32(VehicleTypeID);
                                List <OCustomerVehicle> obj_listCustomerVehicle = new List <OCustomerVehicle>();
                                obj_listCustomerVehicle = dal_Vehicle.GetListOfCustomerVehicleWithType(Convert.ToString(App.Current.Properties["apitoken"]), obj_CustomerVehicle);

                                int x = 0;

                                if (obj_listCustomerVehicle.Count > 0)
                                {
                                    ColView.ItemsSource = null;

                                    var index = obj_listCustomerVehicle.Count;
                                    OCustomerVehicle ocustvehObj = new OCustomerVehicle();
                                    ocustvehObj.VehicleImage        = "resource://InstaConsumer.Resources.addvehicle.svg";
                                    ocustvehObj.Model               = "Add Vehicle";
                                    ocustvehObj.PrimaryVehicleImage = "";
                                    ocustvehObj.RegistrationNumber  = "";
                                    ocustvehObj.ModelFontsize       = 10;
                                    obj_listCustomerVehicle.Insert(obj_listCustomerVehicle.Count, ocustvehObj);

                                    ColView.ItemsSource = obj_listCustomerVehicle;
                                }
                                else
                                {
                                    ColView.ItemsSource = null;

                                    OCustomerVehicle ocustvehObj = new OCustomerVehicle();
                                    ocustvehObj.VehicleImage        = "resource://InstaConsumer.Resources.addvehicle.svg";
                                    ocustvehObj.Model               = "Add Vehicle";
                                    ocustvehObj.PrimaryVehicleImage = "";
                                    ocustvehObj.RegistrationNumber  = "";
                                    ocustvehObj.ModelFontsize       = 10;
                                    obj_listCustomerVehicle.Insert(0, ocustvehObj);

                                    ColView.ItemsSource = obj_listCustomerVehicle;
                                    //DisplayAlert("", "No Vehicles found to park! Please add/activate your Vehicle", "Ok");
                                }
                            }
                        }
                        else
                        {
                            DisplayAlert("", "Profile not found!", "Ok");
                        }
                    }
                    else
                    {
                        DisplayAlert("", "Customer Key does not exists", "Ok");
                    }
                }
                else
                {
                    DisplayAlert("", "Please check your network connectivity", "Ok");
                    return;
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("Failed - GetListOfCustomerVehicles", Convert.ToString(ex.Message), "Ok");
            }
        }
Exemplo n.º 13
0
        private async void btn_AddVehicleClicked(object sender, EventArgs e)
        {
            IsOnline = VerifyInternet();

            if (IsOnline)
            {
                ShowLoading(true);
                btnAddVehicle.IsVisible = false;

                if (txtMake.Text == "" || txtMake.Text == null)
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Brand of your Vehicle", "Ok");
                    return;
                }

                var regexName = new Regex("^[a-zA-Z ]*$");
                if (!regexName.IsMatch(txtMake.Text.Trim()))
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter only alphabets for Vehicle Brand", "Ok");
                    return;
                }

                if (txtModel.Text == "" || txtModel.Text == null)
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Model of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z0-9 ]*$");
                if (!regexName.IsMatch(txtModel.Text.Trim()))
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please do not enter special characters for Vehicle Model", "Ok");
                    return;
                }

                if (txtColor.Text == "" || txtColor.Text == null)
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Color of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z ]*$");
                if (!regexName.IsMatch(txtColor.Text.Trim()))
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please do not enter special characters for Vehicle Color", "Ok");
                    return;
                }

                if (txtRegNumber.Text == "" || txtRegNumber.Text == null)
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Registration Number of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z0-9]*$");
                if (!regexName.IsMatch(txtRegNumber.Text.Trim()))
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter only alphabets and numbers in Registration Number", "Ok");
                    return;
                }

                if (ValidRegistrationNumber(txtRegNumber.Text.Trim()))
                {
                    if (ValidateRegistrationNumber())
                    {
                        btnAddVehicle.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "This Registration Number already exists!", "Ok");
                    }
                    else
                    {
                        CustomerVehicle objCustomerVehicle = new CustomerVehicle();
                        objCustomerVehicle.CustomerID         = CustomerID;
                        objCustomerVehicle.VehicleTypeCode    = VehicleTypeCode;
                        objCustomerVehicle.Make               = txtMake.Text.Trim();
                        objCustomerVehicle.Model              = txtModel.Text.Trim();
                        objCustomerVehicle.Color              = txtColor.Text.Trim();
                        objCustomerVehicle.RegistrationNumber = txtRegNumber.Text.Trim();
                        objCustomerVehicle.IsPrimaryVehicle   = swtPrimary.IsToggled;

                        swtActive.IsToggled         = true;
                        objCustomerVehicle.IsActive = swtActive.IsToggled;

                        if (App.Current.Properties.ContainsKey("apitoken"))
                        {
                            var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                            var content = new StringContent(json, Encoding.UTF8, "application/json");
                            dal_Vehicle = new DALVehicle();
                            OCustomerVehicle resultObj = new OCustomerVehicle();

                            await Task.Run(() =>
                            {
                                resultObj = dal_Vehicle.InsertCustomerVehicle(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerVehicle);
                            });

                            if (resultObj.CustomerVehicleID != 0)
                            {
                                var location = await Geolocation.GetLastKnownLocationAsync();

                                if (location != null)
                                {
                                    Latitude  = (decimal)location.Latitude;
                                    Longitude = (decimal)location.Longitude;
                                }
                                else
                                {
                                    btnAddVehicle.IsVisible = true;
                                    ShowLoading(false);
                                    DisplayAlert("", "Please turn on device location", "Ok");
                                    return;
                                }

                                App.Current.Properties["Vehicle"]            = true;
                                App.Current.Properties["VehicleTypeID"]      = resultObj.VehicleTypeID;
                                App.Current.Properties["CustomerID"]         = CustomerID;
                                App.Current.Properties["CustomerVehicleID"]  = resultObj.CustomerVehicleID;
                                App.Current.Properties["RegistrationNumber"] = objCustomerVehicle.RegistrationNumber;
                                btnAddVehicle.IsVisible = true;
                                await Application.Current.SavePropertiesAsync();

                                //await Navigation.PushAsync(new MasterPage(objLocationParkingLotFilter));
                                await Navigation.PushAsync(new Home(null, CustomerID));

                                ShowLoading(false);
                            }
                        }
                    }
                }
                else
                {
                    btnAddVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please provide valid vehicle Registration Number ", "Ok");
                }
            }
            else
            {
                DisplayAlert("", "Please check your network connectivity", "Ok");
                return;
            }
        }