예제 #1
0
        /// <summary>
        /// 新增手术记录事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDiagnose_Click(object sender, EventArgs e)
        {
            try
            {
                m_OperInfoFrom = new IemNewOperInfo(m_App, "new", null);

                m_OperInfoFrom.ShowDialog();

                if (m_OperInfoFrom.DialogResult == DialogResult.OK)
                {
                    m_OperInfoFrom.IemOperInfo = null;
                    DataTable dataTable = m_OperInfoFrom.DataOper;

                    DataTable dataTableOper = new DataTable();
                    if (this.gridControl1.DataSource != null)
                    {
                        dataTableOper = this.gridControl1.DataSource as DataTable;
                    }
                    if (dataTableOper.Rows.Count == 0)
                    {
                        dataTableOper = dataTable.Clone();
                    }
                    DataRow newRow = dataTableOper.NewRow();
                    foreach (DataColumn item in dataTableOper.Columns)
                    {
                        DataRow dataRow = dataTable.Rows[0];
                        if (dataTable.Columns.Contains(item.ColumnName))
                        {
                            newRow[item.ColumnName] = dataRow[item.ColumnName].ToString();
                        }
                    }
                    dataTableOper.Rows.Add(newRow);
                    //foreach (DataRow row in dataTable.Rows)
                    //{
                    //    dataTableOper.ImportRow(row);
                    //}
                    gridControl1.BeginUpdate();
                    this.gridControl1.DataSource = dataTableOper;

                    gridControl1.EndUpdate();
                    m_App.PublicMethod.ConvertGridDataSourceUpper(gridViewOper);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// 编辑手术信息界面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEditOperation_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridViewOper.FocusedRowHandle < 0)
                {
                    return;
                }
                DataRow dataRow = gridViewOper.GetDataRow(gridViewOper.FocusedRowHandle);
                if (dataRow == null)
                {
                    return;
                }
                DataTable dataTableOper = this.gridControl1.DataSource as DataTable;
                DataTable dataTable     = new DataTable();
                dataTable = dataTableOper.Clone();
                dataTable.ImportRow(dataRow);
                m_OperInfoFrom = new IemNewOperInfo(m_App, "edit", dataTable);
                if (m_OperInfoFrom.ShowDialog() == DialogResult.OK)
                {
                    m_OperInfoFrom.IemOperInfo = null;
                    DataTable dtReturn = m_OperInfoFrom.DataOper;
                    //遍历选中行所在表的列若返回表中有该行则更新选中行的该列
                    foreach (DataColumn item in dataRow.Table.Columns)
                    {
                        DataRow rowOper = m_OperInfoFrom.DataOper.Rows[0];
                        if (dtReturn.Columns.Contains(item.ColumnName))
                        {
                            dataRow[item.ColumnName] = rowOper[item.ColumnName].ToString();
                        }
                    }
                    gridControl1.BeginUpdate();
                    this.gridControl1.DataSource = dataTableOper;

                    gridControl1.EndUpdate();
                    m_App.PublicMethod.ConvertGridDataSourceUpper(gridViewOper);
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(1, ex);
            }
        }