Beispiel #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                BusinessManager BM  = new BusinessManager();
                BOProduct       BOP = new BOProduct();
                BOInventory     BOI = new BOInventory();
                BOP.ConfigID      = txtConfigID.Text;
                BOI.InventoryID   = txtInventoryID.Text;
                BOI.InventoryDate = dtpInventoryDate.Text;
                BOI.TotalPrice    = txtTotalPrice.Text;
                BOI.Quantity      = txtQuantity.Text;
                int RowsAffected = BM.BALUpdateIntoInventory(BOP, BOI);

                MessageBox.Show("Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnUpdate.Enabled = false;
                getData();
                //frmMainMenu frm = new frmMainMenu();
                //frm.GetData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (ValidateChildren(ValidationConstraints.Enabled))
     {
         try
         {
             BusinessManager BM  = new BusinessManager();
             BOProduct       BOP = new BOProduct();
             BOInventory     BOI = new BOInventory();
             BOP.ConfigID      = txtConfigID.Text;
             BOI.InventoryID   = txtInventoryID.Text;
             BOI.InventoryDate = dtpInventoryDate.Text;
             BOI.TotalPrice    = txtTotalPrice.Text;
             BOI.Quantity      = txtQuantity.Text;
             int RowsAffected = BM.BALUpdateIntoInventory(BOP, BOI);
             if (RowsAffected > 0)
             {
                 MessageBox.Show("Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 btnUpdate.Enabled = false;
                 getData();
             }
             else
             {
                 MessageBox.Show("Record couldn't be updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #3
0
        private void Delete()
        {
            try
            {
                BusinessManager BM  = new BusinessManager();
                BOInventory     BOI = new BOInventory();
                BOI.InventoryID = txtInventoryID.Text;
                int RowsAffected = BM.BALDeleteFromInventory(BOI);

                if (RowsAffected > 0)
                {
                    MessageBox.Show("The record has been successfully deleted", "Successfully Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    New();
                }
                else
                {
                    MessageBox.Show("No record found", "No Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    New();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                BusinessManager BM  = new BusinessManager();
                BOSales         BOS = new BOSales();
                BOProduct       BOP = new BOProduct();
                BOInventory     BOI = new BOInventory();
                BOS.GrandTotal   = txtGrandTotal.Text;
                BOS.TotalPayment = txtTotalPayment.Text;
                BOS.PaymentDue   = txtPaymentDue.Text;
                BOS.Remarks      = txtRemarks.Text;
                BOS.InvoiceNo    = txtInvoiceNo.Text;

                try
                {
                    BM.BALUpdateSales(BOS);

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOP.ProductQuantity = listView1.Items[i].SubItems[4].Text;
                        BOP.Price           = listView1.Items[i].SubItems[3].Text;
                        BOP.TotalAmount     = listView1.Items[i].SubItems[5].Text;
                        BOS.InvoiceNo       = txtInvoiceNo.Text;
                        BOP.ConfigID        = listView1.Items[i].SubItems[1].Text;
                        BM.BALUpdateProductSold(BOS, BOP);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOS.InvoiceNo       = txtInvoiceNo.Text;
                        BOP.ConfigID        = listView1.Items[i].SubItems[1].Text;
                        BOP.ProductQuantity = listView1.Items[i].SubItems[4].Text;
                        BOP.Price           = listView1.Items[i].SubItems[3].Text;
                        BOP.TotalAmount     = listView1.Items[i].SubItems[5].Text;
                        BM.BALInsertIntoProductSold(BOS, BOP);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOI.TotalPrice = listView1.Items[i].SubItems[5].Text;
                        BOP.ConfigID   = listView1.Items[i].SubItems[1].Text;
                        BM.BALUpdateInventoryTotalPrice(BOI, BOP);
                    }
                    dataGridView1.DataSource = BM.BALGetInvoiceData();
                    btnUpdate.Enabled        = false;
                    MessageBox.Show("Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                if (txtProductName.Text == "")
                {
                    MessageBox.Show("Please select a product name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtProductName.Focus();
                    return;
                }

                if (txtQuantity.Text == "")
                {
                    MessageBox.Show("Please enter a quantity", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtQuantity.Focus();
                    return;
                }
                try
                {
                    BusinessManager BM  = new BusinessManager();
                    BOProduct       BOP = new BOProduct();
                    BOInventory     BOI = new BOInventory();
                    BOP.ConfigID      = txtConfigID.Text;
                    BOI.InventoryDate = dtpInventoryDate.Text;
                    auto_generate();
                    BOI.InventoryID = txtInventoryID.Text;
                    BOI.Quantity    = txtQuantity.Text;
                    BOI.TotalPrice  = txtTotalPrice.Text;
                    bool res = BM.BALVerifyInventoryName(BOP);

                    if (res == true)
                    {
                        MessageBox.Show("Record already exists!" + "\n" + "Please update the stock of product", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        int rowsAffected = BM.BALInsertIntoInventory(BOP, BOI);

                        if (rowsAffected > 0)
                        {
                            MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            btnRegister.Enabled = false;
                            getData();
                            //frmMainMenu frm = new frmMainMenu();
                            //frm.GetData();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                try
                {
                    if (txtCustID.Text == "")
                    {
                        MessageBox.Show("Please retrieve Customer ID", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtCustID.Focus();
                        return;
                    }

                    if (txtVAT.Text == "")
                    {
                        MessageBox.Show("Please enter VAT percentage", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtVAT.Focus();
                        return;
                    }

                    if (txtTotalPayment.Text == "")
                    {
                        MessageBox.Show("Please enter total payment", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtTotalPayment.Focus();
                        return;
                    }
                    if (listView1.Items.Count == 0)
                    {
                        MessageBox.Show("Sorry no product added", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    auto_generate_id();
                    BusinessManager BM  = new BusinessManager();
                    BOSales         BOS = new BOSales();
                    BOCustomer      BOC = new BOCustomer();
                    BOProduct       BOP = new BOProduct();
                    BOInventory     BOI = new BOInventory();
                    BOS.InvoiceNo    = txtInvoiceNo.Text;
                    BOS.InvoiceDate  = dtpInvoiceDate.Text;
                    BOC.CustomerID   = txtCustID.Text;
                    BOS.SubTotal     = txtSubTotal.Text;
                    BOS.VATPercent   = txtVAT.Text;
                    BOS.VATAmount    = txtVatAmount.Text;
                    BOS.GrandTotal   = txtGrandTotal.Text;
                    BOS.TotalPayment = txtTotalPayment.Text;
                    BOS.PaymentDue   = txtPaymentDue.Text;
                    BOS.Remarks      = txtRemarks.Text;

                    bool res = BM.BALVerifyInvoiceNumber(BOS);

                    if (res == true)
                    {
                        MessageBox.Show("Invoice No. already exists", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        BM.BALInsertIntoSales(BOS, BOC);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOS.InvoiceNo       = txtInvoiceNo.Text;
                        BOP.ConfigID        = listView1.Items[i].SubItems[1].Text;
                        BOP.ProductQuantity = listView1.Items[i].SubItems[4].Text;
                        BOP.Price           = listView1.Items[i].SubItems[3].Text;
                        BOP.TotalAmount     = listView1.Items[i].SubItems[5].Text;
                        BM.BALInsertIntoProductSold(BOS, BOP);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOI.Quantity = listView1.Items[i].SubItems[4].Text;
                        BOP.ConfigID = listView1.Items[i].SubItems[1].Text;
                        BM.BALUpdateInventoryQuantity(BOI, BOP);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOI.TotalPrice = listView1.Items[i].SubItems[5].Text;
                        BOP.ConfigID   = listView1.Items[i].SubItems[1].Text;
                        BM.BALUpdateInventoryTotalPrice(BOI, BOP);
                    }

                    btnSave.Enabled          = false;
                    btnPrint.Enabled         = true;
                    dataGridView1.DataSource = BM.BALGetInvoiceData();
                    MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #7
0
        public void BALUpdateInventoryTotalPrice(BOInventory Inventory, BOProduct Product)
        {
            DBManager DALObject = new DBManager();

            DALObject.UpdateInventoryTotalPrice(Inventory, Product);
        }
Beispiel #8
0
        public void BALUpdateInventoryQuantity(BOInventory Inventory, BOProduct Product)
        {
            DBManager DALObject = new DBManager();

            DALObject.UpdateInventoryQuantity(Inventory, Product);
        }
Beispiel #9
0
        public int BALUpdateIntoInventory(BOProduct Product, BOInventory Inventory)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.UpdateIntoInventory(Product, Inventory));
        }
Beispiel #10
0
        public int BALDeleteFromInventory(BOInventory Inventory)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.DeleteFromInventory(Inventory));
        }