示例#1
0
 private void btnSaveAll_Click(object sender, EventArgs e)
 {
     try
     {
         List <Stock> stks = new List <Stock>();
         foreach (DataGridViewRow row in grdViewStock.Rows)
         {
             Stock stk = row.DataBoundItem as Stock;
             stk.CurrentDate = DateTime.Now;
             stks.Add(stk);
         }
         _repository.SaveAllStocks(stks);
         MessageBox.Show("All Stock Add Successfully", "Add...", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ClearAll();
         BindingList <Stock> newlist = new BindingList <Stock>();
         grdViewStock.DataSource = newlist;
         lblNoInStock.Text       = Convert.ToString(_repository.GetNumberInStock(Convert.ToInt32(cmbInventory.SelectedValue)));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }