Exemple #1
0
        private void buttonRepeat_Click(object sender, EventArgs e)
        {
            List <int> orderLines = new List <int>();
            double     sum        = 0;

            var lines = (from line in ctx.HISTORY_LINES
                         where line.HL_ORDER_HEADER == history_header
                         select line).ToList();

            foreach (var line in lines)
            {
                var x = new ORDER_LINES
                {
                    OL_ITEM     = line.HL_ITEM,
                    OL_QUANTITY = line.HL_QUANTITY
                };

                var item = (from i in ctx.ITEMS
                            where i.I_ID == x.OL_ITEM
                            select i).First();

                sum += (double)item.I_PRICE * x.OL_QUANTITY;

                ctx.ORDER_LINES.Add(x);
                ctx.SaveChanges();

                orderLines.Add(x.OL_ID);
            }

            FormOrderHeader orderHeader = new FormOrderHeader(orderLines, user_id, sum);

            orderHeader.ShowDialog(this);
            orderHeader.Dispose();
            this.Close();
        }
        private void buttonOrderDone_Click(object sender, EventArgs e)
        {
            int header = (int)dataGridViewOrderHeaders.CurrentRow.Cells["oHIDDataGridViewTextBoxColumn"].Value;

            var lines = (from line in ctx.ORDER_LINES
                         where line.OL_ORDER_HEADER == header
                         select line).ToList();

            foreach (var line in lines)
            {
                ctx.ORDER_LINES.Remove(line);
                ctx.SaveChanges();
            }

            oRDERHEADERSBindingSource.RemoveCurrent();
        }
