private async void btnSave_Click(object sender, EventArgs e) { string[] items; items = txtComponents.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); List <Task <bool> > tasks = new List <Task <bool> >(); if (items.Length > 0) { foreach (string s in items) { AbandonReason c = new AbandonReason(); c.CreatedBy = RuntimeSettings.UserId; c.CreatedOn = DateTime.Now; 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)} powodów. Dodano {res.Count(r => r)} powodów.", "Niepełne powodzenie", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show($"Dodawanie {res.Count(r => r)} powodów zakończone powodzeniem.", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("W polu tekstowym wpisz nowe powody niewykonania. Jeden powód w jednej linii!", "Nie podano komponentów", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void View(object sender, EventArgs e) { int id = Convert.ToInt32(dgItems.Rows[dgItems.CurrentCell.RowIndex].Cells[0].Value); AbandonReason item = new AbandonReason(); item = Keeper.Items.Where(u => u.AbandonReasonId == id).FirstOrDefault(); frmAbandonReason ItemForm = new frmAbandonReason(item, this); ItemForm.Show(); }
public frmAbandonReason(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 powód niewykonania"; _this = new AbandonReason(); }
public frmAbandonReason(AbandonReason 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 powodu niewykonania"; _this = Item; txtName.Text = _this.Name; 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; } }