private void BtnProducts_Click(object sender, EventArgs e)
        {
            if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminProducts"))
            {
                AdminProducts pro = new AdminProducts();
                pro.Dock = DockStyle.Fill;
                AdminAdministrator.Instance.PnlContainer.Controls.Add(pro);

                pro.ShowAllProductsInDatabase();
            }
            AdminAdministrator.Instance.PnlContainer.Controls["AdminProducts"].BringToFront();
            AdminAdministrator.Instance.BackButton.Visible = true;
        }
Example #2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (txtDesc.Text == String.Empty)
            {
                WarningIndicator.Visible  = true;
                WarningIndicator.Location = new System.Drawing.Point(522, 100);
                txtDesc.Focus();
                return;
            }
            if (txtCode.Text == String.Empty)
            {
                WarningIndicator.Visible  = true;
                WarningIndicator.Location = new System.Drawing.Point(522, 173);
                return;
            }
            if (txtCategory.Text == String.Empty)
            {
                WarningIndicator.Location = new System.Drawing.Point(377, 247);
                WarningIndicator.Visible  = true;

                txtDesc.Focus();
                return;
            }
            if (txtPrice.Text == String.Empty)
            {
                WarningIndicator.Visible  = true;
                WarningIndicator.Location = new System.Drawing.Point(319, 313);
                txtDesc.Focus();
                return;
            }
            else
            {
                cn.Open();
                cm = new SqlCommand("SELECT category FROM tblCategory WHERE category = @category", cn);
                cm.Parameters.AddWithValue("@category", txtCategory.Text);
                da = new SqlDataAdapter(cm);
                dt = new DataTable();
                da.Fill(dt);
                cn.Close();
                if (dt.Rows.Count >= 1)
                {
                    InsertProductInformation();
                    MessageBox.Show("Product Information Successfully Saved. ", "Product Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cn.Close();

                    ClearData();
                    PRlist.ShowAllProductsInDatabase();
                    this.Dispose();
                }
                cn.Close();
            }
            if (dt.Rows.Count <= 0)
            {
                //Automation of Inserting Category in category table
                InsertCategory();
                InsertProductInformation();

                MessageBox.Show("Product Information Successfully Saved.", "Product Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cn.Close();

                ClearData();
                PRlist.ShowAllProductsInDatabase();
                this.Dispose();
            }
        }