Exemple #3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (!checkBoxApprove.Checked)
            {
                MessageBox.Show("Необхідна згода з вимогами публічної пропозиції!", "Увага!");
                return;
            }

            if (textBoxCard1.Text == "" || textBoxCard2.Text == "" ||
                textBoxCard3.Text == "" || textBoxCard4.Text == "" ||
                textBoxCVV.Text == "" || comboBoxYear.Text == "" ||
                comboBoxMonth.Text == "" || textBoxCard2.Text == null ||
                textBoxCard3.Text == null || textBoxCard4.Text == null ||
                textBoxCVV.Text == null || textBoxCard1.Text == null ||
                comboBoxMonth.Text == null || comboBoxYear.Text == null)
            {
                MessageBox.Show("Заповнення усіх полів необхідне!", "Помилка");
                return;
            }

            if (textBoxCard1.Text.Length != 4 || textBoxCard2.Text.Length != 4 ||
                textBoxCard3.Text.Length != 4 || textBoxCard4.Text.Length != 4)
            {
                MessageBox.Show("Вказаний номер картки не є коректним", "Помилка");
                return;
            }

            if (textBoxCVV.Text.Length != 3)
            {
                MessageBox.Show("Некоректний формат CVV");
                return;
            }

            DateTime date = new DateTime(Convert.ToInt32("20" + comboBoxYear.Text), Convert.ToInt32(comboBoxMonth.Text), 1);

            var transaction = new TRANSACTIONS
            {
                T_DATE        = System.DateTime.Now,
                T_EXPIRE_DATE = date,
                T_RRN         = textBoxCard1.Text + textBoxCard2.Text + textBoxCard3.Text + textBoxCard4.Text
            };

            ctx.TRANSACTIONS.Add(transaction);
            ctx.SaveChanges();

            transaction_id = transaction.T_ID;
            finished       = true;

            MessageBox.Show("Транзакцію успішно виконано!");

            this.Close();
        }
        private void AddUser()
        {
            var quantity = (from u in ctx.USERS
                            select u).Count();

            string modifier = "U";

            if (quantity == 0)
            {
                modifier = "A";
            }

            var user = new USERS
            {
                U_LOGIN    = login,
                U_MODIFIER = modifier,
                U_PASSWORD = password
            };

            ctx.USERS.Add(user);
            ctx.SaveChanges();

            var customer = new CUSTOMERS
            {
                C_EMAIL  = email,
                C_NAME   = name,
                C_PHONE  = phoneNumber,
                C_USERID = user.U_ID
            };

            ctx.CUSTOMERS.Add(customer);
            ctx.SaveChanges();

            MessageBox.Show(user.U_MODIFIER == "A" ? "Адміністраторa" : "Користувачa" + " успішно зареєстровано!");

            this.Close();
        }
        private void FormPizzaOrder_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (finished == false)
            {
                var query = (from line in ctx.ORDER_LINES
                             where orderLines.Contains(line.OL_ID)
                             select line);

                foreach (var line in query)
                {
                    ctx.ORDER_LINES.Remove(line);
                }
                ctx.SaveChanges();
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            var line = new ORDER_LINES
            {
                OL_ITEM     = item_id,
                OL_QUANTITY = quantity
            };

            ctx.ORDER_LINES.Add(line);
            ctx.SaveChanges();

            orderLines.Add(line.OL_ID);

            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var line = new ORDER_LINES
            {
                OL_ITEM     = (int)dataGridViewSizes.CurrentRow.Cells["iIDDataGridViewTextBoxColumn"].Value,
                OL_QUANTITY = quantity
            };

            ctx.ORDER_LINES.Add(line);
            ctx.SaveChanges();

            orderLines.Add(line.OL_ID);

            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (richTextBox1.Text != null && richTextBox1.Text != "")
            {
                var review = new REVIEWS
                {
                    R_DATE       = System.DateTime.Now,
                    R_CUSTOMERID = customer_id,
                    R_TEXT       = richTextBox1.Text
                };

                ctx.REVIEWS.Add(review);
                ctx.SaveChanges();

                this.Close();
            }
            else
            {
                MessageBox.Show("Порожній відгук не буде опубліковано!", "Увага");
                return;
            }
        }
        private async void buttonAdd_Click(object sender, EventArgs e)
        {
            if (textBoxAddress.Text == null || textBoxAddress.Text == "" ||
                textBoxCity.Text == null || textBoxAddress.Text == "")
            {
                MessageBox.Show("Заповнення усіх полів обов'язкове!", "Увага");
                return;
            }

            var store = new STORES
            {
                S_CITY    = textBoxCity.Text,
                S_ADDRESS = textBoxAddress.Text
            };

            string address = store.S_CITY + ", " + store.S_ADDRESS;

            (store.S_LATITUDE, store.S_LONGITUDE) = await LocationFromAddress(address);

            ctx.STORES.Add(store);
            ctx.SaveChanges();

            this.Close();
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            const int logo_id = 70;

            if (comboBoxCategory.Text == "" || comboBoxCategory.Text == null ||
                textBoxName.Text == "" || textBoxName.Text == null ||
                textBoxS.Text == null || textBoxS.Text == "" ||
                (comboBoxCategory.SelectedIndex == 0 && (textBoxM.Text == null || textBoxM.Text == "" ||
                                                         textBoxL.Text == null || textBoxL.Text == "")))
            {
                MessageBox.Show("Усі поля є обов'язковими для заповнення!", "Увага");
                return;
            }

            category = comboBoxCategory.Text;
            name     = textBoxName.Text;

            var item1 = new ITEMS
            {
                I_DESCRIPTION = richTextBoxDescription.Text,
                I_CATEGORY    = comboBoxCategory.Text,
                I_PRICE       = Decimal.Parse(textBoxS.Text, CultureInfo.InvariantCulture),
                I_NAME        = textBoxName.Text,
                I_IMAGE       = logo_id
            };

            if (comboBoxCategory.SelectedIndex == 0)
            {
                var item2 = new ITEMS
                {
                    I_DESCRIPTION = richTextBoxDescription.Text,
                    I_CATEGORY    = comboBoxCategory.Text,
                    I_PRICE       = Decimal.Parse(textBoxM.Text, CultureInfo.InvariantCulture),
                    I_NAME        = textBoxName.Text,
                    I_SIZE        = "M",
                    I_IMAGE       = logo_id
                };

                var item3 = new ITEMS
                {
                    I_DESCRIPTION = richTextBoxDescription.Text,
                    I_CATEGORY    = comboBoxCategory.Text,
                    I_PRICE       = Decimal.Parse(textBoxL.Text, CultureInfo.InvariantCulture),
                    I_NAME        = textBoxName.Text,
                    I_SIZE        = "L",
                    I_IMAGE       = logo_id
                };

                item1.I_SIZE = "S";

                ctx.ITEMS.Add(item2);
                ctx.ITEMS.Add(item3);
                ctx.SaveChanges();
            }

            ctx.ITEMS.Add(item1);

            try
            {
                ctx.SaveChanges();
            }
            catch (Exception)
            {
                MessageBox.Show("Помилка при додаванні нової страви!", "Увага");
                this.Close();
            }
            this.Close();
        }
