private void bindData(int index) { // ---- BIND DU LIEU VAO CAC DROP LIST cboBelongPosition = new cls_Catalog_Position().SelectList(); cboEduMajor = new cls_Catalog_EducationMajor().Select(); cboEngLevel = new cls_Catalog_EducationLangLevel().SelectEnglish(); cboEduLevel = new cls_Catalog_EducationLevel().Select(); dlBelongName.DataSource = cboBelongPosition.Tables[0]; dlEngLevel.DataSource = cboEngLevel; dlEngLevel.DataTextField = "LanguageLevel"; dlEngLevel.DataValueField = "Id"; dlBelongName.DataBind(); dlEduLevel.DataBind(); dlEduMajor.DataBind(); dlEngLevel.DataBind(); if(option != 1) // KHONG PHAI TRANG THAI INSERT { if (dtPosition.Rows.Count > 0) { try { //LAY THONG TIN VTCV TUONG UNG cls_Catalog_Position cPosition = new cls_Catalog_Position(); cPosition.Id = PositionId; cPosition = cPosition.Select(); //VIEW DU LIEU LEN txtPositionName.Text = cPosition.PositionName; dlBelongName.SelectedValue = cPosition.Belong_PositionId.ToString(); txtSalaryLevel.Text = cPosition.Salary_Level.ToString(); txtDescrible.Text = cPosition.Describle; dlEduMajor.SelectedValue = cPosition.Education_MajorId.ToString(); dlEduLevel.SelectedValue = cPosition.Education_LevelId.ToString(); dlEngLevel.SelectedValue = cPosition.English_LevelId.ToString(); txtITLevel.Text = cPosition.Informatic_Level; txtMLevel.Text = cPosition.Management_Level; txtPLevel.Text = cPosition.Politics_Level; txtSkills.Text = cPosition.Skills; txtOther.Text = cPosition.Other_Requires; //LAY DANH SACH NHIEM VU CAC CONG VIEC cls_Catalog_PositionRoles cPRoles = new cls_Catalog_PositionRoles(); cPRoles.Positionid = PositionId; dsPRoles = cPRoles.Select(); m_grid.EditIndex = index; if ((dsPRoles.Tables[0] == null) || (dsPRoles.Tables[0].Rows.Count <= 0)) { dsPRoles.Tables[0].Rows.Add(dsPRoles.Tables[0].NewRow()); m_grid.DataSource = dsPRoles.Tables[0]; m_grid.DataBind(); m_grid.Rows[0].Visible = false; } else { m_grid.DataSource = dsPRoles.Tables[0]; m_grid.DataBind(); } bool optionStatus; if ((option == 1) || (option == 2)) // TRANG THAI INSERT HOAC UPDATE optionStatus = true; else optionStatus = false; if (m_grid.Rows.Count > 0) { string confirm = "return confirm('Bạn thật sự muốn xóa row này?')"; for (int i = 0; i < m_grid.Rows.Count; i++) { GridViewRow row = m_grid.Rows[i]; LinkButton lbutton1 = (LinkButton)row.FindControl("cmdDelete"); if (lbutton1 != null) { lbutton1.Visible = optionStatus; lbutton1.Attributes.Add("onclick", confirm); } LinkButton lbutton2 = (LinkButton)row.FindControl("cmdEdit"); if (lbutton2 != null) lbutton2.Visible = optionStatus; } } //XET QUYEN CHO CHUC NANG INSERT POSITION ROLES GridViewRow row1 = m_grid.FooterRow; if (row1 != null) { LinkButton lbutton3 = (LinkButton)row1.FindControl("cmdInsert"); if (lbutton3 != null) lbutton3.Visible = optionStatus; } } catch (Exception ex) { } } else { option = 1; //CHUYEN SANG TRANG THAI INSERT PositionId = 0; btnDelete.Enabled = false; btnUpdate.Enabled = false; btnInsert.Text = "Ghi"; btnInsert1.Text = "Ghi"; btnUpdate.Text = "Sửa"; btnUpdate1.Text = "Sửa"; stateInsertbtn = false; bindData(-1); } } else //TRANG THAI INSERT { if (dtPosRoles == null) { dtPosRoles = new DataTable(); dtPosRoles.Columns.Add("Id", typeof(int)); dtPosRoles.Columns.Add("Prior_Level", typeof(short)); dtPosRoles.Columns.Add("WorkName", typeof(string)); } if (dtPosRoles.Rows.Count <= 0) dtPosRoles.Rows.Add(dtPosRoles.NewRow()); m_grid.EditIndex = index; m_grid.DataSource = dtPosRoles; m_grid.DataBind(); if (countPosRoles == 0) { m_grid.Rows[0].Visible = false; //VIEW DU LIEU LEN txtPositionName.Text = ""; txtSalaryLevel.Text = ""; txtDescrible.Text = ""; txtITLevel.Text = ""; txtMLevel.Text = ""; txtPLevel.Text = ""; txtSkills.Text = ""; txtOther.Text = ""; } } setAuthorization(); }