Ejemplo n.º 1
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            frmPackageAddModify secondFrm = new frmPackageAddModify();

            secondFrm.isModify = true;
            int rowNum = Convert.ToInt32(packageDataGridView.CurrentCell.RowIndex);
            int packId = Convert.ToInt32(packageDataGridView["dataGridViewTextBoxColumn1", rowNum].Value);

            using (DataClasses1DataContext dbContext = new DataClasses1DataContext())
            {
                secondFrm.currentPackage = (from p in dbContext.Packages
                                            where p.PackageId == packId
                                            select p).Single();
            }

            DialogResult result = secondFrm.ShowDialog();

            using (DataClasses1DataContext dbContext = new DataClasses1DataContext())
            {
                if (result == DialogResult.OK)                           // successful Modify
                {
                    packageDataGridView.DataSource = dbContext.Packages; // refresh grid
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmPackageAddModify secondFrm = new frmPackageAddModify();

            DialogResult result = secondFrm.ShowDialog();

            using (DataClasses1DataContext dbContext = new DataClasses1DataContext())
            {
                if (result == DialogResult.OK)                           // successful Add
                {
                    packageDataGridView.DataSource = dbContext.Packages; // refresh grid
                }
            }
        }