private void bindData(int index) { try { //LAY DANH SACH CAC QUOC GIA RA dsGroup = new DataTable(); //Hiển thị tổng hợp clsPhieuXuat oPhieuXuat = new clsPhieuXuat(); DataTable tblPhieuXuat = new DataTable(); oPhieuXuat.PhieuXuat_Id = sKey; dsGroup = oPhieuXuat.Select_ThongTinThietBi(); // tblPhieuXuat = oPhieuXuat.Select(); if (tblPhieuXuat.Rows.Count > 0) { txtSoPhieu.Text = tblPhieuXuat.Rows[0]["So_Phieu"].ToString(); dtpNgayNhap.SelectedDate = Convert.ToDateTime(tblPhieuXuat.Rows[0]["Ngay_Xuat"]); txtNguoiNhan.Text = tblPhieuXuat.Rows[0]["NguoiXuat"].ToString(); } m_grid.EditIndex = index; m_grid.DataSource = dsGroup; bool add = false; if (dsGroup.Rows.Count <= 0) { dsGroup.Rows.Add(dsGroup.NewRow()); add = true; } // m_grid.DataBind(); if (add) m_grid.Rows[0].Visible = 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 = D_Option; lbutton1.Attributes.Add("onclick", confirm); //lbutton1.Enabled = D_Option; } LinkButton lbutton2 = (LinkButton)row.FindControl("cmdEdit"); if (lbutton2 != null) lbutton2.Visible = U_Option; } } //XET QUYETN CHO CHUC NANG INSERT GridViewRow row1 = m_grid.FooterRow; if (row1 != null) { row1.Visible = I_Option; } // string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLConn"].ToString();// "server='NgoQuangLua-PC'; uid=sa;pwd=sa; Database='QL'; trusted_connection=true;"; System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString); string queryString = "select COUNT(*) sl_danhap from ThongTinThietBi a where a.PhieuXuat_Id='"+ sKey +"' and a.ThietBi_Id='"+ cboThietBi.SelectedValue +"'"; sqlConnection.Open(); SqlDataAdapter oAdap = new SqlDataAdapter(queryString, sqlConnection); DataTable tblTemp = new DataTable(); oAdap.Fill(tblTemp); if (tblTemp.Rows.Count > 0) { txtSoLuongDaCoChiTiet.Text = tblTemp.Rows[0]["sl_danhap"].ToString(); txtSoLuongCanNhapChiTiet.Text = (Convert.ToInt16(txtSoLuongNhapKho.Text == "" ? "0" : txtSoLuongNhapKho.Text) - Convert.ToInt16(txtSoLuongDaCoChiTiet.Text == "" ? "0" : txtSoLuongDaCoChiTiet.Text)).ToString(); } else { txtSoLuongDaCoChiTiet.Text = "0"; txtSoLuongCanNhapChiTiet.Text = (Convert.ToInt16(txtSoLuongNhapKho.Text == "" ? "0" : txtSoLuongNhapKho.Text) - Convert.ToInt16(txtSoLuongDaCoChiTiet.Text == "" ? "0" : txtSoLuongDaCoChiTiet.Text)).ToString(); } } catch (Exception ex) { } }