private void View(object sender, EventArgs e)
        {
            int       id   = Convert.ToInt32(dgItems.Rows[dgItems.CurrentCell.RowIndex].Cells[0].Value);
            Component item = new Component();

            item = Keeper.Items.Where(u => u.ComponentId == id).FirstOrDefault();
            frmComponent ItemForm = new frmComponent(item, this);

            ItemForm.Show();
        }
Beispiel #2
0
 public frmComponent(Form parent)
 {
     InitializeComponent();
     this.Owner              = parent;
     this.Location           = new Point(this.Owner.Location.X + 20, this.Owner.Location.Y + 20);
     mode                    = 1;
     lblCreated.Visible      = false;
     cboxArchived.CheckState = CheckState.Indeterminate;
     this.Text               = "Nowy komponent";
     _this                   = new Component();
 }
Beispiel #3
0
 public frmComponent(Component Item, Form parent)
 {
     InitializeComponent();
     this.Owner              = parent;
     this.Location           = new Point(this.Owner.Location.X + 20, this.Owner.Location.Y + 20);
     mode                    = 2;
     this.Text               = "Szczegóły komponentu";
     _this                   = Item;
     txtName.Text            = _this.Name;
     txtDescription.Text     = _this.Description;
     cboxArchived.CheckState = _this.IsArchived.ToCheckboxState();
     if (_this.CreatedOn != null && _this.CreatedBy != 0)
     {
         lblCreated.Text    = "Utworzone w dniu " + _this.CreatedOn + " przez " + _this.CreatedByName;
         lblCreated.Visible = true;
     }
 }
Beispiel #4
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            PlaceId = cmbPlace.GetSelectedValue <Place>();
            if (PlaceId == null || PlaceId == 0)
            {
                MessageBox.Show("Z listy rozwijanej wybierz zasób, dla którego chcesz utworzyć komponenty.", "Nie wybrano zasobu", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string[] components;
                components = txtComponents.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                List <Task <bool> > tasks = new List <Task <bool> >();
                if (components.Length > 0)
                {
                    foreach (string s in components)
                    {
                        Component c = new Component();
                        c.CreatedBy = RuntimeSettings.UserId;
                        c.CreatedOn = DateTime.Now;
                        c.PlaceId   = PlaceId;
                        c.Name      = s;
                        tasks.Add(c.Add());
                    }

                    string             response = "";
                    IEnumerable <bool> res      = await Task.WhenAll <bool>(tasks);

                    if (res.Where(r => r == false).Any())
                    {
                        MessageBox.Show($"Nie udało się dodać {res.Count(r => r == false)} komponentów. Dodano {res.Count(r => r)} komponentów.", "Niepełne powodzenie", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show($"Dodawanie {res.Count(r => r)} komponentów zakończone powodzeniem.", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("W polu tekstowym wpisz nazwy komponentów dla tego zasobu. Jeden komponent w jednej linii!", "Nie podano komponentów", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }