Esempio n. 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();
        }
Esempio n. 2
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();
                }
            }
        }