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); } }
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); }
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 } }
private void InitializationDataTables() { string queryString = QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Patient) + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Order) + QueryRuleControl.GetHeadersQueryString(GWDataDBTable.Report); ShowTables(queryString); }
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; } }
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); } } }
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; } }
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 }
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(); }
//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); } }
public string GetQueryString() { return(QueryRuleControl.GetFilterString(_filterItemList)); }
private string GetQueryStatement() { _filterInfo = new SimpleQuery(); GenerateQueryInfo(); return(QueryRuleControl.GetFilterString(_filterInfo)); }
public void CreatStatement(XCollection <QueryCriteriaItem> filterList) { txtStatement.Text = QueryRuleControl.GetFilterString(filterList); parentControl.IsChanged = false; }