protected void btnSave_Click(object sender, EventArgs e) { //BasePage basepage=new BasePage(); //List<UserTaskMaping> lst = new List<UserTaskMaping>(); //lst = userBal.ReadUserTask(UserId); //BindCheckBoxList(); //foreach (ListItem item in chbxUserTask.Items) //{ // foreach (UserTaskMaping pop in lst) // { // if (Convert.ToInt32(item.Value) == pop.MetadataUserTask.Id) // { // item.Selected = true; // userBal.DeleteUserTask(UserId,basepage.LoggedInUser.LoginId,DateTime.Now); // } // } //} UserDom user = new UserDom(); user.UserId = Convert.ToInt32(hdfldUserId.Value); user.UserTask = new List <UserTaskMaping>(); foreach (ListItem item in chbxUserTask.Items) { if (item.Selected == true) { UserTaskMaping usertaskMap = new UserTaskMaping(); usertaskMap.UserTaskMappingId = Convert.ToInt32(item.Value); usertaskMap.Description = item.Text; usertaskMap.Created_By = "Admin"; usertaskMap.Created_Date = DateTime.Now; user.UserTask.Add(usertaskMap); } } userBal.CreateUserTask(user.UserTask, user.UserId); ScriptManager.RegisterClientScriptBlock(btnSave, GetType(), "a", "alert('User Task Mapping Updated successfully...')", true); chbxUserTask.Enabled = false; Response.Redirect("UserMaster.aspx"); }
public List <UserTaskMaping> ReadUserTaskByUserId(Int32 userId) { List <UserTaskMaping> lstUserTask = new List <UserTaskMaping>(); DbCommand dbcommand = myDataBase.GetStoredProcCommand(DBConstant.READ_USERTASK_BY_USERID); myDataBase.AddInParameter(dbcommand, "@in_UserId", DbType.Int32, userId); using (IDataReader reader = myDataBase.ExecuteReader(dbcommand)) { while (reader.Read()) { UserTaskMaping userTaskMap = new UserTaskMaping(); userTaskMap.MetadataUserTask = new MetaData(); userTaskMap.MetadataUserTask.Id = GetIntegerFromDataReader(reader, "MetaDataUserTask_Id"); userTaskMap.UserTaskMappingId = GetIntegerFromDataReader(reader, "User_Id"); userTaskMap.Description = GetStringFromDataReader(reader, "Description"); userTaskMap.Created_By = GetStringFromDataReader(reader, "Created_By"); userTaskMap.Created_Date = GetDateFromReader(reader, "Created_Date"); userTaskMap.Description = GetStringFromDataReader(reader, "Description"); lstUserTask.Add(userTaskMap); } return(lstUserTask); } }