private void SetNewKeyPadButtonProperties(KeypadButton oldButton, ref KeypadButton newButton) { newButton.ActionText = oldButton.ActionText; newButton.Font = oldButton.Font; newButton.ID = oldButton.ID; newButton.IndexLocation = oldButton.IndexLocation; newButton.Location = oldButton.Location; newButton.Name = oldButton.Name; newButton.Screen = oldButton.Screen; newButton.Size = oldButton.Size; newButton.TabIndex = oldButton.TabIndex; newButton.UseVisualStyleBackColor = oldButton.UseVisualStyleBackColor; newButton.Enabled = true; newButton.Click += KeyPressed; }
private bool SetButtonAtIndexLocation(KeypadButton value, Control.ControlCollection controls = null) { if (controls == null) controls = this.Controls; for (int i = 0; i < controls.Count - 1; i++) { Control c = controls[i]; if (c.Tag != null) { int tag = -1; int.TryParse(c.Tag.ToString(), out tag); if (tag == value.IndexLocation) { c.Text = value.Text; value.SetInheritedProperties(c); c = value; return true; } } if (c.HasChildren) SetButtonAtIndexLocation(value, controls); //Recursively check all children controls as well; ie groupboxes or tabpages } return false; }
protected virtual void OnWiperBladesClicked(KeypadButton sender, EventArgs e) { EventHandler handler = WiperBladesClicked; if (handler != null) { handler(sender, e); } }
private bool SetButtonAtIndexLocation(KeypadButton value, Control.ControlCollection controls = null) { if (controls == null) controls = this.Controls; for (int i = 0; i < controls.Count; i++) { Control c = controls[i]; if (c.GetType() == typeof(KeypadButton)) { KeypadButton oldButton = (KeypadButton)c; if (oldButton.IndexLocation == value.IndexLocation) { SetNewKeyPadButtonProperties(oldButton, ref value); this.Controls.Remove(c); this.Controls.Add(value); return true; } } if (c.HasChildren) SetButtonAtIndexLocation(value, controls); //Recursively check all children controls as well; ie groupboxes or tabpages } return false; }
protected virtual void OnOilChangeClicked(KeypadButton sender, EventArgs e) { EventHandler handler = OilChangeClicked; if (handler != null) { handler(sender, e); } }
protected virtual void OnTireRotationClicked(KeypadButton sender, EventArgs e) { EventHandler handler = TireRotationClicked; if (handler != null) { handler(sender, e); } }
protected virtual void OnNotActionStarterClicked(KeypadButton sender, NotActionStartEventArgs e) { EventHandler<NotActionStartEventArgs> handler = NotActionStarterClicked; if (handler != null) { handler(sender, e); } }
protected virtual void OnBatteryReplacementClicked(KeypadButton sender, EventArgs e) { EventHandler handler = BatteryReplacementClicked; if (handler != null) { handler(sender, e); } }
protected virtual void OnAirFilterClicked(KeypadButton sender, EventArgs e) { EventHandler handler = AirFilterClicked; if (handler != null) { handler(sender, e); } }
//FillButtons into GlobalVar, identifying ServiceTypes as Actions. public void FillButtons() { OleDbConnection dbConnection = null; OleDbCommand dbCommand = null; string syntax = "SELECT * FROM tblKeyPadButtons"; OleDbDataReader dbReader = null; List<KeypadButton> buttons = new List<KeypadButton>(); try { dbConnection = new OleDbConnection(connectionString); } catch (Exception ex) { throw ex; } try { dbCommand = new OleDbCommand(syntax, dbConnection); } catch (Exception ex) { throw ex; } try { dbConnection.Open(); } catch (Exception ex) { throw ex; } try { dbReader = dbCommand.ExecuteReader(); } catch (Exception ex) { throw ex; } try { while (dbReader.Read()) { KeypadButton button = new KeypadButton(); int id = -1; int location; int.TryParse(dbReader[0].ToString(), out id); if (id != -1) { button.ID = id; button.Screen = dbReader[1].ToString(); int actionType = -1; int.TryParse(dbReader[2].ToString(), out actionType); if (actionType == 0) { actionType = (int)Actions.NotActionStarter; } button.ActionType = (Actions)actionType; button.Text = dbReader[3].ToString(); int.TryParse(dbReader[4].ToString(), out location); button.IndexLocation = location; } buttons.Add(button); } } catch (Exception ex) { throw ex; } try { dbReader.Close(); dbReader.Dispose(); dbCommand.Dispose(); dbConnection.Close(); dbConnection.Dispose(); } catch (Exception ex) { throw ex; } GlobalVariables.KeyPadButtons = buttons; }
//CreateButton public int CreateButton(KeypadButton iKeyPadButton) { OleDbConnection dbConnection = null; OleDbCommand dbCommand = null; StringBuilder syntaxBuilder = new StringBuilder(); syntaxBuilder.Append("INSERT INTO tblKeyPadButtons (Screen, ServiceCode, ActionText, Location) VALUES ("); syntaxBuilder.Append("'" + iKeyPadButton.Screen + "',"); //syntaxBuilder.Append("'" + iKeyPadButton.ServiceCode + "',"); //SERVICECODE //HANDLE syntaxBuilder.Append("'" + iKeyPadButton.Text + "',"); syntaxBuilder.Append("'" + iKeyPadButton.IndexLocation + "'"); syntaxBuilder.Append(")"); string syntax = syntaxBuilder.ToString(); try { dbConnection = new OleDbConnection(connectionString); dbConnection.Open(); } catch (Exception) { throw; } try { dbCommand = new OleDbCommand(syntax, dbConnection); } catch (Exception) { throw; } try { dbCommand.ExecuteNonQuery(); } catch (Exception) { throw; } int newID = -1; try { dbCommand.CommandText = "Select @@Identity"; newID = (int)dbCommand.ExecuteScalar(); } catch (Exception) { throw; } dbCommand.Dispose(); dbCommand = null; dbConnection.Close(); dbConnection.Dispose(); dbConnection = null; return newID; }