Пример #1
0
 private void btn_Edit_Click(object sender, EventArgs e)
 {
     if (dGVItemInfo.SelectedRows.Count > 0)
     {
         var i = dGVItemInfo.SelectedRows[0].Cells[0].Value.ToString().Trim();
         if (lst != null && lst.Count > 0)
         {
             var         oneItem = lst.Find(x => x.SKU == i);
             FormAddItem f       = new FormAddItem(oneItem);
             f.ShowDialog();
             if (f.item != null)
             {
                 var editOne = lst.Find(c => c.SKU == f.item.SKU);
                 try
                 {
                     lst.Remove(editOne);
                 }
                 catch (Exception)
                 {
                 }
                 lst.Add(f.item);
                 dGVItemInfo.DataSource = null;
                 dGVItemInfo.DataSource = lst;
             }
         }
     }
 }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormAddItem f = new FormAddItem();

            f.ShowDialog();
            if (f.item != null)
            {
                lst.Add(f.item);
                dGVItemInfo.DataSource = null;
                dGVItemInfo.DataSource = lst;
            }
        }