//Create a new method to delete a team public void DeleteTeam(TeamDAO TeamToDelete) { try { //Create a new connection to the database using (SqlConnection connection = new SqlConnection(connectionstring)) { //This states a command object for the database using (SqlCommand command = new SqlCommand("sp_DeleteTeam", connection)) { //This specifies that the object is going to execute a stored procedure for the dataase command.CommandType = CommandType.StoredProcedure; //This specifies the parameters for the stored procedure command.Parameters.AddWithValue("@TeamID", TeamToDelete.TeamID); //open the connection connection.Open(); //Execute the command command.ExecuteNonQuery(); //close the connection connection.Close(); //Dispose the connection connection.Dispose(); } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } }
public TeamService(IUserProvider userProvider, TeamDAO teamDao, TeamMemberDAO teamMemberDao, IUserAuthorization userAuthorization) { _teamDao = teamDao; _teamMemberDao = teamMemberDao; _userAuthorization = userAuthorization; _userId = userProvider.GetUserId(); }
public List <TeamInfo> selectallteam() { List <TeamInfo> lst = new List <TeamInfo>(); Tdao = new TeamDAO(); return(Tdao.SelectAllTeamInfo()); }
private void Load_NhomNhanVien() { this.lb_NhomNV.DataSource = TeamDAO.Get(); this.lb_NhomNV.DataTextField = "Name"; this.lb_NhomNV.DataValueField = "ID"; this.lb_NhomNV.DataBind(); }
public ActionResult AdminDeleteTeam(int deleteID) { TeamDAO ChosenTeam = new TeamDAO(); ChosenTeam.TeamID = deleteID; teamData.DeleteTeam(ChosenTeam); return(RedirectToAction("ViewAllTeams")); }
private void Load_Nhom() { var ddl_Nhom = (DropDownList)this.lv_ThongTinSP.InsertItem.FindControl("ddl_Nhom"); ddl_Nhom.DataSource = TeamDAO.Get(); ddl_Nhom.DataValueField = "ID"; ddl_Nhom.DataTextField = "Name"; ddl_Nhom.DataBind(); }
public ActionResult UserTeams() { TeamDAO UserToGet = new TeamDAO(); UserToGet.CreatorID = (int)Session["UserID"]; TeamViewModel TeamModel = new TeamViewModel(); TeamModel.TeamList = mapper.TeamsMap(teamData.SelectUserTeams(UserToGet)); return(View(TeamModel)); }
public HomeController(ILogger <HomeController> logger) { _logger = logger; win_typeDAO = new Win_TypeDAO(); seasonDAO = new SeasonDAO(); teamDAO = new TeamDAO(); matchDAO = new MatchDAO(); standingDAO = new StandingDAO(); info = new Info(standingDAO, matchDAO, teamDAO, win_typeDAO, seasonDAO); }
//Create a method to view a single users teams public List <TeamDAO> SelectUserTeams(TeamDAO TeamsToGet) { //Instantiate a new instance of the List<TeamDAO> object List <TeamDAO> teamlist = new List <TeamDAO>(); //Create a new connection to the database try { using (SqlConnection connection = new SqlConnection(connectionstring)) { //Create a new command for the database using (SqlCommand command = new SqlCommand("sp_SelectUserTeams", connection)) { //State that the command is a stored procedure for the database command.CommandType = CommandType.StoredProcedure; //Add parameters for the storedprocedure command.Parameters.AddWithValue("@UserID", TeamsToGet.CreatorID); //Open the connection connection.Open(); //Open the sql data reader using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { //Create a new teamDAO Variable to store values TeamDAO TeamToList = new TeamDAO(); TeamToList.TeamID = reader.GetInt32(0); TeamToList.TeamName = reader.GetString(1); TeamToList.Creator = reader.GetString(2); TeamToList.CreatorID = reader.GetInt32(3); TeamToList.FirstPokemon = reader.GetString(4); TeamToList.FirstPkID = reader.GetInt32(5); TeamToList.SecondPokemon = reader.GetString(6); TeamToList.SecondPkID = reader.GetInt32(7); TeamToList.ThirdPokemon = reader.GetString(8); TeamToList.ThirdPkID = reader.GetInt32(9); TeamToList.FourthPokemon = reader.GetString(10); TeamToList.FourthPkID = reader.GetInt32(11); TeamToList.FifthPokemon = reader.GetString(12); TeamToList.FifthPkID = reader.GetInt32(13); TeamToList.SixthPokemon = reader.GetString(14); TeamToList.SixthPkID = reader.GetInt32(15); teamlist.Add(TeamToList); } } } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } return(teamlist); }
//Create a new method to view all teams public List <TeamDAO> GetAllTeams() { //Create a new TeamDAO List named teamlist List <TeamDAO> teamlist = new List <TeamDAO>(); try { //Create a new connection for the database using (SqlConnection connection = new SqlConnection(connectionstring)) { //Create a new command object for teh database using (SqlCommand command = new SqlCommand("sp_SelectAllTeams", connection)) { //Define what command to send to the database command.CommandType = CommandType.StoredProcedure; //Open the connection connection.Open(); //Open the sql data reader using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { //Create a new teamDAO Variable to store values TeamDAO TeamToList = new TeamDAO(); TeamToList.TeamID = reader.GetInt32(0); TeamToList.TeamName = reader.GetString(1); TeamToList.Creator = reader.GetString(2); TeamToList.CreatorID = reader.GetInt32(3); TeamToList.FirstPokemon = reader.GetString(4); TeamToList.FirstPkID = reader.GetInt32(5); TeamToList.SecondPokemon = reader.GetString(6); TeamToList.SecondPkID = reader.GetInt32(7); TeamToList.ThirdPokemon = reader.GetString(8); TeamToList.ThirdPkID = reader.GetInt32(9); TeamToList.FourthPokemon = reader.GetString(10); TeamToList.FourthPkID = reader.GetInt32(11); TeamToList.FifthPokemon = reader.GetString(12); TeamToList.FifthPkID = reader.GetInt32(13); TeamToList.SixthPokemon = reader.GetString(14); TeamToList.SixthPkID = reader.GetInt32(15); teamlist.Add(TeamToList); } } } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } return(teamlist); }
public ActionResult ViewTeam(int ViewID) { PopulateDropDowns(); TeamDAO ChosenTeam = new TeamDAO(); ChosenTeam.TeamID = ViewID; TeamPO MappedTeam = mapper.SelectTeamMap(teamData.SelectTeam(ChosenTeam)); List <int> chosenTypes = mapper.TypeIDMap(MappedTeam); TypeDAO FinalValues = teamData.CalculateTypes(chosenTypes); MappedTeam.MaxName = FinalValues.MaxName; MappedTeam.Max2Name = FinalValues.Max2Name; MappedTeam.MinName = FinalValues.MinName; MappedTeam.Min2Name = FinalValues.Min2Name; return(View(MappedTeam)); }
private void MakeListTeamsCombo() { TeamDAO dao = new TeamDAO(); var models = dao.List(); List <SelectListItem> list = new List <SelectListItem>(); list.Add(new SelectListItem("Selecione a equipe...", "0")); foreach (var model in models) { SelectListItem item = new SelectListItem(model.name, model.id.ToString()); list.Add(item); } ViewBag.Teams = list; }
public TeamPO SelectTeamMap(TeamDAO TeamToCreate) { TeamPO TeamToList = new TeamPO(); TeamToList.TeamID = TeamToCreate.TeamID; TeamToList.TeamName = TeamToCreate.TeamName; TeamToList.Creator = TeamToCreate.Creator; TeamToList.CreatorID = TeamToCreate.CreatorID; TeamToList.FirstPokemon = TeamToCreate.FirstPokemon; TeamToList.FirstPkID = TeamToCreate.FirstPkID; TeamToList.Pk1Type1 = TeamToCreate.Pk1Type1; TeamToList.Pk1Type1Name = TeamToCreate.Pk1Type1Name; TeamToList.Pk1Type2 = TeamToCreate.Pk1Type2; TeamToList.Pk1Type2Name = TeamToCreate.Pk1Type2Name; TeamToList.SecondPokemon = TeamToCreate.SecondPokemon; TeamToList.SecondPkID = TeamToCreate.SecondPkID; TeamToList.Pk2Type1 = TeamToCreate.Pk2Type1; TeamToList.Pk2Type1Name = TeamToCreate.Pk2Type1Name; TeamToList.Pk2Type2 = TeamToCreate.Pk2Type2; TeamToList.Pk2Type2Name = TeamToCreate.Pk2Type2Name; TeamToList.ThirdPokemon = TeamToCreate.ThirdPokemon; TeamToList.ThirdPkID = TeamToCreate.ThirdPkID; TeamToList.Pk3Type1 = TeamToCreate.Pk3Type1; TeamToList.Pk3Type1Name = TeamToCreate.Pk3Type1Name; TeamToList.Pk3Type2 = TeamToCreate.Pk3Type2; TeamToList.Pk3Type2Name = TeamToCreate.Pk3Type2Name; TeamToList.FourthPokemon = TeamToCreate.FourthPokemon; TeamToList.FourthPkID = TeamToCreate.FourthPkID; TeamToList.Pk4Type1 = TeamToCreate.Pk4Type1; TeamToList.Pk4Type1Name = TeamToCreate.Pk4Type1Name; TeamToList.Pk4Type2 = TeamToCreate.Pk4Type2; TeamToList.Pk4Type2Name = TeamToCreate.Pk4Type2Name; TeamToList.FifthPokemon = TeamToCreate.FifthPokemon; TeamToList.FifthPkID = TeamToCreate.FifthPkID; TeamToList.Pk5Type1 = TeamToCreate.Pk5Type1; TeamToList.Pk5Type1Name = TeamToCreate.Pk5Type1Name; TeamToList.Pk5Type2 = TeamToCreate.Pk5Type2; TeamToList.Pk5Type2Name = TeamToCreate.Pk5Type2Name; TeamToList.SixthPokemon = TeamToCreate.SixthPokemon; TeamToList.SixthPkID = TeamToCreate.SixthPkID; TeamToList.Pk6Type1 = TeamToCreate.Pk6Type1; TeamToList.Pk6Type1Name = TeamToCreate.Pk6Type1Name; TeamToList.Pk6Type2 = TeamToCreate.Pk6Type2; TeamToList.Pk6Type2Name = TeamToCreate.Pk6Type2Name; return(TeamToList); }
public void ShouldUpdateTeam() { using (var db = new JUGContext()) { var teamDataService = new BaseDataService <TeamDAO>(); var name = "Team 1"; var skill = 5; var type = TeamType.BaseTeam; var teamDAO = new TeamDAO() { Name = name, Skill = skill, TeamType = type }; teamDataService.Create(teamDAO, db); teamDataService.SaveChanges(db); Assert.Single(db.Teams); var currenTeam = teamDataService.GetById(teamDAO.Id, db); Assert.Equal(name, currenTeam.Name); Assert.Equal(skill, currenTeam.Skill); Assert.Equal(type, currenTeam.TeamType); currenTeam.Name = "Team 2"; currenTeam.Skill = 12; currenTeam.TeamType = TeamType.SeasonTeam; teamDataService.Save(currenTeam, db); Assert.Single(db.Teams.Local); var updatedTeam = teamDataService.GetById(teamDAO.Id, db); Assert.Equal("Team 2", updatedTeam.Name); Assert.Equal(12, updatedTeam.Skill); Assert.Equal(TeamType.SeasonTeam, updatedTeam.TeamType); Assert.Equal(currenTeam.Id, updatedTeam.Id); teamDataService.SaveChanges(db); teamDataService.Delete(updatedTeam, db); teamDataService.SaveChanges(db); } }
protected void lv_ThongTinSP_ItemDeleting(object sender, ListViewDeleteEventArgs e) { if (this.objCheckPermision.Permission(this.objCheckPermision.LayQuyen("strNhomNhanVien_Xoa"))) { var hdf = (this.lv_ThongTinSP.Items[e.ItemIndex].FindControl("hfID")) as HiddenField; if (hdf != null) { TeamDAO.Delete(Int32.Parse(hdf.Value)); this.lv_ThongTinSP.EditIndex = -1; this.BinList(); } } else { this.iRightAccess.Visible = false; this.objControl.LoadMyControl(this.idNotPermissionAccess, NotPermissControl); } }
//Create a new method to update a team public void UpdateTeam(TeamDAO TeamToUpdate) { try { //Create a new connection to the database using (SqlConnection connection = new SqlConnection(connectionstring)) { //This creates a new command object for the database using (SqlCommand command = new SqlCommand("sp_UpdateTeam", connection)) { //This states to the database that the command is a stored procedure command.CommandType = CommandType.StoredProcedure; //This specifies the parameters for the database command.Parameters.AddWithValue("@TeamID", TeamToUpdate.TeamID); command.Parameters.AddWithValue("@TeamName", TeamToUpdate.TeamName); command.Parameters.AddWithValue("@Creator", TeamToUpdate.CreatorID); command.Parameters.AddWithValue("@FirstPokemon", TeamToUpdate.FirstPkID); command.Parameters.AddWithValue("@SecondPokemon", TeamToUpdate.SecondPkID); command.Parameters.AddWithValue("@ThirdPokemon", TeamToUpdate.ThirdPkID); command.Parameters.AddWithValue("@FourthPokemon", TeamToUpdate.FourthPkID); command.Parameters.AddWithValue("@FifthPokemon", TeamToUpdate.FifthPkID); command.Parameters.AddWithValue("@SixthPokemon", TeamToUpdate.SixthPkID); //Open the database connection connection.Open(); //Execute the command above command.ExecuteNonQuery(); //Close the connection connection.Close(); //Dispose the connection connection.Dispose(); } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } }
public TeamDAO SingleTeamMap(TeamPO TeamToCreate) { TeamDAO TeamToList = new TeamDAO(); TeamToList.TeamID = TeamToCreate.TeamID; TeamToList.TeamName = TeamToCreate.TeamName; TeamToList.Creator = TeamToCreate.Creator; TeamToList.CreatorID = TeamToCreate.CreatorID; TeamToList.FirstPokemon = TeamToCreate.FirstPokemon; TeamToList.FirstPkID = TeamToCreate.FirstPkID; TeamToList.SecondPokemon = TeamToCreate.SecondPokemon; TeamToList.SecondPkID = TeamToCreate.SecondPkID; TeamToList.ThirdPokemon = TeamToCreate.ThirdPokemon; TeamToList.ThirdPkID = TeamToCreate.ThirdPkID; TeamToList.FourthPokemon = TeamToCreate.FourthPokemon; TeamToList.FourthPkID = TeamToCreate.FourthPkID; TeamToList.FifthPokemon = TeamToCreate.FifthPokemon; TeamToList.FifthPkID = TeamToCreate.FifthPkID; TeamToList.SixthPokemon = TeamToCreate.SixthPokemon; TeamToList.SixthPkID = TeamToCreate.SixthPkID; return(TeamToList); }
protected void lbtnUpdate_Click(object sender, EventArgs e) { if (this.objCheckPermision.Permission(this.objCheckPermision.LayQuyen("strNhomNhanVien_Sua"))) { try { foreach (ListViewDataItem lvit in this.lv_ThongTinSP.Items) { string ID; if (((HiddenField)lvit.FindControl("hfID")).Value != "") { ID = ((HiddenField)lvit.FindControl("hfID")).Value; } else { this.ltr_Notice.Text = this.objComm.ShowNotice( false, "Cập nhật thông tin thất bại.\nLỗi trong quá trình nhận dạng nhóm chức năng"); return; } Team t0 = TeamDAO.Get(Int32.Parse(ID)); t0.Name = ((TextBox)lvit.FindControl("txt_Name")).Text; //t0.Name = ((TextBox)lvit.FindControl("txt_Name")).Text; EmployeeDAO.Update(); } this.ltr_Notice.Text = this.objComm.ShowNotice(true, "Cập nhật thông tin thành công!"); } catch (Exception ex) { this.ltr_Notice.Text = this.objComm.ShowNotice( false, "Cập nhật thông tin thất bại. Chi tiết lỗi: " + ex.Message); } } else { this.objComm.wr( "<script language='javascript'>alert('Bạn không có quyền thực hiện chức năng này.');location.href='thong-tin-san-pham';</script>"); } }
protected void lv_ThongTinSP_ItemInserting(object sender, ListViewInsertEventArgs e) { if (this.objCheckPermision.Permission(this.objCheckPermision.LayQuyen("strNhomNhanVien_Them"))) { var it = new Team(); var txt = (e.Item.FindControl("txt_Name")) as TextBox; if (txt != null) { it.Name = txt.Text; } txt = (e.Item.FindControl("txt_Name")) as TextBox; //if (txt != null) // it.Name = txt.Text; TeamDAO.Insert(it); this.lv_ThongTinSP.EditIndex = -1; this.BinList(); } else { this.iRightAccess.Visible = false; this.objControl.LoadMyControl(this.idNotPermissionAccess, NotPermissControl); } }
public void ShouldAddTeam() { using (var db = new JUGContext()) { var teamDataService = new BaseDataService <TeamDAO>(); Assert.Empty(teamDataService.GetAll(db)); var name = "Team 1"; var skill = 5; var type = TeamType.BaseTeam; var teamDAO = new TeamDAO() { Name = name, Skill = skill, TeamType = type }; teamDataService.Create(teamDAO, db); Assert.Single(db.Teams.Local); } }
public static void AddSomeTeams(int numberToAdd, JUGContext db) { var teamDataService = new BaseDataService <TeamDAO>(); for (int i = 0; i < numberToAdd; i++) { long id = 1; if (teamDataService.GetAll(db).Count > 0) { id = teamDataService.GetAll(db).Max(t => t.Id) + 1; } var name = "Team " + id; var skill = 5; var type = TeamType.BaseTeam; var teamDAO = new TeamDAO() { Name = name, Skill = skill, TeamType = type }; teamDataService.Save(teamDAO, db); } }
public TeamController() { DAO = new TeamDAO(); }
public void Insert(TeamInfo tinfo) { Tdao = new TeamDAO(); Tdao.InsertToTeam(tinfo); }
//Create a method to view a single team from the teams table public TeamDAO SelectTeam(TeamDAO TeamToGet) { TeamDAO TeamToReturn = new TeamDAO(); try { //Create a new connection to the database using (SqlConnection connection = new SqlConnection(connectionstring)) { //Create a new command for the database using (SqlCommand command = new SqlCommand("sp_SelectTeam", connection)) { //State that the command is a stored procedure for the database command.CommandType = CommandType.StoredProcedure; //Add parameters for the storedprocedure command.Parameters.AddWithValue("@TeamID", TeamToGet.TeamID); //Open the connection connection.Open(); //Open the sql data reader using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { //Create a new teamDAO Variable to store values TeamDAO TeamToList = new TeamDAO(); TeamToList.TeamID = reader.GetInt32(0); TeamToList.TeamName = reader.GetString(1); TeamToList.Creator = reader.GetString(2); TeamToList.CreatorID = reader.GetInt32(3); TeamToList.FirstPokemon = reader.GetString(4); TeamToList.FirstPkID = reader.GetInt32(5); TeamToList.Pk1Type1 = reader.GetInt32(6); TeamToList.Pk1Type1Name = reader.GetString(7); TeamToList.Pk1Type2 = reader.GetInt32(8); TeamToList.Pk1Type2Name = reader.GetString(9); TeamToList.SecondPokemon = reader.GetString(10); TeamToList.SecondPkID = reader.GetInt32(11); TeamToList.Pk2Type1 = reader.GetInt32(12); TeamToList.Pk2Type1Name = reader.GetString(13); TeamToList.Pk2Type2 = reader.GetInt32(14); TeamToList.Pk2Type2Name = reader.GetString(15); TeamToList.ThirdPokemon = reader.GetString(16); TeamToList.ThirdPkID = reader.GetInt32(17); TeamToList.Pk3Type1 = reader.GetInt32(18); TeamToList.Pk3Type1Name = reader.GetString(19); TeamToList.Pk3Type2 = reader.GetInt32(20); TeamToList.Pk3Type2Name = reader.GetString(21); TeamToList.FourthPokemon = reader.GetString(22); TeamToList.FourthPkID = reader.GetInt32(23); TeamToList.Pk4Type1 = reader.GetInt32(24); TeamToList.Pk4Type1Name = reader.GetString(25); TeamToList.Pk4Type2 = reader.GetInt32(26); TeamToList.Pk4Type2Name = reader.GetString(27); TeamToList.FifthPokemon = reader.GetString(28); TeamToList.FifthPkID = reader.GetInt32(29); TeamToList.Pk5Type1 = reader.GetInt32(30); TeamToList.Pk5Type1Name = reader.GetString(31); TeamToList.Pk5Type2 = reader.GetInt32(32); TeamToList.Pk5Type2Name = reader.GetString(33); TeamToList.SixthPokemon = reader.GetString(34); TeamToList.SixthPkID = reader.GetInt32(35); TeamToList.Pk6Type1 = reader.GetInt32(36); TeamToList.Pk6Type1Name = reader.GetString(37); TeamToList.Pk6Type2 = reader.GetInt32(38); TeamToList.Pk6Type2Name = reader.GetString(39); TeamToReturn = TeamToList; } } } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } return(TeamToReturn); }
private void BinList() { this.lv_ThongTinSP.DataSource = TeamDAO.Get(); this.lv_ThongTinSP.DataBind(); }