예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dataGridViewIndex.SelectedCells.Count > 0)
            {
                if (MessageBox.Show(this, "Are you sure to delete this record?", "Delete Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    int    selectRow    = dataGridViewIndex.SelectedCells[0].RowIndex;
                    int    selectColumn = dataGridViewIndex.SelectedCells[0].ColumnIndex;
                    string guid         = dataGridViewIndex.Rows[selectRow].Cells[GUIDColumnIndex].Value.ToString();
                    string queryString  = QueryRuleControl.GetDeleteString(guid);
                    if (Program.DataAccess.ExecuteNoneQuery(queryString))
                    {
                        indexTable.Rows.Remove(indexTable.Rows[selectRow]);

                        RefreshTables();
                    }
                    if (dataGridViewIndex.SelectedCells.Count == 0 && dataGridViewIndex.Rows.Count > 0)
                    {
                        dataGridViewIndex.Rows[selectRow - 1].Selected = true;
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "Please Choose a record!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
        private bool ModifyRecord(GWDataDBTable recordType)
        {
            string queryString = "";

            if (recordType == GWDataDBTable.None)
            {
                return(false);;
            }
            if (recordType >= GWDataDBTable.Report)
            {
                queryString += QueryRuleControl.GetUpdateString(dataGridViewReport.Columns, dataGridViewReport.Rows[0], GWDataDBTable.Report);
            }
            if (recordType >= GWDataDBTable.Order)
            {
                queryString += QueryRuleControl.GetUpdateString(dataGridViewOrder.Columns, dataGridViewOrder.Rows[0], GWDataDBTable.Order);
            }
            if (recordType >= GWDataDBTable.Patient)
            {
                queryString += QueryRuleControl.GetUpdateString(dataGridViewPatient.Columns, dataGridViewPatient.Rows[0], GWDataDBTable.Patient);
                int index = indexTable.Rows.Count - 1;
                queryString += QueryRuleControl.GetUpdateString(dataGridViewIndex.Columns, dataGridViewIndex.Rows[index], GWDataDBTable.Index);
            }

            bool result = Program.DataAccess.ExecuteNoneQuery(queryString);

            return(result);
        }
예제 #3
0
        private void InitializationAdd()
        {
            string queryString = QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Index)
                                 + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Patient)
                                 + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Order)
                                 + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Report);

            DataSet ds = Program.DataAccess.ExecuteQuery(queryString);

            if (ds != null && ds.Tables.Count == 4)
            {
                #region Get Table Headers
                indexTable = ds.Tables[0];
                indexTable.DefaultView.AllowNew = false;
                dataGridViewIndex.DataSource    = indexTable;

                patientTable = ds.Tables[1];
                patientTable.DefaultView.AllowNew = false;
                dataGridViewPatient.DataSource    = patientTable;

                orderTable = ds.Tables[2];
                orderTable.DefaultView.AllowNew = false;
                dataGridViewOrder.DataSource    = orderTable;

                reportTable = ds.Tables[3];
                reportTable.DefaultView.AllowNew = false;
                dataGridViewReport.DataSource    = reportTable;
                #endregion

                SetUnNullColumns();

                #region Add a record to tables
                Guid     guid = Guid.NewGuid();
                DateTime now  = DateTime.Now;

                DataRow row = indexTable.NewRow();
                row[GWDataDBField.i_IndexGuid.FieldName]    = guid;
                row[GWDataDBField.i_DataDateTime.FieldName] = now;
                row[GWDataDBField.i_PROCESS_FLAG.FieldName] = 0;
                indexTable.Rows.Add(row);

                row = patientTable.NewRow();
                row[GWDataDBField.p_DATA_ID.FieldName] = guid;
                row[GWDataDBField.p_DATA_DT.FieldName] = now;

                patientTable.Rows.Add(row);

                row = orderTable.NewRow();
                row[GWDataDBField.o_DATA_ID.FieldName] = guid;
                row[GWDataDBField.o_DATA_DT.FieldName] = now;
                orderTable.Rows.Add(row);

                row = reportTable.NewRow();
                row[GWDataDBField.r_DATA_ID.FieldName] = guid;
                row[GWDataDBField.r_DATA_DT.FieldName] = now;
                reportTable.Rows.Add(row);
                #endregion
            }
        }
예제 #4
0
        private void InitializationDataTables()
        {
            string queryString = QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Patient)
                                 + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Order)
                                 + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Report);

            ShowTables(queryString);
        }
예제 #5
0
        private void SetDataTable(DataGridView dataGridView, ref DataTable dataTable, GWDataDBTable table)
        {
            string  queryString = QueryRuleControl.GetSelectRecordString(_guid, table);
            DataSet ds          = Program.DataAccess.ExecuteQuery(queryString);

            if (ds != null && ds.Tables.Count > 0)
            {
                dataTable = ds.Tables[0];
                dataTable.DefaultView.AllowNew = false;
                dataGridView.DataSource        = dataTable;
            }
        }
