예제 #1
0
파일: Form1.cs 프로젝트: wolf99/PlantHire
        private void UpdateHirer_Click(object sender, EventArgs e)
        {
            // Create and populate a new Hirer object
            var h = new Hirer()
            {
                Code       = HirerCode.Text,
                Name       = HirerName.Text,
                AddressLn1 = HirerAddressLn1.Text,
                AddressLn2 = HirerAddressLn2.Text,
                AddressLn3 = HirerAddressLn3.Text,
                AddressLn4 = HirerAddressLn4.Text,
                AddressLn5 = HirerAddressLn5.Text
            };

            // Get indes of selected item to update
            var i = HirerDataGridView.SelectedRows[0].Index;

            // Update the item on the binding source
            var l = (SortableBindingList <Hirer>)Hirers.DataSource;

            l[i] = h;
            Hirers.DataSource = l;

            // Save the changes to file
            UpdateCsvFile <Hirer>(l.ToList(), HirerCsvPath);
        }
예제 #2
0
파일: Form1.cs 프로젝트: wolf99/PlantHire
        private void AddHirer_Click(object sender, EventArgs e)
        {
            // Create and populate a new Hirer object
            var h = new Hirer()
            {
                Code       = HirerCode.Text,
                Name       = HirerName.Text,
                AddressLn1 = HirerAddressLn1.Text,
                AddressLn2 = HirerAddressLn2.Text,
                AddressLn3 = HirerAddressLn3.Text,
                AddressLn4 = HirerAddressLn4.Text,
                AddressLn5 = HirerAddressLn5.Text,
            };

            // Add the new object to the Binding source
            // This causes the RowsAdded event to be raised
            Hirers.Add(h);
            // Save the change to file
            UpdateCsvFile <Hirer>(((SortableBindingList <Hirer>)Hirers.DataSource).ToList(), HirerCsvPath);
        }