/// <summary> /// Insert for usertask managerment /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUserTask_OnClick(object sender, EventArgs e) { try { ltMessage.Text = string.Empty; var dataManager = new UserTasks(); var userId = Convert.ToInt32(ddlUserName.SelectedValue); var taskId = Convert.ToInt32(ddlTaskName.SelectedValue); dataManager.InsertUserTask(userId, taskId); gvUserTask.EditIndex = -1; ltMessage.Text = "Insert Successflly !"; ddlUserName.SelectedValue = "none"; ddlTaskName.SelectedValue = "none"; BindDataToGridView(); } catch (Exception ex) { ltMessage.Text = ex.Message; } }
/// <summary> /// Delete row user task manager /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvUserTask_OnRowDeleting(object sender, GridViewDeleteEventArgs e) { try { ltMessage.Text = string.Empty; var dataManager = new UserTasks(); var row = gvUserTask.Rows[e.RowIndex]; var lbUserTask = (Label)row.FindControl("lbUserTask"); var id = Convert.ToInt32(lbUserTask.Text); dataManager.DeleteUserTask(id); BindDataToGridView(); ltMessage.Text = "Delete Successflly!"; } catch (Exception ex) { ltMessage.Text = ex.Message; } }