/// <summary> /// 单元格的值变更事件 /// </summary> public void GridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { MedGridView grid = (MedGridView)sender; if (MedGridViewScore != null && (MedGridViewScore.Columns[e.ColumnIndex].HeaderText == "评分")) { decimal valueTatol = 0; for (int i = 0; i < MedGridViewScore.RowCount; i++) { if (MedGridViewScore.Rows[i].Cells[e.ColumnIndex].Value != null) { decimal temp = 0; decimal.TryParse(MedGridViewScore.Rows[i].Cells[e.ColumnIndex].Value.ToString(), out temp); valueTatol += temp; } } // 计算值后生成事件参数 SYRMGridViewCellValueChangeEventArgs EventArgs = new SYRMGridViewCellValueChangeEventArgs((int)Math.Round(valueTatol)); // 异步调用值变化的事件 if (OnRefreshTotalScore != null) { OnRefreshTotalScore(sender, EventArgs); } } }
private void InitGridSource(MedGridView control, DataTable dataSources) { int rowCount = control.LinesPerPage; for (int i = 0; i < rowCount; i++) { int index = control.Rows.Add(); control.Rows[i].Tag = i + control.LinesPerPage * PagerSetting.CurrentPageIndex; } for (int i = 0; i < dataSources.Rows.Count; i++) { if (i < control.LinesPerPage * PagerSetting.CurrentPageIndex || i >= control.LinesPerPage * (PagerSetting.CurrentPageIndex + 1)) { continue; } DataGridViewRow gridRow = control.Rows[i - control.LinesPerPage * PagerSetting.CurrentPageIndex]; DataRow dataRow = dataSources.Rows[i]; for (int j = 0; j < control.ColumnCount; j++) { object value = dataRow[control.MedGridViewColumns[j].DataProperty]; if (value != System.DBNull.Value) { gridRow.Cells[j].Value = value; gridRow.Cells[j].Tag = value; } } } }
/// <summary> /// 初始化表格 /// </summary> private void InitGridSource(MedGridView control, Dictionary <string, System.Data.DataTable> dataSources) { List <MED_QIXIE_QINGDIAN> dataTable = new ModelHandler <MED_QIXIE_QINGDIAN>().FillModel(dataSources["MED_QIXIE_QINGDIAN"]); List <MED_QIXIE_QINGDIAN> qiXierows = null; if (dataTable != null && dataTable.Count > 0) { qiXierows = dataTable.Where(x => x.TABLETAG == control.Name).ToList();; } if (qiXierows == null || qiXierows.Count == 0) { if (string.IsNullOrEmpty(control.DefaultDatas)) { return; } if (dataTable == null) { dataTable = CareDocService.ClientInstance.GetOperCheckList(ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID, ExtendAppContext.Current.PatientInformationExtend.VISIT_ID, ExtendAppContext.Current.PatientInformationExtend.OPER_ID); } string defaultDatas = control.DefaultDatas; string[] rows = defaultDatas.Split(new string[] { "{}" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < rows.Length; i++) { string[] rowdatas = rows[i].Split(new string[] { "[]" }, StringSplitOptions.None); for (int j = 0; j < rowdatas.Length; j++) { try { if (string.IsNullOrEmpty(rowdatas[j])) { continue; } MED_QIXIE_QINGDIAN row = new MED_QIXIE_QINGDIAN(); row.PATIENT_ID = ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID; row.VISIT_ID = ExtendAppContext.Current.PatientInformationExtend.VISIT_ID; row.OPER_ID = ExtendAppContext.Current.PatientInformationExtend.OPER_ID; row.X_POSITION = j; row.Y_POSITION = i; row.POSITION_VALUE = rowdatas[j]; row.TABLETAG = control.Name; dataTable.Add(row); } catch (Exception ex) { ExceptionHandler.Handle(ex); } } } dataSources["MED_QIXIE_QINGDIAN"] = new ModelHandler <MED_QIXIE_QINGDIAN>().FillDataTable(dataTable); } }
/// <summary> /// 将数据绑定到UI界面 /// </summary> public override void BindDataToUI(MedGridView control, Dictionary <string, System.Data.DataTable> dataSources) { control.EnableHeadersVisualStyles = false; base.BindDataToUI(control, dataSources); for (int j = 0; j < control.Columns.Count; j++) { control.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable; } }
public void BindGridViewData(MedGridView control, DataTable dataSources) { control.EnableHeadersVisualStyles = false; control.AutoCreateColumns(); for (int j = 0; j < control.Columns.Count; j++) { control.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable; } InitGridSource(control, dataSources); }
/// <summary> /// 将数据源绑定显示到表格上 /// </summary> public override void BindDataToUI(MedGridView control, Dictionary <string, System.Data.DataTable> dataSources) { control.EnableHeadersVisualStyles = false; base.BindDataToUI(control, dataSources); control.Rows.Clear(); // 自动生成列 control.AutoCreateColumns(); InitGridSource(control, dataSources); for (int j = 0; j < control.Columns.Count; j++) { control.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable; } List <MED_QIXIE_QINGDIAN> dataTable = new ModelHandler <MED_QIXIE_QINGDIAN>().FillModel(dataSources["MED_QIXIE_QINGDIAN"]); int rowCount = control.LinesPerPage; for (int i = 0; i < rowCount; i++) { int index = control.Rows.Add(); control.Rows[i].Tag = i; } if (dataTable != null && dataTable.Count > 0) { foreach (MED_QIXIE_QINGDIAN row in dataTable) { if (control.Name == row.TABLETAG) { if (row.Y_POSITION >= rowCount || row.Y_POSITION < 0) { continue; } int x, y; x = Convert.ToInt16(row.X_POSITION); y = Convert.ToInt16(row.Y_POSITION); control[x, y].Value = row.POSITION_VALUE; control[x, y].Tag = row.POSITION_VALUE; } } } }
public event RefreshTotalScore OnRefreshTotalScore = null; // 刷新总分的事件 /// <summary> /// 控件属性事件设置 /// </summary> public override void ControlSetting(MedGridView control) { base.ControlSetting(control); // 计算评分,绑定事件 if (control.Name.ToUpper() == "MedGridViewScore".ToUpper()) { control.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(GridView_Validating); control.CellValidated += new System.Windows.Forms.DataGridViewCellEventHandler(GridView_CellValidated); control.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(GridView_CellValueChanged); MedGridViewScore = control; this.RefreshScore(); } else if (control.Name.ToUpper() == "MedGridViewAldrete".ToUpper()) { control.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(GridView_Validating); control.CellValidated += new System.Windows.Forms.DataGridViewCellEventHandler(GridView_CellValidated); MedGridViewAldrete = control; } }
protected override void OnViewBuilded(List <IUIElementHandler> handlers, Dictionary <string, DataTable> dataSources) { textBoxs = this.GetControls <MTextBox>(); foreach (MTextBox ctl in textBoxs) { if (ctl.Name == "mtbInpNo" || ctl.Name == "mtbPatID") { ctl.TextChanged += new EventHandler(ctl_TextChanged); ctl.Leave += new EventHandler(ctl_Leave); } } List <MedGridView> girdView = this.GetControls <MedGridView>(); foreach (MedGridView view in girdView) { if (view.Name == "dgvScheduleOperInfo") { dgvScheduleOperInfo = view; } } }
protected override Control GetEditControl(object instance) { _source = instance; if (_source != null) { _panelBody = new Panel(); _panelBody.Width = 800; _panelBody.Height = 500; Panel panelBottom = new Panel(); panelBottom.Height = 80; panelBottom.Dock = DockStyle.Bottom; _panelBody.Controls.Add(panelBottom); MedButton btnUp = new MedButton(); btnUp.Click += new EventHandler(btnUp_Click); panelBottom.Controls.Add(btnUp); btnUp.Text = "上移(&W)"; btnUp.Location = new System.Drawing.Point(10, 10); btnUp.Width = 60; MedButton btnDown = new MedButton(); btnDown.Click += new EventHandler(btnDown_Click); panelBottom.Controls.Add(btnDown); btnDown.Text = "下移(&S)"; btnDown.Location = new System.Drawing.Point(90, 10); btnDown.Width = 60; MedButton btnAdd = new MedButton(); btnAdd.Click += new EventHandler(btnAdd_Click); panelBottom.Controls.Add(btnAdd); btnAdd.Text = "添加(&A)"; btnAdd.Location = new System.Drawing.Point(170, 10); btnAdd.Width = 60; MedButton btnDelete = new MedButton(); btnDelete.Click += new EventHandler(btnDelete_Click); panelBottom.Controls.Add(btnDelete); btnDelete.Text = "删除(&D)"; btnDelete.Location = new System.Drawing.Point(250, 10); btnDelete.Width = 60; MedButton btnOK = new MedButton(); btnOK.Click += new EventHandler(btnOK_Click); panelBottom.Controls.Add(btnOK); btnOK.Text = "确定(&O)"; btnOK.Location = new System.Drawing.Point(410, 10); btnOK.Width = 60; _gird = new MedGridView(); _gird.Columns.Add("显示文本", "显示文本"); _gird.Columns.Add("字段名称", "字段名称"); _gird.Columns.Add("宽度", "宽度"); _listBox = new ListBox(); _propertyGrid = new PropertyGrid(); if (_source is MedGridView) { (_source as MedGridView).GetMedGridViewColumns(out _medGridViewColumns); } //else // if (_source is MedDevGrid) // { // (_source as MedDevGrid).GetMedGridViewColumns(out _medGridViewColumns); // } ResetList(); _panelBody.Controls.Add(_gird); _gird.Dock = DockStyle.Left; _gird.BringToFront(); _gird.Visible = false; _panelBody.Controls.Add(_listBox); _listBox.Dock = DockStyle.Left; _listBox.BringToFront(); _listBox.Width += 30; _listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged); _panelBody.Controls.Add(_propertyGrid); _propertyGrid.Dock = DockStyle.Fill; _propertyGrid.BringToFront(); _propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); return(_panelBody); } else { return(base.GetEditControl(instance)); } }
private void grid_Enter(object sender, EventArgs e) { _currentMRichTextBox = null; _currentGridView = sender as MedGridView; }
void richBox_Enter(object sender, EventArgs e) { _currentGridView = null; _currentMRichTextBox = sender as MRichTextBox; }
/// <summary> /// 单元格验证完成后触发 /// </summary> public void GridView_CellValidated(object sender, DataGridViewCellEventArgs e) { MedGridView grid = (MedGridView)sender; }
/// <summary> /// 初始化表格数据 /// </summary> protected override void InitGridModelData(MedGridView control, Dictionary <string, System.Data.DataTable> datasources) { DataTable dataTable = null; string defaultDatas = control.DefaultDatas; string[] rows = defaultDatas.Split(new string[] { "{}" }, StringSplitOptions.RemoveEmptyEntries); if (control.Name.ToUpper() == "MedGridViewAnesScore".ToUpper()) { dataTable = DataContext.GetCurrent().GetData("MED_ANES_SORCE"); } else if (control.Name.ToUpper() == "MedGridViewScore".ToUpper()) { dataTable = DataContext.GetCurrent().GetData("MED_PACU_SORCE"); } else if (control.Name.ToUpper() == "MedGridViewAldrete".ToUpper()) { dataTable = DataContext.GetCurrent().GetData("MED_PACU_ALDRETE_SORCE"); } if (dataTable.Rows.Count > 0) { } else { // 没有记录 读取模板 control.RowCount = rows.Length; for (int i = 0; i < rows.Length; i++) { try { string[] rowdatas = rows[i].Split(new string[] { "[]" }, StringSplitOptions.None); DataRow row = dataTable.NewRow(); row["PATIENT_ID"] = ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID; row["VISIT_ID"] = ExtendAppContext.Current.PatientInformationExtend.VISIT_ID; row["OPER_ID"] = ExtendAppContext.Current.PatientInformationExtend.OPER_ID; row["ORDER_ID"] = i + 1; for (int j = 0; j < control.Columns.Count; j++) { if (!string.IsNullOrEmpty(rowdatas[j])) { row[control.Columns[j].DataPropertyName] = rowdatas[j]; } } control.Rows[i].Tag = i; dataTable.Rows.Add(row); } catch (Exception ex) { ExceptionHandler.Handle(ex); } } if (control.Name.ToUpper() == "MedGridViewAnesScore".ToUpper()) { datasources["MED_ANES_SORCE"] = dataTable; } else if (control.Name.ToUpper() == "MedGridViewScore".ToUpper()) { datasources["MED_PACU_SORCE"] = dataTable; } else if (control.Name.ToUpper() == "MedGridViewAldrete".ToUpper()) { datasources["MED_PACU_ALDRETE_SORCE"] = dataTable; } } }