Example #1
0
        private void btnUpdateSupplier_Click(object sender, EventArgs e)
        {
            if (Validation.IsPresent(txtSupplier, "Supplier Name", lblSuppError))
            {
                updateSupplierName(lstSupplier.SelectedItem.ToString(), txtSupplier.Text);
                gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers();
                ResetPrdSupplierPage();
                ResetProductSupllierList();
                ResetSupplierList();

                List <int>    suppupdated = SuppliersDB.GetSupplierIDs();
                List <string> supplier    = new List <string>();

                foreach (var sup in suppupdated)
                {
                    supplier.Add(SuppliersDB.GetSupplier(sup).SupName);
                }
                comboSupplier.DataSource = supplier;

                List <int>    prod    = ProductsDB.GetProductID();
                List <string> product = new List <string>();

                foreach (var prd in prod)
                {
                    product.Add(ProductsDB.GetProduct(prd).ProdName);
                }
                comboProduct.DataSource = null;
                comboProduct.DataSource = product;

                txtSupplier.Text  = "";
                lblSuppError.Text = "";
            }
        }
Example #2
0
        // Deleting Packages from Package
        private void pkgdelete_Click(object sender, EventArgs e)
        {
            Packages pkgDel = new Packages();
            Packages_Products_Suppliers pkgPrdDel = new Packages_Products_Suppliers();
            List <Packages>             pack      = PackagesDB.GetPackages();

            if (
                Validation.IsListSelected(lstPkg, "Available Packages", lblError)
                )

            {
                // delete confirmaiton message box with ok or cancel
                if (MessageBox.Show("Delete Package?", "Delete Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    lblError.Text = "";
                    foreach (var item in pack)
                    {
                        if (item.PackageId == Convert.ToInt32(txtpkgID.Text)) // txt box is one number ahead of newly added items
                        {
                            pkgDel.PackageId           = item.PackageId;
                            pkgDel.PkgName             = item.PkgName;
                            pkgDel.PkgStartDate        = item.PkgStartDate;
                            pkgDel.PkgEndDate          = item.PkgEndDate;
                            pkgDel.PkgDesc             = item.PkgDesc;
                            pkgDel.PkgBasePrice        = item.PkgBasePrice;
                            pkgDel.PkgAgencyCommission = item.PkgAgencyCommission;
                        }
                    }


                    var productSupplierid = from item in Products_SuppliersDB.GetProductsSuppliers()
                                            where item.PackageId == Convert.ToInt32(txtpkgID.Text)
                                            select new { item.ProductSupplierId };


                    Packages_Products_Suppliers pkgDelPro = new Packages_Products_Suppliers();

                    var id = productSupplierid.ToList();

                    foreach (var item in id)
                    {
                        pkgDelPro.ProductSupplierId = item.ProductSupplierId;
                    }
                    pkgDelPro.PackageId = Convert.ToInt32(txtpkgID.Text);

                    Packages_Products_SuppliersDB.DeletePackagePro(pkgDelPro);

                    PackagesDB.DeletePackage(pkgDel);
                    lstPkg.Items.Clear();

                    List <Packages> packupdatedel = PackagesDB.GetPackages();
                    foreach (var pkg in packupdatedel)
                    {
                        lstPkg.Items.Add(pkg.PkgName);
                    }

                    ResetPackage();
                }
            }
        }
Example #3
0
        public void ResetProductSupllierList()
        {
            lstPkg.Items.Clear();
            List <Packages> packupdated = PackagesDB.GetPackages();

            foreach (var pkg in packupdated)
            {
                lstPkg.Items.Add(pkg.PkgName);
            }

            lstPkg.SelectedIndex = 0;

            productSupplierList = Products_SuppliersDB.GetProductsSuppliers();
            var distinctPrd = productSupplierList.Select(o => o.ProdName).Distinct().ToList();

            comboPrdPack.DataSource  = distinctPrd;
            comboProduct.DataSource  = product;
            comboSupplier.DataSource = supplier;

            listSuppPkg.Items.Clear();
            foreach (var supname in productSupplierList)
            {
                if (supname.ProdName == comboPrdPack.SelectedItem.ToString())
                {
                    listSuppPkg.Items.Add(supname.SupName);
                }
            }
        }
Example #4
0
        private void btnDeleteProdSupplier_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Delete Product?", "Delete Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    var productSupplierID = gridProductSuppliers.CurrentRow.Cells[1].Value;
                    Products_Suppliers          itemDelete   = new Products_Suppliers();
                    Packages_Products_Suppliers pkgPrdDelete = new Packages_Products_Suppliers();

                    pkgPrdDelete.ProductSupplierId = Convert.ToInt32(productSupplierID);
                    itemDelete.ProductSupplierId   = Convert.ToInt32(productSupplierID);

                    Packages_Products_SuppliersDB.DeletePackageProSupplierByID(pkgPrdDelete);
                    Products_SuppliersDB.DeleteProductsSuppliers(itemDelete);
                    gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers();
                    ResetProductList();
                    ResetSupplierList();
                    ResetPrdSupplierPage();
                    ResetProductSupllierList();
                }
            }
            catch
            {
                MessageBox.Show("Cannot Delete at this moment as this supplied id is linked with  booking details table.Plaese select another one to delete");
            }
        }
