コード例 #1
0
        //ДОБАВЛЕНИЕ
        private void Button_add_Click(object sender, RoutedEventArgs e)
        {
            switch (current_table)
            {
            case Tables.requests:
                WindowRequests wrequest = new WindowRequests(QueryMode.add, this);
                wrequest.Show();
                break;

            case Tables.cars:
                WindowCars wcar = new WindowCars(QueryMode.add, this);
                wcar.Show();
                break;

            case Tables.clients:
                WindowClients wclient = new WindowClients(QueryMode.add, this);
                wclient.Show();
                break;
            }
        }
コード例 #2
0
        //ИЗМЕНЕНИЕ
        private void Button_change_Click(object sender, RoutedEventArgs e)
        {
            object item = DataGrid.SelectedItem;

            if (item != null)
            {
                string item_name;
                switch (current_table)
                {
                case Tables.requests:
                    if (((Request)item).request_status == "Обработано")
                    {
                        MessageBox.Show("Нельзя изменить обработанную заявку!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    item_name = ((Request)item).id.ToString();
                    WindowRequests wrequest = new WindowRequests(QueryMode.change, this, item_name);
                    wrequest.Show();
                    break;

                case Tables.cars:
                    item_name = ((Car)item).vin;
                    WindowCars wcar = new WindowCars(QueryMode.change, this, item_name);
                    wcar.Show();
                    break;

                case Tables.clients:
                    item_name = ((Client)item).mail.ToString();
                    WindowClients wclient = new WindowClients(QueryMode.change, this, item_name);
                    wclient.Show();
                    break;
                }
            }
            else
            {
                MessageBox.Show("Выберите мышью запись перед изменением.");
            }
        }
コード例 #3
0
        //ДОБАВЛЕНИЕ
        private void Button_add_Click(object sender, RoutedEventArgs e)
        {
            switch (current_table)
            {
            case Tables.genders:
            case Tables.cities:
            case Tables.measurements:
            case Tables.request_statuses:
            case Tables.roles:
            case Tables.service_types:
                DictionaryWindow dw = new DictionaryWindow(QueryMode.add,
                                                           ru_tables[(int)current_table],
                                                           tables[(int)current_table],
                                                           fields[current_primary_key_name],
                                                           current_primary_key_name,
                                                           this);
                dw.Show();
                break;

            case Tables.cars:
                WindowCars wcar = new WindowCars(QueryMode.add, this);
                wcar.Show();
                break;

            case Tables.clients:
                WindowClients wclient = new WindowClients(QueryMode.add, this);
                wclient.Show();
                break;

            case Tables.colors:
                WindowColors wcolor = new WindowColors(QueryMode.add, this);
                wcolor.Show();
                break;

            case Tables.paint_types:
                WindowPaint_types wpt = new WindowPaint_types(QueryMode.add, this);
                wpt.Show();
                break;

            case Tables.pictures:
                WindowPictures wpic = new WindowPictures(QueryMode.add, this);
                wpic.Show();
                break;

            case Tables.products: WindowProducts wproduct = new WindowProducts(QueryMode.add, this);
                wproduct.Show();
                break;

            case Tables.requests: WindowRequests wrequest = new WindowRequests(QueryMode.add, this);
                wrequest.Show();
                break;

            case Tables.storage: WindowStorage wstor = new WindowStorage(QueryMode.add, this);
                wstor.Show();
                break;

            case Tables.suppliers: WindowSuppliers wsupplier = new WindowSuppliers(QueryMode.add, this);
                wsupplier.Show();
                break;

            case Tables.supplies: WindowSupplies wsupply = new WindowSupplies(QueryMode.add, this);
                wsupply.Show();
                break;

            case Tables.users: WindowUsers wuser = new WindowUsers(QueryMode.add, this);
                wuser.Show();
                break;
            }
        }
コード例 #4
0
        //ИЗМЕНЕНИЕ
        private void Button_change_Click(object sender, RoutedEventArgs e)
        {
            object item = DataGrid.SelectedItem;

            if (item != null)
            {
                if (current_table == Tables.measurements)
                {
                    switch (((Measurement)item).measurement)
                    {
                    case "литр":
                    case "рулон":
                        MessageBox.Show("Вы не можете изменять записи, используемые в системе.");
                        return;
                    }
                }
                if (current_table == Tables.request_statuses)
                {
                    switch (((Request_status)item).request_status)
                    {
                    case "Обработано":
                    case "Ожидает обработки":
                        MessageBox.Show("Вы не можете изменять записи, используемые в системе.");
                        return;
                    }
                }
                if (current_table == Tables.roles)
                {
                    switch (((Role)item).role)
                    {
                    case "администратор":
                    case "менеджер по заявкам":
                    case "менеджер по поставкам":
                        MessageBox.Show("Вы не можете изменять записи, используемые в системе.");
                        return;
                    }
                }
                if (current_table == Tables.service_types)
                {
                    switch (((Service_type)item).service_type)
                    {
                    case "Аэрография":
                    case "Детальная":
                    case "Оклейка плёнкой":
                    case "Полная":
                        MessageBox.Show("Вы не можете изменять записи, используемые в системе.");
                        return;
                    }
                }
                string item_name = primary_key_values[DataGrid.Items.IndexOf(item)];
                switch (current_table)
                {
                case Tables.genders:
                case Tables.cities:
                case Tables.measurements:
                case Tables.request_statuses:
                case Tables.roles:
                case Tables.service_types:
                case Tables.paint_types:
                    DictionaryWindow dw = new DictionaryWindow(QueryMode.change,
                                                               ru_tables[(int)current_table],
                                                               tables[(int)current_table],
                                                               fields[current_primary_key_name],
                                                               current_primary_key_name,
                                                               this, item_name);
                    dw.Show();
                    break;

                case Tables.car_parts:
                    WindowCarParts wcp = new WindowCarParts(this, item_name);
                    wcp.Show();
                    break;

                case Tables.cars:
                    WindowCars wcar = new WindowCars(QueryMode.change, this, item_name);
                    wcar.Show();
                    break;

                case Tables.clients:
                    WindowClients wclient = new WindowClients(QueryMode.change, this, item_name);
                    wclient.Show();
                    break;

                case Tables.colors:
                    WindowColors wcolor = new WindowColors(QueryMode.change, this, item_name);
                    wcolor.Show();
                    break;

                /*case Tables.paint_types: WindowPaint_types wpt = new WindowPaint_types(QueryMode.change, this, item_name);
                 *      wpt.Show();
                 *      break;*/
                case Tables.pictures: WindowPictures wpic = new WindowPictures(QueryMode.change, this, item_name);
                    wpic.Show();
                    break;

                case Tables.products: WindowProducts wproduct = new WindowProducts(QueryMode.change, this, item_name);
                    wproduct.Show();
                    break;

                case Tables.requests: WindowRequests wrequest = new WindowRequests(QueryMode.change, this, item_name);
                    wrequest.Show();
                    break;

                case Tables.storage: WindowStorage wstor = new WindowStorage(QueryMode.change, this, item_name);
                    wstor.Show();
                    break;

                case Tables.suppliers: WindowSuppliers wsupplier = new WindowSuppliers(QueryMode.change, this, item_name);
                    wsupplier.Show();
                    break;

                case Tables.supplies: WindowSupplies wsupply = new WindowSupplies(QueryMode.change, this, item_name);
                    wsupply.Show();
                    break;

                case Tables.users: WindowUsers wuser = new WindowUsers(QueryMode.change, this, item_name);
                    wuser.Show();
                    break;
                }
            }
            else
            {
                MessageBox.Show("Выберите мышью запись перед изменением.");
            }
        }