Ejemplo n.º 1
0
        //add packages, based on the criteria
        private void btnAddPackage_Click_1(object sender, EventArgs e)
        {
            if (validaterClass.isProvided(txtPkgName, "Package Name can not be null") &&
                (validaterClass.validateDate(Convert.ToDateTime(dtPkgStartDate.Text), Convert.ToDateTime(dtPkgEndDate.Text)) &&
                 (validaterClass.isProvided(txtPkgDesc, "Package Description can not be null")) &&
                 (validaterClass.isProvided(txtPkgBasePrice, "Package Base Price can not be null")) &&
                 (validaterClass.isNonNegativeDoub(txtPkgBasePrice, "Package Price must be a Positive Whole number")) &&
                 (validaterClass.isProvided(txtPkgComision, "Agency Comm can not be null")) &&
                 (validaterClass.isNonNegativeDoub(txtPkgComision, "Agency Comm must be a positive whole number") &&
                  (validaterClass.isValidateComm(txtPkgBasePrice, txtPkgComision)))))
            {
                try
                {
                    PackageDB addPkgObj     = new PackageDB();
                    string    pkgName       = Convert.ToString(txtPkgName.Text);
                    DateTime  pkgStartDate  = Convert.ToDateTime(dtPkgStartDate.Text);
                    DateTime  pkgEndDate    = Convert.ToDateTime(dtPkgEndDate.Text);
                    string    pkgDesc       = Convert.ToString(txtPkgDesc.Text);
                    decimal   pkgBasePrice  = Convert.ToDecimal(txtPkgBasePrice.Text);
                    decimal   pkgAgencyComm = Convert.ToDecimal(txtPkgComision.Text);

                    addPkgObj.addPackage(pkgName, pkgStartDate, pkgEndDate, pkgDesc, pkgBasePrice, pkgAgencyComm);
                    if (addPkgObj.FillDataGrid())
                    {
                        pkgDataGrid.DataSource = addPkgObj.dt;
                    }
                }
                catch (OverflowException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                Clear_Form();
            }
        }