Example #5
0
        // Editing Product_supplier table
        private void btnAddPrdSaveEdit_Click(object sender, EventArgs e)
        {
            updateProductname(gridProductSuppliers.CurrentRow.Cells[2].Value.ToString(), txtPrdSupPrdName.Text);
            updateSupplierName(gridProductSuppliers.CurrentRow.Cells[3].Value.ToString(), txtAddSupSupName.Text);

            gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers();
            ResetProductList();
            ResetSupplierList();
            ResetProductSupllierList();
            ResetPrdSupplierPage();
        }
Example #6
0
        // Adding Supplier to supplier table
        private void btnSaveAddSupp_Click(object sender, EventArgs e)
        {
            if (Validation.IsPresent(txtSupplier, "Supplier Name", lblSuppError))
            {
                Suppliers suppAdd = new Suppliers();


                List <int> supp         = SuppliersDB.GetSupplierIDs();
                var        newsuppindex = supp[supp.Count - 1] + 1;

                suppAdd.SupplierID = newsuppindex;

                suppAdd.SupName = txtSupplier.Text;

                SuppliersDB.AddSupplier(suppAdd);

                gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers();


                List <int>    suppupdated = SuppliersDB.GetSupplierIDs();
                List <string> supplier    = new List <string>();

                foreach (var sup in suppupdated)
                {
                    supplier.Add(SuppliersDB.GetSupplier(sup).SupName);
                }

                comboSupplier.DataSource = null;
                comboSupplier.DataSource = supplier;


                List <int>    prod    = ProductsDB.GetProductID();
                List <string> product = new List <string>();

                foreach (var prd in prod)
                {
                    product.Add(ProductsDB.GetProduct(prd).ProdName);
                }

                comboProduct.DataSource = null;
                comboProduct.DataSource = product;

                ResetSupplierList();
                ResetPrdSupplierPage();
                ResetProductSupllierList();

                txtSupplier.Text  = "";
                lblSuppError.Text = "";
            }
        }
Example #7
0
        private void saveProdSup_Click(object sender, EventArgs e)
        {
            ResetPrdSupplierPage();

            try
            {
                Products_Suppliers addPrdSupp = new Products_Suppliers();

                List <int> prod = ProductsDB.GetProductID();
                List <int> supp = SuppliersDB.GetSupplierIDs();

                foreach (var item in prod)
                {
                    if (comboProduct.SelectedItem.ToString() == ProductsDB.GetProduct(item).ProdName)
                    {
                        addPrdSupp.ProductId = item;
                    }
                }

                foreach (var item in supp)
                {
                    if (comboSupplier.SelectedItem.ToString() == SuppliersDB.GetSupplier(item).SupName)
                    {
                        addPrdSupp.SupplierId = item;
                    }
                }

                Products_SuppliersDB.AddProdSupplier(addPrdSupp);
                gridProductSuppliers.DataSource            = null;
                gridProductSuppliers.DataSource            = Products_SuppliersDB.GetProductsSuppliers();
                gridProductSuppliers.Columns[0].Visible    = false;
                gridProductSuppliers.Columns[1].HeaderText = "Product Supplier ID";
                gridProductSuppliers.Columns[2].HeaderText = "Product Name";
                gridProductSuppliers.Columns[3].HeaderText = "Supplier Name";
                gridProductSuppliers.Columns[1].Width      = 150;
                gridProductSuppliers.Columns[2].Width      = 300;
                gridProductSuppliers.Columns[3].Width      = 300;
                ResetProductList();
                ResetSupplierList();
                ResetPrdSupplierPage();
                ResetProductSupllierList();
            }

            catch
            {
                lblPckProdError.Text = "Same Product Supplier Already Exist";
            }
        }
Example #8
0
        // Adding Product to Product list ** Need Validation of Data
        private void btnAddSaveProd_Click(object sender, EventArgs e)
        {
            if (Validation.IsPresent(txtProductName, "Product Name", lblProdsError))
            {
                Products prodAdd = new Products();

                prodAdd.ProdName = txtProductName.Text;

                List <int>    prod    = ProductsDB.GetProductID();
                List <string> product = new List <string>();

                foreach (var prd in prod)
                {
                    product.Add(ProductsDB.GetProduct(prd).ProdName);
                }
                comboProduct.DataSource = null;
                comboProduct.DataSource = product;


                List <int>    suppupdated = SuppliersDB.GetSupplierIDs();
                List <string> supplier    = new List <string>();

                foreach (var sup in suppupdated)
                {
                    supplier.Add(SuppliersDB.GetSupplier(sup).SupName);
                }

                comboSupplier.DataSource = null;
                comboSupplier.DataSource = supplier;

                ProductsDB.AddProduct(prodAdd);

                gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers();
                ResetProductList();
                ResetPrdSupplierPage();
                ResetProductSupllierList();

                txtProductName.Text = "";
                lblProdsError.Text  = "";
            }
        }