private void OnDisplayCheckList(DataRow patientRow) { ClearCheckList(); chkChecked.Checked = false; Result result = CompanyContractBus.GetCheckList(_hopDongGUID, patientRow["PatientGUID"].ToString()); if (result.IsOK) { DataTable dt = result.QueryResult as DataTable; dgService.DataSource = dt; foreach (DataGridViewRow row in dgService.Rows) { DataRow drRow = (row.DataBoundItem as DataRowView).Row; if (drRow["NguoiChuyenNhuong"] != null && drRow["NguoiChuyenNhuong"] != DBNull.Value && drRow["NguoiChuyenNhuong"].ToString().Trim() != string.Empty) { DataGridViewDisableCheckBoxCell cell = row.Cells["Using"] as DataGridViewDisableCheckBoxCell; cell.Enabled = false; } } OnTinhTongTienChecklist(patientRow); //btnLuu.Enabled = AllowEdit; } else { MsgBox.Show(this.Text, result.GetErrorAsString("CompanyContractBus.GetCheckList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("CompanyContractBus.GetCheckList")); } }
private void chkChecked_SoHoaDon_CheckedChanged(object sender, EventArgs e) { if (dgSoHoaDon.RowCount <= 0) { return; } foreach (DataGridViewRow row in dgSoHoaDon.Rows) { DataGridViewDisableCheckBoxCell cell = row.Cells["colChecked"] as DataGridViewDisableCheckBoxCell; if (cell.Enabled) { cell.Value = chkChecked_SoHoaDon.Checked; } else { cell.Value = false; } } //DataTable dt = dgSoHoaDon.DataSource as DataTable; //if (dt == null || dt.Rows.Count <= 0) return; //foreach (DataRow row in dt.Rows) //{ // row["Checked"] = chkChecked_SoHoaDon.Checked; //} }
/// Override the Clone method so that the Enabled property is copied. public override object Clone() { DataGridViewDisableCheckBoxCell cell = (DataGridViewDisableCheckBoxCell)base.Clone(); cell.Enabled = this.Enabled; return(cell); }
private void chkChiTietChecked_CheckedChanged(object sender, EventArgs e) { if (dgChiTiet.RowCount <= 0) { return; } foreach (DataGridViewRow row in dgChiTiet.Rows) { DataGridViewDisableCheckBoxCell cell = row.Cells["Checked"] as DataGridViewDisableCheckBoxCell; if (cell.Enabled) { DataRow r = (row.DataBoundItem as DataRowView).Row; r["Checked"] = chkChecked.Checked; } } }
private void dgService_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex != 0) { return; } DataRow row = (dgService.SelectedRows[0].DataBoundItem as DataRowView).Row; bool isUsing = Convert.ToBoolean(row["Using"]); DataGridViewDisableCheckBoxCell cell = (DataGridViewDisableCheckBoxCell)dgService.Rows[e.RowIndex].Cells[0]; if (!cell.Enabled) { return; } bool isChecked = Convert.ToBoolean(cell.EditingCellFormattedValue); if (isUsing != isChecked) { _isSaved = false; row["Using"] = isChecked; } }
private void SaveCheckList() { List <DataRow> checkListRows = new List <DataRow>(); foreach (DataGridViewRow row in dgService.Rows) { DataGridViewDisableCheckBoxCell cell = row.Cells["Using"] as DataGridViewDisableCheckBoxCell; if (!cell.Enabled) { continue; } DataRow drRow = (row.DataBoundItem as DataRowView).Row; checkListRows.Add(drRow); } if (checkListRows.Count <= 0) { return; } Result result = ServiceHistoryBus.UpdateChecklist(_patientGUID, _hopDongGUID, _beginDate, _endDate, checkListRows); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.UpdateChecklist"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.UpdateChecklist")); } else { MsgBox.Show(this.Text, "Đã lưu thành công.", IconType.Information); _isSaved = true; OnTinhTongTienChecklist(_patientRow); txtSearchPatient.Focus(); } }