protected void lnkbtnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString())
         {
             Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString());
             LinkButton  lnkbtn = sender as LinkButton;
             GridViewRow gvrow  = lnkbtn.NamingContainer as GridViewRow;
             int         secid  = Convert.ToInt32(gvSecondCategory.DataKeys[gvrow.RowIndex].Value.ToString());
             _boscat.SecondCategoryId = secid;
             _boscat.IsDelete         = true;
             _boscat.CreatedBy        = adminId;
             _boscat.CreatedDate      = DateTime.UtcNow;
             _boscat.UpdatedBy        = adminId;
             _boscat.UpdatedDate      = DateTime.UtcNow;
             _boscat.Event            = "Delete";
             int rtnvalue = _bascat.Delete(_boscat);
             if (rtnvalue == 3)
             {
                 ShowMessage("Category deleted successfully", MessageType.Success);
             }
             else if (rtnvalue == 5)
             {
                 ShowMessage("Can not delete category because used in another entity", MessageType.Info);
             }
         }
     }
     catch (Exception ex)
     {
         Common.LogError(ex);
         ShowMessage("Some technical error", MessageType.Warning);
     }
     ClearControl();
 }
Exemple #2
0
 private void dgvSecondCategory_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (headval)
         {
             if (dgvSecondCategory.Columns[e.ColumnIndex].Name == "Edit")
             {
                 SecCatId = Convert.ToInt32(dgvSecondCategory.Rows[e.RowIndex].Cells[0].Value.ToString());
                 txtSecondCategory.Text = dgvSecondCategory.Rows[e.RowIndex].Cells[1].Value.ToString();
                 cmbTopCategory.Text    = dgvSecondCategory.Rows[e.RowIndex].Cells[2].Value.ToString();
                 btnAdd.Text            = "Update";
             }
             else if (dgvSecondCategory.Columns[e.ColumnIndex].Name == "Delete")
             {
                 DialogResult result1 = MessageBox.Show("Are you sure you want to delete\nrecord " + dgvSecondCategory.Rows[e.RowIndex].Cells[1].Value.ToString() + " ?", "Warning", MessageBoxButtons.YesNo);
                 if (result1 == DialogResult.Yes)
                 {
                     SecCatId = Convert.ToInt32(dgvSecondCategory.Rows[e.RowIndex].Cells[0].Value.ToString());
                     BOSecondCategory _boscat = new BOSecondCategory();
                     _boscat.SecondCategoryId   = SecCatId;
                     _boscat.SecondCategoryName = txtSecondCategory.Text;
                     _boscat.TopCategoryId      = Convert.ToInt32(cmbTopCategory.SelectedValue);
                     _boscat.IsActive           = true;
                     _boscat.IsDelete           = true;
                     _boscat.CreatedBy          = loginID;
                     _boscat.CreatedDate        = DateTime.UtcNow;
                     _boscat.UpdatedBy          = loginID;
                     _boscat.UpdatedDate        = DateTime.UtcNow;
                     _boscat.Event = "Delete";
                     MessageBox.Show(Common.Message(dgvSecondCategory.Rows[e.RowIndex].Cells[1].Value.ToString(), bscat.Delete(_boscat)));
                     ClearControl();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }