예제 #1
0
        private void BtnAddCategory_Click(object sender, EventArgs e)
        {
            AdminAddCategory cat = new AdminAddCategory(this);

            cat.BtnSave.Visible   = true;
            cat.BtnSave.Location  = new System.Drawing.Point(106, 167);
            cat.BtnUpdate.Visible = false;
            cat.ShowDialog();
        }
예제 #2
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            //File a switch case statement
            switch (e.ClickedItem.Name.ToString())
            {
            case "edi":

                contextMenuStrip1.Hide();
                AdminAddCategory c = new AdminAddCategory(this);

                c.lblID.Text       = lblID.Text;
                c.txtCategory.Text = lblCategory.Text;

                //Hide the Save Button
                c.BtnSave.Visible = false;

                //Show Only the Update Button
                c.BtnUpdate.Visible = true;
                c.lbl1.Text         = "Update Category";
                c.Show();

                break;

            case "del":

                contextMenuStrip1.Hide();
                if (MessageBox.Show("Are you sure you want to Delete this Category?", "Delete Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("DELETE FROM tblCategory WHERE cid like '" + lblID.Text + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Category has been Successfully Deleted", "Category Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowCategories();
                }

                break;

            case "deta":

                contextMenuStrip1.Hide();

                if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminGroupByCategory"))
                {
                    AdminGroupByCategory categorized = new AdminGroupByCategory(this);
                    categorized.Dock = DockStyle.Fill;
                    AdminAdministrator.Instance.PnlContainer.Controls.Add(categorized);

                    categorized.ShowCategorizedProducts();
                    categorized.BtnCategorizedBy.Text = "Categorized by " + lblCategory.Text + "";
                }
                AdminAdministrator.Instance.PnlContainer.Controls["AdminGroupByCategory"].BringToFront();
                AdminAdministrator.Instance.BackButton.Visible = true;

                break;
            }
        }
예제 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colName == "Group")
            {
                this.lblCategory.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminGroupByCategory"))
                {
                    AdminGroupByCategory categorized = new AdminGroupByCategory(this);
                    categorized.Dock = DockStyle.Fill;
                    AdminAdministrator.Instance.PnlContainer.Controls.Add(categorized);

                    categorized.ShowCategorizedProducts();
                    categorized.BtnCategorizedBy.Text = "Categorized by " + lblCategory.Text + "";
                }
                AdminAdministrator.Instance.PnlContainer.Controls["AdminGroupByCategory"].BringToFront();
                AdminAdministrator.Instance.BackButton.Visible = true;
            }
            if (colName == "Edit")
            {
                AdminAddCategory frm = new AdminAddCategory(this);
                frm.txtCategory.Text  = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                frm.lblID.Text        = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                frm.BtnSave.Visible   = false;
                frm.BtnUpdate.Visible = true;
                frm.lbl1.Text         = "Update Category";
                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this Category?", "Deleting Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("Delete FROM tblCategory WHERE cid like '" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Category has been successfully Deleted.", "Category Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowCategories();
                }
            }
        }