Beispiel #1
0
        private void btn_user_update_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();

            customer.SetName(txtb_name.Text);
            customer.SetPassword(DbCustomer.get_customer_from_id(Customer.activeCustomer).GetPassword()); //bu aşamada parola güncellensin istemiyoruz eski parolayı tekrar yazdırıyorum.
            customer.SetTelephone_number(maskedtxtb_telephone.Text);
            customer.SetBirth_date(dateTimePicker1.Value);
            customer.SetImage(pictureBox_user.ImageLocation);
            customer.SetMoney(Convert.ToInt32(numericUpdown_money.Value));

            DialogResult dialog = MessageBox.Show("Update changed fields.", "Okey", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.Yes)
            {
                if (string.IsNullOrEmpty(customer.GetName()) || string.IsNullOrEmpty(customer.GetPassword()))
                {
                    MessageBox.Show("Username field is required. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    DbCustomer.UpdateCustomer(customer);
                    MessageBox.Show("Updated!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Beispiel #2
0
        private void btn_buy_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show($"Buy product.", "Okey", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.Yes)
            {
                Customer customer = new Customer();
                customer = DbCustomer.get_customer_from_id(Customer.activeCustomer);
                double userMoney = customer.GetMoney();
                double product_price;

                product_price = Convert.ToInt32(lbl_price.Text);

                if (userMoney >= product_price)
                {
                    userMoney = userMoney - product_price;
                    customer.SetMoney(userMoney);
                    DbCustomer.UpdateCustomer(customer);
                }
            }
        }
Beispiel #3
0
        public void buy_product(int product_number)
        {
            DialogResult dialog = MessageBox.Show($"Buy product.", "Okey", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.Yes)
            {
                Customer customer = new Customer();
                customer = DbCustomer.get_customer_from_id(Customer.activeCustomer);
                double userMoney = customer.GetMoney();
                double product_price;

                if (product_number == 0) //kaçıncı butona(0,1,2) basıldı kontrolu
                {
                    product_price = Convert.ToInt32(lbl_product0_price.Text);
                }
                else if (product_number == 1)
                {
                    product_price = Convert.ToInt32(lbl_product1_price.Text);
                }
                else if (product_number == 2)
                {
                    product_price = Convert.ToInt32(lbl_product2_price.Text);
                }
                else
                {
                    return;
                }


                if (userMoney >= product_price)
                {
                    userMoney = userMoney - product_price;
                    customer.SetMoney(userMoney);
                    DbCustomer.UpdateCustomer(customer);
                }
            }
        }