예제 #6
0
        private void GetGUIDColumnIndex()
        {
            string queryStr = QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Index);

            if (Program.DataAccess != null)
            {
                DataSet ds = Program.DataAccess.ExecuteQuery(queryStr);

                if (ds != null)
                {
                    GUIDColumnIndex = ds.Tables[0].Columns.IndexOf(GWDataDBField.i_IndexGuid.FieldName);
                }
            }
        }
예제 #7
0
        private void dataGridViewIndex_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string guid = dataGridViewIndex.Rows[e.RowIndex].Cells[GUIDColumnIndex].Value.ToString();

                string queryStr = QueryRuleControl.GetTablesString(guid);
                ShowTables(queryStr);

                dataGridViewPatient.ClearSelection();
                dataGridViewOrder.ClearSelection();
                dataGridViewReport.ClearSelection();

                dataGridViewIndex.Rows[e.RowIndex].Selected = true;
            }
        }
예제 #8
0
        private void DataManagerInitialization()
        {
            #region Data initialization
            int totalHeight = pTables.Height;
            pPatient.Height = totalHeight / 3;
            pOrder.Height   = totalHeight / 3;

            pLeft.Width = (pControl.Width - pMiddle.Width) / 2;
            this.dateTimePickerStart.Value = DateTime.Now;
            this.dateTimePickerEnd.Value   = DateTime.Now;
            #endregion

            #region Load default database data infomation
            if (!Program.DataAccess.TestDBConnection())
            {
                btnAdd.Enabled = false;
                MessageBox.Show("Connect To Database Failed");
            }
            else
            {
                //GetGUIDColumnIndex();
                #region Get today query scrpt
                SimpleQuery query = new SimpleQuery();
                DateTime    today = DateTime.Now;
                query.StartTime = new SimpleQueryItem(GWDataDBField.i_DataDateTime, today.ToString("yyyy-MM-dd 00:00:00.000"));
                query.EndTime   = new SimpleQueryItem(GWDataDBField.i_DataDateTime, today.ToString("yyyy-MM-dd 23:59:59.999"));
                string queryStr = QueryRuleControl.GetFilterString(query);
                #endregion

                if (ShowDataIndexTable(queryStr))
                {
                    InitializationDataTables();
                }
                else
                {
                    btnFilter.Enabled   = false;
                    btnAdvQuery.Enabled = false;
                    btnToday.Enabled    = false;
                    btnAdd.Enabled      = false;
                    Program.Log.Write(LogType.Warning, "Can't find the matched tables in database!");
                    MessageBox.Show(this, "Data Management is disable!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            #endregion
        }
예제 #9
0
        private void btnToday_Click(object sender, EventArgs e)
        {
            dtpStart.Checked = true;
            dtpEnd.Checked   = true;
            dtpStart.Value   = DateTime.Now;
            dtpEnd.Value     = DateTime.Now;

            SimpleQuery query = new SimpleQuery();
            DateTime    today = DateTime.Now;

            query.StartTime = new SimpleQueryItem(GWDataDBField.i_DataDateTime, today.ToString("yyyy-MM-dd 00:00:00.000"));
            query.EndTime   = new SimpleQueryItem(GWDataDBField.i_DataDateTime, today.ToString("yyyy-MM-dd 23:59:59.999"));

            string queryStr = QueryRuleControl.GetFilterString(query);

            ShowDataIndexTable(queryStr);
            RefreshTables();
        }
예제 #10
0
        //After add a new record to database, add a new record to the relevant dataTables and show them on the dataGridviews
        public void AfterAddRecord(DataTable table)
        {
            if (table != null && table.Rows.Count > 0)
            {
                DataRow row = indexTable.NewRow();

                int i = 0;
                foreach (object o in table.Rows[0].ItemArray)
                {
                    row[i] = o.ToString();
                    i++;
                }

                indexTable.Rows.Add(row);

                string guid     = dataGridViewIndex.Rows[indexTable.Rows.Count - 1].Cells[GUIDColumnIndex].Value.ToString();
                string queryStr = QueryRuleControl.GetTablesString(guid);
                ShowTables(queryStr);
            }
        }
예제 #11
0
 public string GetQueryString()
 {
     return(QueryRuleControl.GetFilterString(_filterItemList));
 }
예제 #12
0
 private string GetQueryStatement()
 {
     _filterInfo = new SimpleQuery();
     GenerateQueryInfo();
     return(QueryRuleControl.GetFilterString(_filterInfo));
 }
예제 #13
0
 public void CreatStatement(XCollection <QueryCriteriaItem> filterList)
 {
     txtStatement.Text       = QueryRuleControl.GetFilterString(filterList);
     parentControl.IsChanged = false;
 }