/// <summary> /// Event handler for when the MySQL connection changes. /// </summary> /// <param name="SENDER"></param> /// <param name="E"></param> private void CONNECTION_CHANGED(object SENDER, EventArgs E) { var CASTED_E = (MYSQL_COMS.CONNECTION_CHANGED_EVENT_ARGS)E; //Cast the EventArgs into a more specific type. if (CASTED_E.FULLY_CONNECTED == true) //If the connection is fully connected... { LBL_CONNECTION.Image = Properties.Resources.cloud_check_fill; LBL_CONNECTION.Text = "Connected to Host"; } else //If the connection is not fully connected... { DATABASE_CONNECTION_SWITCH(null); LBL_TABLE.Image = Properties.Resources.table; LBL_TABLE.Text = "No Table Selected"; LBL_CONNECTION.Image = Properties.Resources.cloud_slash_fill; LBL_CONNECTION.Text = "Disconnected from Host"; DGV_1.DataSource = null; DGV_1.Refresh(); } //Binary assignments. BTN_DISCONNECT.Enabled = CASTED_E.FULLY_CONNECTED; GRP_BOX_DB_CONNECTION.Enabled = CASTED_E.FULLY_CONNECTED; //Inverse binary assignments. BTN_CONNECT.Enabled = !CASTED_E.FULLY_CONNECTED; TXT_BOX_HOST.Enabled = !CASTED_E.FULLY_CONNECTED; TXT_BOX_PORT.Enabled = !CASTED_E.FULLY_CONNECTED; TXT_BOX_USER.Enabled = !CASTED_E.FULLY_CONNECTED; TXT_BOX_PASSWORD.Enabled = !CASTED_E.FULLY_CONNECTED; }
private void DGV_1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { if (DGV_1.Rows[e.RowIndex].Cells[0].Value == null || DGV_1.Rows[e.RowIndex].Cells[2].Value == null) { return; } if ((DGV_1.Rows[e.RowIndex].Cells[2] as DataGridViewComboBoxCell).Items.IndexOf(DGV_1.Rows[e.RowIndex].Cells[2].Value) == 0) { return; } com_Fields.Text = DGV_1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (DGV_1.Focused && DGV_1.CurrentCell.ColumnIndex == 3 && com_Fields.SelectedValue.ToString() == "datetime") { dtp.Location = DGV_1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location; dtp.Visible = true; if (DGV_1.CurrentCell.Value != null)// إذا كان يوجد قيمة { DateTime temp; if (DateTime.TryParse(DGV_1.CurrentCell.Value.ToString(), out temp))// هل القيمة تاريخ ؟ { dtp.Value = temp; } else { dtp.Value = DateTime.Today; dtp_Value_Changed(null, null); } } else { dtp.Value = DateTime.Today; dtp_Value_Changed(null, null); } } else { dtp.Visible = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, "DGV_1_CellEnter", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void DATABASE_CONNECTION_SWITCH(string NAME) { if (NAME == null) { LBL_DB_CONNECTION.Text = "Not connected to a DB"; LBL_DB_CONNECTION.Image = Properties.Resources.server_disconnected; GRP_BOX_DB_CONNECTION.Enabled = true; GRP_BOX_TABLE.Enabled = false; DGV_2.DataSource = null; DGV_2.Refresh(); } else { LBL_DB_CONNECTION.Text = string.Format("Connected to {0}", NAME); LBL_DB_CONNECTION.Image = Properties.Resources.server_connected; GRP_BOX_DB_CONNECTION.Enabled = false; DGV_1.DataSource = null; DGV_1.Refresh(); GRP_BOX_TABLE.Enabled = true; } }