Example #1
0
        // заповнюємо dataGridView даними з бази даних
        void FillDGV(DataGridView dataGridVeiw)
        {
            try
            {
                if (dataGridVeiw == DGV_Drug)
                {
                    // отримуємо таблицю drug
                    dataGridVeiw.DataSource = DrugForm.SELECTQuery();

                    // ховаємо непотрібні користовачу стопчики
                    dataGridVeiw.Columns["id"].Visible              = false;
                    dataGridVeiw.Columns["description"].Visible     = false;
                    dataGridVeiw.Columns["manufacturer_id"].Visible = false;
                    dataGridVeiw.Columns["category_id"].Visible     = false;

                    // перейменовуємо заголовки
                    dataGridVeiw.Columns["name"].HeaderText             = "Назва препарату";
                    dataGridVeiw.Columns["quantity"].HeaderText         = "Ціна (грн.)";
                    dataGridVeiw.Columns["price"].HeaderText            = "Кількість (шт.)";
                    dataGridVeiw.Columns["manufacture_date"].HeaderText = "Дата виготовлення";
                    dataGridVeiw.Columns["expiration_date"].HeaderText  = "Строк придатності до";
                    dataGridVeiw.Columns["cname"].HeaderText            = "Категорія";
                }
                else if (dataGridVeiw == DGV_Category)
                {
                    // отримуємо таблицю category
                    dataGridVeiw.DataSource = CategoryForm.SELECTQuery();

                    // ховаємо непотрібні користовачу стопчики
                    dataGridVeiw.Columns["id"].Visible = false;

                    // перейменовуємо заголовки
                    dataGridVeiw.Columns["name"].HeaderText = "Назва категорії";
                }
                else if (dataGridVeiw == DGV_Manufacturer)
                {
                    // отримуємо таблицю manufacturer
                    dataGridVeiw.DataSource = ManufacturerForm.SELECTQuery();

                    // ховаємо непотрібні користовачу стопчики
                    dataGridVeiw.Columns["id"].Visible = false;

                    // перейменовуємо заголовки
                    dataGridVeiw.Columns["name"].HeaderText         = "Назва організації";
                    dataGridVeiw.Columns["country"].HeaderText      = "Країна";
                    dataGridVeiw.Columns["address"].HeaderText      = "Адреса";
                    dataGridVeiw.Columns["phone_number"].HeaderText = "Телефонний номер";
                    dataGridVeiw.Columns["site"].HeaderText         = "Сайт";
                }
            }
            catch (Exception ex) { }
        }
Example #2
0
        // кнопка "додати"
        private void BTN_Insert_Click(object sender, EventArgs e)
        {
            if (currentDGV == DGV_Drug)
            {
                DrugForm drugForm = new DrugForm();
                drugForm.INSERTQuery();
            }
            else if (currentDGV == DGV_Category)
            {
                CategoryForm categoryForm = new CategoryForm();
                categoryForm.INSERTQuery();
            }
            else if (currentDGV == DGV_Manufacturer)
            {
                ManufacturerForm manufacturerForm = new ManufacturerForm();
                manufacturerForm.INSERTQuery();
            }

            FillDGV(currentDGV);
        }
Example #3
0
        // кнопка "змінити"
        private void BTN_Update_Click(object sender, EventArgs e)
        {
            var currentRow = currentDGV.CurrentRow;

            if (currentRow != null) // чи обран рядок
            {
                if (currentDGV == DGV_Drug)
                {
                    DrugForm drugForm = new DrugForm(currentRow.Cells["name"].Value.ToString(),
                                                     (int)currentRow.Cells["quantity"].Value,
                                                     (float)currentRow.Cells["price"].Value,
                                                     currentRow.Cells["description"].Value.ToString(),
                                                     (DateTime)currentRow.Cells["manufacture_date"].Value,
                                                     (DateTime)currentRow.Cells["expiration_date"].Value,
                                                     (int)currentRow.Cells["manufacturer_id"].Value,
                                                     (int)currentRow.Cells["category_id"].Value);
                    drugForm.UPDATEQuery((int)currentRow.Cells["id"].Value);
                }
                else if (currentDGV == DGV_Category)
                {
                    CategoryForm categoryForm = new CategoryForm(currentRow.Cells["name"].Value.ToString());
                    categoryForm.UPDATEQuery((int)currentRow.Cells["id"].Value);
                }
                else if (currentDGV == DGV_Manufacturer)
                {
                    ManufacturerForm manufacturerForm = new ManufacturerForm(currentRow.Cells["name"].Value.ToString(),
                                                                             currentRow.Cells["country"].Value.ToString(),
                                                                             currentRow.Cells["address"].Value.ToString(),
                                                                             currentRow.Cells["phone_number"].Value.ToString(),
                                                                             currentRow.Cells["site"].Value.ToString());
                    manufacturerForm.UPDATEQuery((int)currentRow.Cells["id"].Value);
                }

                FillDGV(currentDGV);
            }
        }