Exemple #11
0
        private async void buttonOK_Click(object sender, EventArgs e)
        {
            if (comboBoxPayment.Text == null || textBoxHouse.Text == null ||
                textBoxApp.Text == null || textBoxCity.Text == null ||
                textBoxHouse.Text == "" || textBoxCity.Text == "" ||
                textBoxApp.Text == "" || comboBoxPayment.Text == "")
            {
                MessageBox.Show("Заповніть обов'язкові поля!");
                return;
            }

            var cityPresence = (from c in ctx.STORES
                                where c.S_CITY.Equals(textBoxCity.Text.Trim())
                                select c).Count();

            if (cityPresence == 0)
            {
                MessageBox.Show("На жаль, доставка Dominos в місто " + textBoxCity.Text + " неможлива!");
                return;
            }

            string address = textBoxCity.Text + ", вул. " + textBoxStreet.Text + " " + textBoxHouse.Text + " кв." + textBoxApp.Text;

            var customer = (from c in ctx.CUSTOMERS
                            where c.C_USERID == user
                            select c).First();

            var header = new ORDER_HEADERS
            {
                OH_CUSTOMER = customer.C_ID,
                OH_ADDRESS  = address,
                OH_STORE    = 1, ////////
                OH_DATE     = System.DateTime.Now,
                OH_SUM      = sum
            };

            var history_header = new HISTORY_HEADERS
            {
                HH_DATE         = System.DateTime.Now,
                HH_PAYMENT_TYPE = comboBoxPayment.Text,
                HH_CUSTOMER     = header.OH_CUSTOMER
            };

            if (comboBoxPayment.Text.Equals("Карткою онлайн"))
            {
                FormTransaction transaction = new FormTransaction(sum);
                transaction.ShowDialog(this);
                if (transaction.finished)
                {
                    history_header.HH_TRANSACTION = transaction.transaction_id;
                }
                else
                {
                    MessageBox.Show("Транзакцію не було завершено!");
                    transaction.Dispose();
                    return;
                }
                transaction.Dispose();
            }

            LoadingWindow loadingWindow = new LoadingWindow();

            loadingWindow.Show();

            int store_id = await GetNearestStore(address);

            var storeOH = (from s in ctx.STORES
                           where s.S_ID == store_id
                           select s).First();

            loadingWindow.Close();

            MessageBox.Show("Замовлення буде виконано з ресторану за адресою: \n" + storeOH.S_CITY.Trim()
                            + ", " + storeOH.S_ADDRESS);

            //FormMaps maps = new FormMaps(store_id, address);
            //maps.ShowDialog(this);
            //maps.Dispose();

            header.OH_STORE = store_id;

            ctx.ORDER_HEADERS.Add(header);
            ctx.SaveChanges();

            ctx.HISTORY_HEADERS.Add(history_header);
            ctx.SaveChanges();

            var lines = (from line in ctx.ORDER_LINES
                         where orderLines.Contains(line.OL_ID)
                         select line).ToList();

            foreach (var line in lines)
            {
                line.OL_ORDER_HEADER = header.OH_ID;

                var x = new HISTORY_LINES
                {
                    HL_ITEM         = line.OL_ITEM,
                    HL_ORDER_HEADER = history_header.HH_ID,
                    HL_QUANTITY     = line.OL_QUANTITY
                };
                ctx.HISTORY_LINES.Add(x);
                ctx.SaveChanges();
            }

            finished = true;

            MessageBox.Show("Дякуємо за покупку! \nОчікуйте СМС-повідомлення.");

            //https://control.txtlocal.co.uk/settings/apikeys/
            //settings -> API -> Create New API

            string apiKey  = "123abc"; //replace this with your ApiKey
            string number  = "+38" + customer.C_PHONE;
            string message = "Hello, it's Dominos! Your order #" + header.OH_ID + " will be delievered in an hour.";
            //"Замовлення №" + header.OH_ID + " буде доставлено протягом години. ";

            sendSMS sms    = new sendSMS();
            string  result = sms.sendMessage(apiKey, number, message);

            //MessageBox.Show(result);

            this.Close();
        }