Esempio n. 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);
                }
            }
        }
Esempio n. 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string clock = DateTime.Now.ToLongTimeString();

            lbl_clock.Text = clock;

            if (Customer.activeCustomer != 0)
            {
                lbl_active_usermoney.Text = DbCustomer.get_customer_from_id(Customer.activeCustomer).GetMoney().ToString(); //menudeki para değiştiğinde güncelleyebilmek için
            }
        }
Esempio n. 3
0
        private void btn_addComment_Click(object sender, EventArgs e)
        {
            Comment comment = new Comment();

            comment.SetText(richTxtb_commentText.Text);
            comment.SetCreateTime(DateTime.Now);
            comment.SetProduct(this.product);
            comment.SetCustomer(DbCustomer.get_customer_from_id(Customer.activeCustomer));
            comment.SetSeller(DbSeller.get_seller_data_from_id(Seller.activeSeller));

            DbComment.add_comment(comment);
        }
Esempio n. 4
0
        private void fill_user_details()
        {
            Customer customer = new Customer();

            customer = DbCustomer.get_customer_from_id(Customer.activeCustomer);

            pictureBox_user.ImageLocation = customer.GetImage();
            txtb_name.Text            = customer.GetName();
            maskedtxtb_telephone.Text = customer.GetTelephone_number();
            dateTimePicker1.Text      = customer.GetBirth_date().ToString();
            numericUpdown_money.Value = Convert.ToDecimal(customer.GetMoney());
        }
Esempio n. 5
0
        private void start_menu_labels()
        {
            timer1.Enabled = true;            //timer

            if (Customer.activeCustomer != 0) //hangi turden kullanıcı açık ise ona gore atama yap
            {
                Customer customer = new Customer();
                customer = DbCustomer.get_customer_from_id(Customer.activeCustomer);
                lbl_active_username.Text     = customer.GetName();
                lbl_dolar.Visible            = true;
                lbl_active_usermoney.Visible = true;
                lbl_active_usermoney.Text    = customer.GetMoney().ToString();
            }
            if (Seller.activeSeller != 0)
            {
                lbl_active_username.Text     = DbSeller.get_seller_data_from_id(Seller.activeSeller).GetName();
                lbl_dolar.Visible            = false;
                lbl_active_usermoney.Visible = false;
            }
        }
Esempio n. 6
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);
                }
            }
        }
Esempio n. 7
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);
                }
            }
        }