Beispiel #1
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            initializeErrorProviders();
            InitializeLabels();
            InitializeComboboxes();
            InitializeTextBox();
            InitializeButtons();



            this.pictureBox1         = new System.Windows.Forms.PictureBox();
            this.historyDataGridView = new DataGridViewNew();
            InitializeHistoryGrid();

            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            //
            // pictureBox1
            //
            this.pictureBox1.Location = new System.Drawing.Point(13, 13);
            this.pictureBox1.Name     = "pictureBox1";
            this.pictureBox1.Size     = new System.Drawing.Size(759, 160);
            this.pictureBox1.TabIndex = 0;
            this.pictureBox1.TabStop  = false;
            pictureBox1.DoubleClick  += new EventHandler(image_DoubleClick);
            pictureBox1.SizeMode      = PictureBoxSizeMode.Zoom;

            var checkbox = new CheckboxImproved()
            {
                Location = new System.Drawing.Point(13, 465),
            };

            var _trackbar = new TrackbarImproved();
            var trackbar  = TrackbarImproved.getTrackbar();

            trackbar.ValueChanged += trackbar_ValueChanged;
            trackbar.Location      = new System.Drawing.Point(13, 405);
            setTrackbarErrors(trackbar);
            //
            // ItemForm
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor           = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
            this.ClientSize          = new System.Drawing.Size(784, 562);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(trackbar);

            this.Controls.Add(checkbox);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            this.Name            = "ItemForm";
            this.Text            = "ItemForm";
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }
Beispiel #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;
        }
Beispiel #3
0
        private void setTrackbarErrors(TrackBar something)
        {
            switch (something.Name)
            {
            case "size":
                if (something.Value < 1)
                {
                    errorProviders[6].Icon = Properties.Resources.ERR;
                    errorProviders[6].SetError(TrackbarImproved.getTrackbar(), "Nie wybrałeś warości");
                    errors[6] = false;
                }
                else
                {
                    errorProviders[6].Icon = Properties.Resources.OK;
                    errorProviders[6].SetError(TrackbarImproved.getTrackbar(), "OK");
                    errors[6] = true;
                }
                break;
            }
            try
            {
                int itemSize = 0;
                try
                {
                    itemSize = queries.getItemById(item.id_item).size;
                }
                catch { }
                var shelfCurrentSize = queries.getShelfOccupancyByShelfId((ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf).SelectedItem as Shelf).id_shelf);
                var capacity         = (ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf).SelectedItem as Shelf).capacity;
                int size             = 0;
                try
                {
                    size = TrackbarImproved.getTrackbar().Value;
                }
                catch { }

                if ((shelfCurrentSize + size - itemSize) > capacity)
                {
                    errorProviders[3].Icon = Properties.Resources.ERR;
                    errorProviders[3].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf), "Rozmiar rzeczy jest za duży");
                    errors[3] = false;
                }
                else
                {
                    errorProviders[3].Icon = Properties.Resources.OK;
                    errors[3] = true;
                }
            }
            catch { }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
        private void setComboboxesErrors(ComboBox something)
        {
            switch (something.Name)
            {
            case "room":
                if (something.SelectedItem == null || something.SelectedItem.ToString() == Utils.GetEnumDescription(ComboboxNew.actions.add))
                {
                    errorProviders[1].Icon = Properties.Resources.ERR;
                    errorProviders[1].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.room), "Nie wybrałeś pokoju");
                    errors[1] = false;
                }
                else
                {
                    errorProviders[1].Icon = Properties.Resources.OK;
                    errorProviders[1].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.room), "OK");
                    errors[1] = true;
                }
                break;

            case "wardrobe":
                if (something.SelectedItem == null || something.SelectedItem.ToString() == Utils.GetEnumDescription(ComboboxNew.actions.add))
                {
                    errorProviders[2].Icon = Properties.Resources.ERR;
                    errorProviders[2].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.wardrobe), "Nie wybrałeś szafy");
                    errors[2] = false;
                }
                else
                {
                    errorProviders[2].Icon = Properties.Resources.OK;
                    errorProviders[2].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.wardrobe), "OK");
                    errors[2] = true;
                }
                break;

            case "shelf":
                if (something.SelectedItem == null || something.SelectedItem.ToString() == Utils.GetEnumDescription(ComboboxNew.actions.add))
                {
                    errorProviders[3].Icon = Properties.Resources.ERR;
                    errorProviders[3].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf), "Nie wybrałeś półki");
                    errors[3] = false;
                }
                else
                {
                    int itemSize = 0;
                    try
                    {
                        itemSize = queries.getItemById(item.id_item).size;
                    }
                    catch { }
                    var shelfCurrentSize = queries.getShelfOccupancyByShelfId((ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf).SelectedItem as Shelf).id_shelf);
                    var capacity         = (ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf).SelectedItem as Shelf).capacity;
                    int size             = 0;
                    try
                    {
                        size = TrackbarImproved.getTrackbar().Value;
                    }
                    catch { }

                    if ((shelfCurrentSize + size - itemSize) > capacity)
                    {
                        errorProviders[3].Icon = Properties.Resources.ERR;
                        errorProviders[3].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf), "Rozmiar rzeczy jest za duży");
                        errors[3] = false;
                    }
                    else
                    {
                        errorProviders[3].Icon = Properties.Resources.OK;
                        errorProviders[3].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.shelf), "OK");
                        errors[3] = true;
                    }
                }
                break;

            case "status":
                if (something.SelectedItem == null || something.SelectedItem.ToString() == Utils.GetEnumDescription(ComboboxNew.actions.add))
                {
                    errorProviders[4].Icon = Properties.Resources.ERR;
                    errorProviders[4].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.status), "Nie wybrałeś statusu");
                    errors[4] = false;
                }
                else
                {
                    errorProviders[4].Icon = Properties.Resources.OK;
                    errorProviders[4].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.status), "OK");
                    errors[4] = true;
                }
                break;

            case "category":
                if (something.SelectedItem == null || something.SelectedItem.ToString() == Utils.GetEnumDescription(ComboboxNew.actions.add))
                {
                    errorProviders[5].Icon = Properties.Resources.ERR;
                    errorProviders[5].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.category), "Nie wybrałeś kategorii");
                    errors[5] = false;
                }
                else
                {
                    errorProviders[5].Icon = Properties.Resources.OK;
                    errorProviders[5].SetError(ComboboxesImproved.getComboboxByName(ComboboxesImproved.names.category), "OK");
                    errors[5] = true;
                }
                break;
            }
        }