예제 #1
0
        // STEP 6
        private void btnAddPkg_Click(object sender, EventArgs e)
        {
            package pkg = new package();

            if (Validator.IsPresent(txtBoxPkgName) && Validator.IsPresent(txtBoxPkgDesc) &&
                Validator.IsPresent(txtBoxBasePrice) && Validator.IsPresent(txtBoxAgencyCommission) &&
                //Validator.IsDecimal(txtBoxBasePrice)&& Validator.IsDecimal(txtBoxAgencyCommission)&&
                Validator.CompareValues(txtBoxAgencyCommission, txtBoxBasePrice) && Validator.CompareDates(dTPkrPkgStart.Value, dTPkrPkgEnd.Value))
            {
                ;
            }
            {
                int add;
                pkg.PkgName             = txtBoxPkgName.Text.ToString();
                pkg.PkgStartDate        = Convert.ToString(dTPkrPkgStart.Value);
                pkg.PkgEndDate          = Convert.ToString(dTPkrPkgEnd.Value);
                pkg.PkgDesc             = txtBoxPkgDesc.Text.ToString();
                pkg.PkgBasePrice        = txtBoxBasePrice.Text;
                pkg.PkgAgencyCommission = txtBoxAgencyCommission.Text;


                add = PackagesDB.AddPackage(pkg);

                List <package> packageS = new List <package>();
                packageS = PackagesDB.GetPackages();

                dataGridView1.DataSource = packageS;

                MessageBox.Show("Package was added!");
            }
        }
예제 #2
0
        // STEP 3



        // STEP 4
        public void GetPackage(int PackageId)
        {
            try
            {
                package pkg = PackagesDB.GetPackage(PackageId);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
예제 #3
0
        // STEP 7
        private void btnSvPkg_Click(object sender, EventArgs e)
        {
            if (Validator.IsPresent(txtBoxPkgName) && Validator.IsPresent(txtBoxPkgDesc) &&
                Validator.IsPresent(txtBoxBasePrice) && Validator.IsPresent(txtBoxAgencyCommission) &&
                // Validator.IsDecimal(txtBoxBasePrice) && Validator.IsDecimal(txtBoxAgencyCommission) &&
                Validator.CompareValues(txtBoxAgencyCommission, txtBoxBasePrice) && Validator.CompareDates(dTPkrPkgStart.Value, dTPkrPkgEnd.Value))
            {
                int oldId = Convert.ToInt32(cboPackageId.SelectedValue.ToString());

                package oldpkg = PackagesDB.GetPackage(oldId);
                package newpkg = new package();

                bool update;

                int newID = Convert.ToInt32(cboPackageId.SelectedValue.ToString());
                newpkg.PackageId = newID;

                string name = txtBoxPkgName.Text.ToString();
                newpkg.PkgName = name;

                DateTime start = Convert.ToDateTime(dTPkrPkgStart.Value.ToString());
                newpkg.PkgStartDate = Convert.ToString(start);

                DateTime end = Convert.ToDateTime(dTPkrPkgEnd.Value.ToString());
                newpkg.PkgEndDate = Convert.ToString(end);

                string desc = txtBoxPkgDesc.Text.ToString();
                newpkg.PkgDesc = desc;

                decimal basePrice = decimal.Parse(txtBoxBasePrice.Text.ToString(), NumberStyles.Currency);
                newpkg.PkgBasePrice = Convert.ToString(basePrice);

                decimal commission = decimal.Parse(txtBoxAgencyCommission.Text.ToString(), NumberStyles.Currency);
                newpkg.PkgAgencyCommission = Convert.ToString(commission);



                update = PackagesDB.UpdatePackage(oldpkg, newpkg);
                this.GetPackage(newID);
                this.tabselection();
                List <package> packageS = new List <package>();
                packageS = PackagesDB.GetPackages();



                dataGridView1.DataSource = packageS;

                MessageBox.Show("Package was updated!");
            }
        }
예제 #4
0
        // STEP 5
        public void load_table()
        {
            try
            {
                List <package> packageS = new List <package>();
                packageS = PackagesDB.GetPackages();

                var source = new BindingSource(packages, null);

                dataGridView1.DataSource = source;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
예제 #5
0
 private void cboPkgPPS_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboPkgPPS.SelectedIndex != 0)
     {
         int     pacnum = (int)cboPkgPPS.SelectedValue;
         package coco   = new package();
         coco = PackagesDB.GetPackage(pacnum);
         lstPackageInfo.Items.Clear();
         lstPackageInfo.Items.Add(coco.PackageId + " " + coco.PkgName + " " + coco.PkgDesc + " " + coco.PkgBasePrice + " " + coco.PkgAgencyCommission);
     }
     else
     {
         package coco = new package();
         coco = PackagesDB.GetPackage(1);
         lstPackageInfo.Items.Clear();
         lstPackageInfo.Items.Add(coco.PackageId + " " + coco.PkgName + " " + coco.PkgDesc + " " + coco.PkgBasePrice + " " + coco.PkgAgencyCommission);
     }
 }
예제 #6
0
        private void packageLoad(object sender, EventArgs e)
        {
            int ID = (cboPackageId.SelectedIndex);

            ID = ID + 1;
            package pkg3 = PackagesDB.GetPackage(ID);

            txtBoxPkgName.Text          = pkg3.PkgName;
            dTPkrPkgStart.Value         = Convert.ToDateTime(pkg3.PkgStartDate);
            dTPkrPkgEnd.Value           = Convert.ToDateTime(pkg3.PkgEndDate);
            txtBoxPkgDesc.Text          = pkg3.PkgDesc;
            txtBoxBasePrice.Text        = pkg3.PkgBasePrice;
            txtBoxAgencyCommission.Text = pkg3.PkgAgencyCommission;


            // int PackageId = Convert.ToInt32(cboPackageId.SelectedValue.ToString());
            this.GetPackage(ID);
            this.load_table();
        }
예제 #7
0
        private void btnDeletePack_Click(object sender, EventArgs e)
        {
            int ps;

            ps = ((int)cboPackageId.SelectedValue);

            bool           logic    = PackagesDB.Delete(ps);
            List <package> packageS = new List <package>();

            packageS = PackagesDB.GetPackages();

            dataGridView1.DataSource   = packageS;
            cboPackageId.SelectedIndex = 0;

            if (logic == true)
            {
                MessageBox.Show("You have Deleted the Package !");
            }
            else
            {
                MessageBox.Show("Delete Package from Products Packages table first!");
            }
        }
예제 #8
0
 // STEP 2
 public void GetPackages()
 {
     try
     {
         packages = PackagesDB.GetPackages();
         cboPackageId.DataSource    = packages;
         cboPackageId.DisplayMember = "PackageId";
         cboPackageId.ValueMember   = "PackageId";
         packages2               = PackagesDB.GetPackages();
         cboPkgPPS.DataSource    = packages2;
         cboPkgPPS.DisplayMember = "PackageId";
         cboPkgPPS.ValueMember   = "PackageId";
         List <ProductsSuppliers> productssupplierid = new List <ProductsSuppliers>();
         productssupplierid     = ProductSupplierIdDB.GetProductsSupplierId();
         cboPSPPS.DataSource    = productssupplierid;
         cboPSPPS.DisplayMember = "ProductSupplierId";
         cboPSPPS.ValueMember   = "ProductSupplierId";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }