Exemplo n.º 1
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            bool isInputCorrect = this.isInputCorrect();

            if (isInputCorrect)
            {
                Package p = ppda.getOneProductPackageByID(packageIdTextBox.Text, Language.getLanguageCode(), conn);
                p.setProductNameEnUs(englishNameTextBox.Text);
                p.setProductNameZhHant(tChineseNameTextBox.Text);
                p.setDescriptionEnUs(engDescTextBox.Text);
                p.setDescriptionZhHant(tChiDescTextBox.Text);
                p.setPhoto(productPhotoBox.Image);
                p.setSupplierID(supplierID);
                p.setQtyInStock(int.Parse(quantityTextBox.Text));
                p.setPrice(int.Parse(priceTextBox.Text));

                int i = ppda.update(p, conn);
                if (i > 0)
                {
                    foreach (DataGridViewRow row in packageListDataGridView.Rows)
                    {
                        if (packageIdTextBox.Text.Equals(row.Cells["packageIdColumn"].Value.ToString()))
                        {
                            row.Cells["engNameColumn"].Value         = englishNameTextBox.Text;
                            row.Cells["tChiNameColumn"].Value        = tChineseNameTextBox.Text;
                            row.Cells["engDescriptionColumn"].Value  = engDescTextBox.Text;
                            row.Cells["tChiDescriptionColumn"].Value = tChiDescTextBox.Text;
                            row.Cells["quantityColumn"].Value        = quantityTextBox.Text;
                            row.Cells["priceColumn"].Value           = rs.GetString("hkdText") + priceTextBox.Text;
                        }
                    }

                    showedStockAlertPackage.Remove(p.getProductID());
                    setting.Save();

                    productList.Clear();
                    productList = null;
                    productList = ppda.findProductPackagesBySupplierID(supplierID, Language.getLanguageCode(), conn);

                    MessageBox.Show(rs.GetString("updateProductSuccessMsg"));
                }
                else
                {
                    MessageBox.Show(rs.GetString("updateProductFailMsg"), rs.GetString("errorText"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        private void approvalButton_Click(object sender, EventArgs e)
        {
            bool qtyBelow50 = false;

            if (!qtyBelow50)
            {
                Package package = ppgda.getOneProductPackageByID(packageOl.getProductID(), Language.getLanguageCode(), conn);
                if (package.getQtyInStock() < 1)
                {
                    qtyBelow50 = true;
                }
            }

            if (!qtyBelow50)
            {
                Bottle bottle = pbda.getOneProductBottleByID(bottleOl.getProductID(), Language.getLanguageCode(), conn);
                if (bottle.getQtyInStock() < 1)
                {
                    qtyBelow50 = true;
                }
            }

            if (!qtyBelow50)
            {
                foreach (OrderLine perfumeOl in perfumeOlList)
                {
                    Perfume perfume = ppda.getOneProductPerfumeByID(perfumeOl.getProductID(), Language.getLanguageCode(), conn);
                    if (perfume.getQtyInStock() < 50)
                    {
                        qtyBelow50 = true;
                        break;
                    }
                }
            }

            if (qtyBelow50)
            {
                rejectButton_Click(null, null);
            }
            else
            {
                Package package = ppgda.getOneProductPackageByID(packageOl.getProductID(), Language.getLanguageCode(), conn);
                package.setQtyInStock(package.getQtyInStock() - 1);
                ppgda.update(package, conn);

                Bottle bottle = pbda.getOneProductBottleByID(bottleOl.getProductID(), Language.getLanguageCode(), conn);
                bottle.setQtyInStock(bottle.getQtyInStock() - 1);
                pbda.update(bottle, conn);

                foreach (OrderLine perfumeOl in perfumeOlList)
                {
                    Perfume perfume = ppda.getOneProductPerfumeByID(perfumeOl.getProductID(), Language.getLanguageCode(), conn);
                    perfume.setQtyInStock(perfume.getQtyInStock() - perfumeOl.getQty());
                    ppda.update(perfume, conn);
                }

                productCategoriesComboBox_SelectedIndexChanged(null, null);

                orderDetail.setApprovedDate(DateTime.Now.Date);
                orderDetail.setRejected(false);
                orderDetail.setApprovedByEmpID(staffID);

                if (oda.update(orderDetail, conn) > 0)
                {
                    MessageBox.Show(rs.GetString("orderApprovalMsg"));
                }
                else
                {
                    MessageBox.Show(rs.GetString("failToUpdateMsg"), rs.GetString("errorText"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }


            approvalButton.Enabled = false;
            rejectButton.Enabled   = false;

            showOrderDetail(orderDetail.getOrderID());

            for (int i = orderDataGridView.Rows.Count - 1; i >= 0; i--)
            {
                if (orderDataGridView.Rows[i].Cells["orderIdColumn"].Value.Equals(orderDetail.getOrderID()))
                {
                    orderDataGridView.Rows.Remove(orderDataGridView.Rows[i]);
                }
            }
        }