Beispiel #1
0
        private void OnAdd()
        {
            dlgAddBranch dlg = new dlgAddBranch();

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                DataTable dt  = dgBranch.DataSource as DataTable;
                DataRow   row = dt.NewRow();
                row["BranchKey"]  = dlg.BranchKey;
                row["BranchName"] = dlg.BranchName;
                row["Address"]    = dlg.Address;
                row["Telephone"]  = dlg.Telephone;
                row["Fax"]        = dlg.Fax;
                row["Website"]    = dlg.Website;
                row["Note"]       = dlg.Notes;
                dt.Rows.Add(row);
                dgBranch.Rows[dgBranch.RowCount - 1].Selected = true;
            }
        }
Beispiel #2
0
        private void OnEdit()
        {
            if (dgBranch.SelectedRows == null || dgBranch.SelectedRows.Count <= 0)
            {
                MessageBox.Show("Please select one branch.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataRow      dataRow = (dgBranch.SelectedRows[0].DataBoundItem as DataRowView).Row;
            dlgAddBranch dlg     = new dlgAddBranch(dataRow);

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                dataRow["BranchName"] = dlg.BranchName;
                dataRow["Address"]    = dlg.Address;
                dataRow["Telephone"]  = dlg.Telephone;
                dataRow["Fax"]        = dlg.Fax;
                dataRow["Website"]    = dlg.Website;
                dataRow["Note"]       = dlg.Notes;
            }
        }