protected void btnDelete_Click(object sender, EventArgs e) { Int64 Key = Convert.ToInt64(Request.QueryString["ID"].ToString()); ClsKeys ClsKey = new ClsKeys(); ClsKey.Add("RecruitmentTestQuestionsID", Key); ClsQuestion objQuestion = new ClsQuestion(this.Master.pCurrentUser); objQuestion.Load(ClsKey); objQuestion.Delete(); Response.Redirect("Question.aspx"); }
void pGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { Int64 Key = 0; // Get the ID for the row to select or delete if (e.CommandName.ToUpper() == "SELECT" || e.CommandName.ToUpper() == "DELETE") { Key = this.QuestionGrid.GetKey(e.Item.ItemIndex); } switch (e.CommandName) { case "Select": this.Response.Redirect(@"~/Page/Question_Details.aspx?ID=" + Key); break; case "Delete": ClsKeys ClsKey = new ClsKeys(); ClsKey.Add("RecruitmentTestQuestionsID", Convert.ToInt64(Key)); ClsQuestion Obj_Question = new ClsQuestion(this.Master.pCurrentUser); Obj_Question.Load(ClsKey); if (this.Master.pCurrentUser.pUserType != Layer02_Constants.eLookupUserType.Administrator) { Int64 CurrentUserID = Methods.Convert_Int64(this.Master.pCurrentUser.pDrUser["RecruitmentTestUserID"], 0); Int64 OwnerUserID = Methods.Convert_Int64(Obj_Question.pDr["RecruitmentTestUserID_CreatedBy"], 0); if (CurrentUserID != OwnerUserID) { this.Show_EventMsg("You can't delete this question.", ClsBaseMain_Master.eStatus.Event_Error); this.QuestionGrid.RebindGrid(); return; } } Obj_Question.Delete(); this.QuestionGrid.RebindGrid(); break; } }
protected override void DeleteRecord(long KeyID) { /* Customer DeleteRecord Rights A Question Record can be deleted by: The user who created the record and has the Delete Rights and the record is not approved. A user who has the Delete and View Rights and the record is not approved. */ Keys ClsKey = new Keys(); ClsKey.Add("RecruitmentTestQuestionsID", Convert.ToInt64(KeyID)); ClsQuestion Obj_Question = new ClsQuestion(this.pCurrentUser); Obj_Question.Load(ClsKey); if (this.pCurrentUser.CheckAccess(Layer02_Constants.eSystem_Modules.Question, Layer02_Constants.eAccessLib.eAccessLib_Delete)) { Int64 CurrentUserID = Do_Methods.Convert_Int64(this.pCurrentUser.pDrUser["RecruitmentTestUserID"], 0); Int64 OwnerUserID = Do_Methods.Convert_Int64(Obj_Question.pDr["RecruitmentTestUserID_CreatedBy"], 0); bool IsApproved = Do_Methods.Convert_Boolean(Obj_Question.pDr["IsApproved"]); if (! ( ( (CurrentUserID == OwnerUserID) || (this.pCurrentUser.CheckAccess(Layer02_Constants.eSystem_Modules.Question, Layer02_Constants.eAccessLib.eAccessLib_View)) ) && (!IsApproved) ) ) { this.Show_EventMsg("You can't delete this question.", ClsBaseMain_Master.eStatus.Event_Error); } else { Obj_Question.Delete(); } } this.pGridList.RebindGrid(); }