Example #1
0
        private void dgvParentCategory_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            try
            {
                if (e.ColumnIndex == 2)
                {
                    Int32  parentCatId   = Convert.ToInt32("0" + dgvParentCategory.Rows[e.RowIndex].Cells[0].Value);
                    string parentCatName = Convert.ToString(dgvParentCategory.Rows[e.RowIndex].Cells[1].Value);

                    UpdateParentCtl objUpdate = new UpdateParentCtl(parentCatId, parentCatName);
                    objUpdate.Parent = this.ParentForm;
                    UserControlManager.UserControls.Push(this);
                    Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"];

                    string s = pnl.Name;

                    objUpdate.ParentForm.Controls[s].Controls.Clear();
                    objUpdate.ParentForm.Controls[s].Controls.Add(objUpdate);
                }

                else if (e.ColumnIndex == 3)
                {
                    if (MessageBox.Show("Are you sure you want to delete the selected parent category?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        int parentCatId = 0;

                        bool bTempBool = Int32.TryParse(dgvParentCategory.Rows[e.RowIndex].Cells[0].Value.ToString(), out parentCatId);

                        if (bTempBool)
                        {
                            CParentCategory oCat = new CParentCategory();

                            oCat.ParentCatID = parentCatId;
                            CCategoryManager oManager = new CCategoryManager();

                            CResult oResult = oManager.DeleteParentCat(oCat);

                            if (oResult.IsSuccess)
                            {
                                dgvParentCategory.Rows.RemoveAt(e.RowIndex);
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }