示例#1
0
        private bool ChangeSettings()
        {
            string name            = "";
            string surname         = "";
            string login           = "";
            string password        = "";
            string confirmpassword = "";
            string email           = "";
            string phone           = "";

            if (!string.IsNullOrEmpty(nameTB.Text))
            {
                name = nameTB.Text;
            }
            else
            {
                MessageBox.Show("Name is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (!string.IsNullOrEmpty(surnameTB.Text))
            {
                surname = surnameTB.Text;
            }
            else
            {
                MessageBox.Show("Surname is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (!string.IsNullOrEmpty(loginTB.Text))
            {
                login = loginTB.Text;
            }
            else
            {
                MessageBox.Show("Login is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (!string.IsNullOrEmpty(passwordTB.Text))
            {
                password = passwordTB.Text;
            }
            else
            {
                MessageBox.Show("Password is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (!string.IsNullOrEmpty(confirmPasswordTB.Text))
            {
                confirmpassword = confirmPasswordTB.Text;
            }
            else
            {
                MessageBox.Show("Confirm Password is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (!password.Equals(confirmpassword))
            {
                MessageBox.Show("Passwords not equalent, please check the password", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (!string.IsNullOrEmpty(emailTB.Text))
            {
                email = emailTB.Text;
            }
            else
            {
                MessageBox.Show("Email is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (!string.IsNullOrEmpty(phoneTB.Text))
            {
                phone = phoneTB.Text;
            }
            else
            {
                MessageBox.Show("Phone is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            string url = MyGlobalClass.Host + "customer/update.php?id=" + MyGlobalClass.Customer.id_customer + "&login="******"&pass="******" &role_id=" + MyGlobalClass.Customer.role_id + "&name=" + name + "&surname=" + surname + "&email=" + email + "&phone=" + phone;
            string json = MyGlobalClass.GetResponsible(url);

            if (json.Equals("1"))
            {
                MyGlobalClass.Customer.Customer_Name    = name;
                MyGlobalClass.Customer.Customer_Surname = surname;
                return(true);
            }
            else
            {
                MessageBox.Show("User settings is not updated,please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            double lat = 0;
            double lon = 0;

            if (!double.TryParse(latitudePL.Text, out lat))
            {
                MessageBox.Show("Latitude value is wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
                return;
            }
            if (!double.TryParse(longitudePL.Text, out lon))
            {
                MessageBox.Show("Longitude value is wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
                return;
            }
            switch (item)
            {
            case 3:    //Location
            {
                string url  = MyGlobalClass.Host + "location/update.php?id=" + location.id_location.ToString() + "&lat=" + lat.ToString() + "&lon=" + lon.ToString();
                string json = MyGlobalClass.GetResponsible(url);
                if (json.Equals("1"))
                {
                    MessageBox.Show("Location succesfull updated", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Location is not updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.DialogResult = DialogResult.None;
                    return;
                }
            }; break;

            case 4:    //Pustoy
            {
                string url  = MyGlobalClass.Host + "location/insert.php?lat=" + lat.ToString() + "&lon=" + lon.ToString();
                string json = MyGlobalClass.GetResponsible(url);
                if (json.Equals("1"))
                {
                    MessageBox.Show("Location succesfull inserted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Location is not inserted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.DialogResult = DialogResult.None;
                    return;
                }
            }; break;

            case 5:    //List Location
            {
                foreach (Location l in listLocation)
                {
                    string url  = MyGlobalClass.Host + "location/update.php?id=" + l.id_location.ToString() + "&lat=" + lat.ToString() + "&lon=" + lon.ToString();
                    string json = MyGlobalClass.GetResponsible(url);
                    if (!json.Equals("1"))
                    {
                        MessageBox.Show("Location is not updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.DialogResult = DialogResult.None;
                        return;
                    }
                }
                MessageBox.Show("Locations are succesfull updates", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }; break;
            }
        }