private void CreateFields() { for (int i = 0; i < CurrentTable.GetCountName(); i++) { columns_field.Add(new TextBox()); } for (int i = 0; i < columns_field.Count; i++) { this.Controls.Add(this.columns_field[i]); } for (int i = 0; i < CurrentTable.GetCountName(); i++) { this.LabelTexte.Add(new Label()); this.Controls.Add(this.LabelTexte[i]); this.LabelTexte[i].Location = new System.Drawing.Point(this.x, this.y - 20); this.LabelTexte[i].Text = CurrentTable.GetColumnName(i); this.columns_field[i].Location = new System.Drawing.Point(this.x, this.y); this.columns_field[i].Name = this.CurrentTable.GetColumnName(i); this.columns_field[i].Size = new System.Drawing.Size(200, 20); this.columns_field[i].TabIndex = i; //this.x += 10; this.y += 50; } }
private bool DeleteSelected() { int count = currentDataGrid.SelectedItems.Count; bool res = false; MessageBoxResult result = MessageBoxResult.None; //Showing confirmation window only if selected items > 1 if (count > 1) { result = MessageBox.Show( $"About to delete {count} selected rows.\n\nProceed?", "Delete selection", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); } if (result != MessageBoxResult.No) { //Delete selected items from the table var items = currentDataGrid.SelectedItems; CurrentTable.MultipleDelete(items); res = true; } //Enabling Delete, Update &Select buttons in case the current table is not empty SetButtonsActivation(CurrentTable.Count > 0); SetRowCount(); return(res); }
public static void DeleteFromCurrentTable(List <string> vals) { if (vals.Count == 0) { return; } //Broker.table = currentTable; DeleteWindow dw = new DeleteWindow(); dw.StartPosition = FormStartPosition.CenterParent; dw.ShowDialog(); try { if (Broker.f) { CurrentTable.Prepare(); CurrentTable.Delete(vals); Broker.f = false; } } catch (Exception exp) { MessageBox.Show(exp.Message); } }
/// <summary> /// Sets the value for the row and column /// </summary> /// <param name="Index">Index.</param> /// <param name="CellName">Cell name.</param> /// <param name="value">Value.</param> public void SetValue(int Index, String CellName, object value) { if (Index != -1) { CurrentTable.SetValue(Index, CellName, value); } }
private void addNewTab_Clicked(object sender, MouseButtonEventArgs e) { var items = currentDataGrid.SelectedItems; NewTableTab newTableTab = new NewTableTab(items.Count > 0, new List <string>(tableList.Keys)); //Showing the dialog window for new table tab creation if (newTableTab.ShowDialog() == true) { //Create new tab & table CreateNewTable(newTableTab.TableName); if (newTableTab.includeSelected.IsChecked == true) { //Copying the selected items from the last tab foreach (Customer item in items) { CurrentTable.Insert(item); } RefreshGrid(); //Enabling Delete, Update &Select buttons SetButtonsActivation(true); SetSelectedRowCount(); SetRowCount(); } } }
private void AddElement() { using (AddElementDialog dialog = new AddElementDialog()) { dialog.EnsureButtonClick += (sender1, e1) => { List <ElementModel> emb = new List <ElementModel>(); int span = GetSpan(dialog.DataType); for (int j = 0, i = 0; j < dialog.AddNums; i += span, j++) { ElementModel ele = new ElementModel(dialog.IntrasegmentType != string.Empty, dialog.DataType); ele.AddrType = dialog.AddrType; ele.DataType = dialog.DataType; ele.StartAddr = (uint)(dialog.StartAddr + i); ele.IntrasegmentType = dialog.IntrasegmentType; ele.IntrasegmentAddr = dialog.IntrasegmentAddr; emb.Add(ele); } Manager.Add(emb); foreach (ElementModel ele in emb) { CurrentTable.AddElement( Manager.Get(ele)); } dialog.Close(); }; dialog.ShowDialog(); } }
public CreateNewRow(SQLExecuter executer, DataGridView dataGridView, CurrentTable currentTable) { InitializeComponent(); Executer = executer; CurrentTable = currentTable; DialogResult = DialogResult.Cancel; dataGridView_AddRow.AllowUserToAddRows = false; dataGridView_AddRow.AllowUserToDeleteRows = false; string columnName; for (int i = 0; i < dataGridView.ColumnCount; i++) { columnName = dataGridView.Columns[i].Name; if (currentTable.Dependences.Dependence.ContainsKey(columnName)) { dataGridView_AddRow.Columns.Add( new DataGridViewComboBoxColumn() { DataSource = currentTable.Dependences.Dependence[columnName] }); } else { dataGridView_AddRow.Columns.Add(dataGridView.Columns[i].Name, dataGridView.Columns[i].Name); } } dataGridView_AddRow.Rows.Add(); }
private void selectBtn_Click(object sender, RoutedEventArgs e) { var currentTabItem = (TabItem)tableTabControl.SelectedItem; string currentTableName = currentTabItem.Header.ToString(); var tableNames = (new List <string>(tableList.Keys)); tableNames.Remove(currentTableName); SelectWindow selectWindow = new SelectWindow(CurrentTable, tableNames); if (selectWindow.ShowDialog() == true) { if (selectWindow.newTable) { CreateNewTable("selected items " + ++selectionTabCount); } else { var selectedTab = tableTabControl.Items.OfType <TabItem>().SingleOrDefault(n => n.Header.ToString().Equals(selectWindow.SelectedTable)); selectedTab.IsSelected = true; } CurrentTable.Insert(selectWindow.ResultDB); //Enabling Delete, Update &Select buttons SetButtonsActivation(true); RefreshGrid(); SetSelectedRowCount(); SetRowCount(); } }
//Single pixel paint public bool Paint(Vector2Int pos, CellType c, EPaintType paintType = EPaintType.PAINT_NEXT) { if (pos.X < 0 || pos.X >= TableSize.X || pos.Y < 0 || pos.Y >= TableSize.Y) { return(false); } CellType prev = CurrentTable.Cells[pos.X, pos.Y].CellType; bool result = false; switch (paintType) { case EPaintType.PAINT_NEXT: result = NextIterationTable.PlaceCell(pos, c); break; case EPaintType.PAINT_CURRENT: result = CurrentTable.PlaceCell(pos, c); break; } if (result && prev != c) { Delta.Add(pos); } return(result); }
public static void InsertIntoCurrentTable() { InsertWindows[CurrentInd].StartPosition = FormStartPosition.CenterParent; Broker.table = CurrentTable; CurrentTable.Prepare(); InsertWindows[CurrentInd].ShowDialog(); //if (Broker.f) { currentTable.Add(Broker.vals); Broker.f = false; } }
private void loadFromSQLBtn_Click(object sender, RoutedEventArgs e) { CurrentTable.Insert(LoadFromSQL.Load()); //Enabling Delete, Update & Select buttons SetButtonsActivation(true); RefreshGrid(); SetRowCount(); }
public void CreateLabels() { for (int i = 0; i < CurrentTable.GetCountName(); i++) { this.LabelTexte.Add(new Label()); this.Controls.Add(this.LabelTexte[i]); } }
static void AddDeviceTables(WordprocessingDocument Certificate, UserSession Session, TablesCreator Creator, string DeviceType, CardData DeviceCard, DateTime StartDateOfService) { //WordprocessingDocument CalibrationProtocol = GetDocument(Session, DeviceCard, StartDateOfService, CalibrationProtocolCategoryID); //XtraMessageBox.Show("DeviceType = " + DeviceType); IEnumerable <CertificateTableLook> TablesCollection = Creator.CertificateDeviceTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для прибра '" + DeviceType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { Dictionary <String, Table> TablesList = new Dictionary <String, Table>(); foreach (CertificateTableLook CurrentTable in TablesCollection) { WordprocessingDocument ParentDocument; string TempPath = ""; switch (CurrentTable.ParentDocumentCategory) { case CertificateTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.AcceptanceTestingProtocolCategoryID, out TempPath); break; case CertificateTableLook.DocumentCategory.CalibrationProtocol: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.CalibrationProtocolCategoryID, out TempPath); break; case CertificateTableLook.DocumentCategory.MeasuringData: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.MeasuringDataCategoryID, out TempPath); break; default: ParentDocument = null; break; } if (TablesList.Any(r => r.Key == CurrentTable.TableName)) { CurrentTable.AdditionDeviceTable(ParentDocument, TablesList.First(r => r.Key == CurrentTable.TableName).Value); } else { TablesList.Add(CurrentTable.TableName, CurrentTable.GetDeviceTable(ParentDocument)); } //Certificate.MainDocumentPart.Document.Body.Append(CurrentTable.GetDeviceTable(ParentDocument)); //Certificate.MainDocumentPart.Document.Body.Append(CalibrationLib.NewParagraph(0, 0, JustificationValues.Left, 10)); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } foreach (KeyValuePair <String, Table> T in TablesList) { Certificate.MainDocumentPart.Document.Body.Append(T.Value); } } }
public void SaveTable() { if (!IsTableOpened) { return; } DataTable rows = EditingTable.GetChanges(); if (rows == null) { return; } BdatMember[] members = CurrentTable.Members; foreach (DataRow row in rows.Rows.Cast <DataRow>()) { int itemId = int.Parse((string)row.ItemArray[0]); for (int m = 0; m < members.Length; m++) { if (members[m].Type != BdatMemberType.Scalar) { continue; } string value = (string)row.ItemArray[m + 1]; try { CurrentTable.WriteValue(itemId, members[m].Name, value); } catch (Exception ex) { string caption = null; if (ex is ArgumentOutOfRangeException) { caption = "Replacement string was too large to fit in the original space."; } if (ex is FormatException || ex is OverflowException) { caption = $"Error parsing \"{value}\" as a {members[m].ValType} " + $"from Item \"{itemId}\" Column \"{members[m].Name}\"."; } if (caption == null) { throw; } MessageBox.Show(caption, "Format Error"); } } } File.WriteAllBytes(Filename, BdatTables.FileData); EditingTable.AcceptChanges(); }
/// <summary> /// Updates the selection /// </summary> /// <param name="index">Index.</param> public void UpdateSelection(int index) { var aRow = CurrentTable.GetRow(index); if (aRow != null) { UpdateSelection(aRow.RowId); } }
private void updateBtn_Click(object sender, RoutedEventArgs e) { UpdateWindow updateWindow = new UpdateWindow(CurrentTable); if (updateWindow.ShowDialog() == true) { CurrentTable.Update(updateWindow.ResultDB); RefreshGrid(); } }
private void DeleteElement() { var temp = new List <ElementModel>(CurrentTable.ElementDataGrid.SelectedItems.OfType <ElementModel>()); Manager.Remove(temp); foreach (ElementModel item in temp) { CurrentTable.DeleteElement(item); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.SuspendLayout(); // // Form2 // this.ClientSize = new System.Drawing.Size(284, (this.y * CurrentTable.GetCountName() + 80)); this.Name = "Form2"; this.ResumeLayout(false); }
// Addition Of Data Of Settings private void AdditionOfDataOfSettings(DataSet StructureForSending) { // Checking if (_Settings != null) { // Addition Of Tables Of Settings foreach (DataTable CurrentTable in _Settings.Tables) { StructureForSending.Tables.Add(CurrentTable.Copy()); } } }
static void AddAdditionalTables(WordprocessingDocument Certificate, TablesCreator Creator, string DeviceType) { IEnumerable <CertificateTableLook> TablesCollection = Creator.CertificateAdditionalTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() > 0) { foreach (CertificateTableLook CurrentTable in TablesCollection) { Certificate.MainDocumentPart.Document.Body.Append(CurrentTable.GetDeviceTable(null)); //Certificate.MainDocumentPart.Document.Body.Append(CalibrationLib.NewParagraph(0, 0, JustificationValues.Left, 10)); } } }
public static void UpdateCurrentTable(List <string> oldValues) { if (oldValues.Count == 0) { return; } Broker.vals = oldValues; Broker.table = CurrentTable; CurrentTable.Prepare(); UpdateWindows[CurrentInd].StartPosition = FormStartPosition.CenterParent; UpdateWindows[CurrentInd].ShowDialog(); }
private void deleteBtn_Click(object sender, RoutedEventArgs e) { DeleteWindow deleteWindow = new DeleteWindow(CurrentTable); if (deleteWindow.ShowDialog() == true) { CurrentTable.MultipleDelete(deleteWindow.ResultDB); //Enabling Delete, Update &Select buttons in case the current table is not empty SetButtonsActivation(CurrentTable.Count > 0); SetRowCount(); RefreshGrid(); } }
// Addition Of Data Of Settings private void AdditionOfDataOfSettings(DataSet StructureForSending) { // if (ManagementOfSettings.GettingAllSettings != null) { // // Addition Of Tables Of Settings // foreach (DataTable CurrentTable in ManagementOfSettings.GettingAllSettings.Tables) { StructureForSending.Tables.Add(CurrentTable.Copy()); } } }
/// <summary> /// Gets the value. /// </summary> /// <returns>The value.</returns> /// <param name="Index">Index.</param> /// <param name="CellName">Cell name.</param> public DSDataValue GetValue(int Index, String CellName) { if (Index == -1) { return(new DSDataValue() { ColumnName = CellName, Value = Columns [CellName].Caption }); } else { return(CurrentTable.GetValue(Index, CellName)); } }
/// <summary> /// Updates the selection, with multi-select /// </summary> /// <param name="Indexes">Indexes.</param> public void UpdateSelection(int[] Indexes) { if (Indexes == null) { mSelectedRowGuids.Clear(); return; } var rows = CurrentTable.GetRows(Indexes); var rowIds = from e in rows select e.RowId; UpdateSelection(rowIds.ToArray()); }
public void CompileVarDec(TypeName type, SyntaxTreeNode node) { string name = node[0].ValueString; if (CurrentTable.Contains(name)) { ErrorManager.ExitWithError(new Exception("Duplicate ID: " + name)); } CodeSymbol symbol = builder.AddLocal(name, type);//CurrentTable.AddSymbol(new CodeSymbol(name, node[2].ValueString)); if (node.Children.Length > 1) { builder.AddInstruction(new InterCopy(symbol, ToIntermediateExpression(node[1]))); } }
static void AddSensorTables(WordprocessingDocument Protocol, UserSession Session, TablesCreator Creator, string SensorType, CardData SensorCard, DateTime StartDateOfService, string DeviceTypeName) { string SensorNumber = SensorCard.GetDeviceNumber(); IEnumerable <VerificationProtocolTableLook> TablesCollection = Creator.VerificationProtokolSensorTablesCollection.Where(r => r.DeviceTypes.Any(s => s == SensorType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для датчика '" + SensorType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { foreach (VerificationProtocolTableLook CurrentTable in TablesCollection) { WordprocessingDocument ParentDocument; string TempPath = ""; switch (CurrentTable.ParentDocumentCategory) { case VerificationProtocolTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.AcceptanceTestingProtocolCategoryID, out TempPath); break; case VerificationProtocolTableLook.DocumentCategory.CalibrationProtocol: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.CalibrationProtocolCategoryID, out TempPath); break; case VerificationProtocolTableLook.DocumentCategory.MeasuringData: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.MeasuringDataCategoryID, out TempPath); break; default: ParentDocument = null; break; } Table NewSensorTable = CurrentTable.GetSensorsTable(ParentDocument, SensorNumber, DeviceTypeName); AddNewTable(Protocol, NewSensorTable, Protocol.GetTable("Заключение:").ElementsBefore().Last()); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } } return; }
private void insertBtn_Click(object sender, RoutedEventArgs e) { InsertWindow insertWindow = new InsertWindow(CurrentTable); //Showing the insert window dialog if (insertWindow.ShowDialog() == true) { Customer customer = new Customer(insertWindow.customerIdBox.Text, insertWindow.companyNameBox.Text, insertWindow.contactNameBox.Text, insertWindow.phoneNumberBox.Text); //Insert the user input data CurrentTable.Insert(customer); RefreshGrid(); //Enabling Delete, Update &Select buttons SetButtonsActivation(true); SetRowCount(); } }
static void AddSensorTables(WordprocessingDocument Certificate, UserSession Session, TablesCreator Creator, string DeviceType, string DeviceNumber, CardData DeviceCard, DateTime StartDateOfService) { IEnumerable <CertificateTableLook> TablesCollection = Creator.CertificateSensorTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для датчика '" + DeviceType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { foreach (CertificateTableLook CurrentTable in TablesCollection) { WordprocessingDocument ParentDocument; string TempPath = ""; switch (CurrentTable.ParentDocumentCategory) { case CertificateTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.AcceptanceTestingProtocolCategoryID, out TempPath); break; case CertificateTableLook.DocumentCategory.CalibrationProtocol: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.CalibrationProtocolCategoryID, out TempPath); break; case CertificateTableLook.DocumentCategory.MeasuringData: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.MeasuringDataCategoryID, out TempPath); break; default: ParentDocument = null; break; } Certificate.MainDocumentPart.Document.Body.Append(CurrentTable.GetSensorsTable(ParentDocument, DeviceNumber)); //Certificate.MainDocumentPart.Document.Body.Append(CalibrationLib.NewParagraph(0, 0, JustificationValues.Left, 10)); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } } }
private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { //Get the dataGrid that called the event DataGrid dataGrid = sender as DataGrid; if (e.EditAction == DataGridEditAction.Commit) { var column = e.Column as DataGridBoundColumn; if (column != null) { var newValue = (e.EditingElement as TextBox).Text; //Don't allow empty fields because MyDB does not support that. if (newValue == "") { currentDataGrid.CancelEdit(); return; } DataGridCellInfo selected = dataGrid.SelectedCells[0]; string selectedId = ((Customer)selected.Item).CustomerID; Customer customer = new Customer(selectedId, "", "", ""); if (column.Header.Equals("CompanyName")) { customer.CompanyName = newValue; } if (column.Header.Equals("ContactName")) { customer.ContactName = newValue; } if (column.Header.Equals("Phone")) { customer.Phone = newValue; } CurrentTable.UpdateByID(customer); } } }