Пример #1
0
        private bool nameValidation()
        {
            bool check = false;
            var  text  = TextboxesNames.getTextBoxByName(TextboxesNames.names.name).Text;

            if (text.Length >= 3)
            {
                check = true;
            }

            return(check);
        }
Пример #2
0
        private void fillForm()
        {
            var textbox = TextboxesNames.getTextBoxByName(TextboxesNames.names.name);

            textbox.Text = (item != null) ? item.name : null;
            setTextboxesErrors(textbox);

            textbox      = TextboxesNames.getTextBoxByName(TextboxesNames.names.description);
            textbox.Text = (item != null) ? item.description : null;

            var combo = ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.category);

            combo.SelectedItem = (item != null) ? queries.getCategoryById(item.id_category) : null;
            setComboboxesErrors(combo);

            combo = ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.room);
            combo.SelectedItem = (item != null) ? queries.getRoomByShelfId(item.id_shelf) : null;
            setComboboxesErrors(combo);

            combo = ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.wardrobe);
            combo.SelectedItem = (item != null) ? queries.getWardrobeByShelfId(item.id_shelf) : null;
            setComboboxesErrors(combo);

            combo = ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf);
            combo.SelectedItem = (item != null) ? queries.getShelfById(item.id_shelf) : null;
            setComboboxesErrors(combo);

            combo = ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.status);
            combo.SelectedItem = (item != null) ? queries.getStatusById(item.id_status) : null;
            setComboboxesErrors(combo);

            var trackbar = TrackbarImproved.getTrackbar();

            trackbar.Value = (item != null) ? item.size : 0;
            setTrackbarErrors(trackbar);

            if (item != null && item.image != null)
            {
                pictureBox1.Image = Classes.ImageConverter.dbImgaeToImage(item.image);
                oryginalImage     = (Bitmap)pictureBox1.Image;
                var button = ButtonsImproved.getList().Find(x => x.Name == ButtonsImproved.names.image_delete.ToString());
                button.Enabled = true;
            }
            else
            {
                var button = ButtonsImproved.getList().Find(x => x.Name == ButtonsImproved.names.image_delete.ToString());
                button.Enabled    = false;
                pictureBox1.Image = null;
                oryginalImage     = null;
            }
            fillHistoryGrid(historyDataGridView);
            //this.checkBox1.Checked = item.deleted ? false : true;
        }
Пример #3
0
        private void InitializeTextBox()
        {
            var textboxes = new TextboxesNames();
            var k         = 0;

            foreach (var item in textboxes.getList())
            {
                item.Location     = new System.Drawing.Point(13, 225 + 60 * k);
                item.Width        = 200;
                item.TextChanged += textBoxOut_TextChanged;
                if (item.Name.ToUpper() == TextboxesNames.names.description.ToString().ToUpper())
                {
                    item.Height = 80;
                }
                k++;
                Controls.Add(item);
                setTextboxesErrors(item);
            }
        }
Пример #4
0
 private void setTextboxesErrors(TextBox something)
 {
     switch (something.Name)
     {
     case "name":
         if (something.TextLength < 3)
         {
             errorProviders[0].Icon = Properties.Resources.ERR;
             errorProviders[0].SetError(TextboxesNames.getTextBoxByName(TextboxesNames.names.name), "Podpis musi mieć więcej niż 3 znaki!");
             errors[0] = false;
         }
         else
         {
             errorProviders[0].Icon = Properties.Resources.OK;
             errorProviders[0].SetError(TextboxesNames.getTextBoxByName(TextboxesNames.names.name), "OK");
             errors[0] = true;
         }
         break;
     }
 }
Пример #5
0
        private void save_Click(object sender, EventArgs e)
        {
            AddItem addItem;

            if (item != null)
            {
                addItem = new AddItem(item);
            }
            else
            {
                addItem = new AddItem();
            }

            if (checkIfSave())
            {
                addItem.setActive(false);
                addItem.setName(TextboxesNames.getTextBoxByName(TextboxesNames.names.name).Text);
                addItem.setStatus(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.status).SelectedItem as Status);
                addItem.setShelf(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf).SelectedItem as Shelf);
                addItem.setCategory(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.category).SelectedItem as Category);
                addItem.setSize(TrackbarImproved.getTrackbar().Value);
                addItem.setImage(oryginalImage);

                var desc = TextboxesNames.getTextBoxByName(TextboxesNames.names.description).Text;
                if (desc != null)
                {
                    addItem.setDescription(desc);
                }
                item = addItem.save();
                fillForm();
            }
            else
            {
                MessageBox.Show(Utils.GetEnumDescription(Messages.errors.SAVE), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }