Пример #1
0
        private void btnAddPackage_Click(object sender, EventArgs e)
        {
            var addEditPackage = new AddEditPackage(this);

            addEditPackage.MdiParent = this.MdiParent;
            addEditPackage.Show();
        }
        private void addPackagesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var addPackage = new AddEditPackage
            {
                MdiParent = this
            };

            addPackage.Show();
        }
        //Click this to edit a package
        private void btnEditPackage_Click(object sender, EventArgs e)
        {
            try
            {
                var packageId = (int)dgvPackages.CurrentRow.Cells[0].Value;

                var package = _db.Packages.Where(p => p.PackageId == packageId).FirstOrDefault();

                AddEditPackage frmAddpackage = new AddEditPackage(package, this);
                frmAddpackage.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }
Пример #4
0
        private void btnEditPackage_Click(object sender, EventArgs e)
        {
            try
            {
                //which row is selected
                var id = Convert.ToString(gvPackageList.CurrentRow.Cells[0].Value);
                //var id = (int)gvPackageList.CurrentRow.Cells[0].Value; //it is the same

                //query database for record
                var package = _db.Packages.FirstOrDefault(p => p.PkgName == id);

                //launch AddEditProduct window with Data
                var addEditPackage = new AddEditPackage(package, this);
                addEditPackage.MdiParent = this.MdiParent;
                addEditPackage.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }
        //Click this to Add a Package
        private void btnAddPackage_Click(object sender, EventArgs e)
        {
            AddEditPackage frmAddpackage = new AddEditPackage(managePackageListing: this);

            frmAddpackage.ShowDialog();
        }