private void SQL_Click(object sender, EventArgs e) { //OleDbConnection conn = new OleDbConnection(); //conn.ConnectionString = gConnect; //conn.Open(); DataTable dt = functions.ExecuteSQLQuery(TextBox1.Text); DataGridView1.ClearSelection(); DataGridView1.DataSource = dt; // DataGridView1.ClearSelection(); // DataGridView1.DataSource = ds; // DataGridView1.DataMember = "PEL"; // //GridView1.Columns(STHLHTOY_ID).Width = 0 // // DataGridView1.Columns(STHLHTOY_ID).Visible = False //} catch (SqlException ex) { // Interaction.MsgBox(ex.ToString); //} finally { // // Close connection // conn.Close(); }
private void ColorPickEdit1_EditValueChanged(object sender, EventArgs e) { if (ChangeColorDirext == false) { Button2.BackColor = ColorPickEdit1.Color; } else { if (DataGridView1.Rows.Count > 0) { DataGridView1.CurrentRow.Cells[11].Value = ColorPickEdit1.Color.ToArgb().ToString(); DataGridView1.CurrentRow.Cells[12].Style.BackColor = ColorPickEdit1.Color; Panel4.Controls.Find(DataGridView1.CurrentRow.Cells[1].Value.ToString(), true)[0].BackColor = ColorPickEdit1.Color; ChangeColorDirext = false; DataGridView1.ClearSelection(); txtDescripcion.Text = "Mesa " + (NumControlsInteger() + 1); ColorPickEdit1.Color = SystemColors.Control; txtLocacion.Clear(); txtLocacionY.Clear(); txtLocacionX.Clear(); txtDescripcion.Focus(); txtDescripcion.SelectAll(); txtTag.Clear(); txtTamañoHeight.Text = "70"; txtTamañoWidth.Text = "120"; txtName.Clear(); DataGridView1.ClearSelection(); } } }
private void btnModificar_Click(object sender, EventArgs e) { if (!(string.IsNullOrEmpty(Label7.Text))) { if (Panel4.Controls.Count > 0) { foreach (DataGridViewRow Row in DataGridView1.Rows) { if (Row.Cells[1].Value.ToString() == Label7.Text) { if (Convert.ToBoolean(Row.Cells[15].Value) == true) { MessageBox.Show(this, "La " + Convert.ToString(Row.Cells[2].Value) + " está incluído para mover en grupos." + Environment.NewLine + Environment.NewLine + "Por favor deseleccione esta opción para modificarla.", "Mesa incluída", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (Row.Cells[0].Value == null) { IDMesaM = ""; DataGridView1.Rows.Remove(Row); } else { IDMesaM = Convert.ToString(Row.Cells[0].Value.ToString()); cbxTipoMesa.Text = Row.Cells[14].Value.ToString(); DataGridView1.Rows.Remove(Row); } } } } txtDescripcion.Text = this.Controls.Find(Label7.Text, true)[0].Text; txtLocacion.Text = this.Controls.Find(Label7.Text, true)[0].Location.ToString(); txtLocacionX.Text = this.Controls.Find(Label7.Text, true)[0].Location.X.ToString(); txtLocacionY.Text = this.Controls.Find(Label7.Text, true)[0].Location.Y.ToString(); txtTamañoHeight.Text = this.Controls.Find(Label7.Text, true)[0].Size.Height.ToString(); txtTamañoWidth.Text = this.Controls.Find(Label7.Text, true)[0].Size.Width.ToString(); TrackBar1.Value = this.Controls.Find(Label7.Text, true)[0].Size.Width; TrackBar2.Value = this.Controls.Find(Label7.Text, true)[0].Size.Height; ColorPickEdit1.Color = this.Controls.Find(Label7.Text, true)[0].BackColor; txtName.Text = this.Controls.Find(Label7.Text, true)[0].Name; txtTag.Text = Convert.ToString(this.Controls.Find(Label7.Text, true)[0].Tag); Button2.BackColor = this.Controls.Find(Label7.Text, true)[0].BackColor; Panel4.Controls.Remove(this.Controls.Find(Label7.Text, true)[0]); Label7.Text = ""; Label5.Text = "Cant. de Mesas: " + NumControlsInteger(); DataGridView1.ClearSelection(); } } }
private void ClickButton(object sender, MouseEventArgs e) { Button TmpButton = new Button(); TmpButton = (dynamic)sender; Label7.Text = TmpButton.Name; foreach (DataGridViewRow Row in DataGridView1.Rows) { if (Row.Cells[1].Value.ToString() == TmpButton.Name) { DataGridView1.ClearSelection(); DataGridView1.Rows[Row.Index].Selected = true; DataGridView1.FirstDisplayedScrollingRowIndex = Row.Index; } } }
private void CambioScripts() { EScript PVAnt = default(EScript); EScript PVDes = default(EScript); int Antes = 0; int Despues = 0; Antes = Convert.ToInt32(TxtIdScript.Text); Despues = Convert.ToInt32(TxtCambio.Text); if ((ListaScripts.Exists(x => x.IdScript == Despues))) { PVAnt = ListaScripts.Find(x => x.IdScript == Antes); PVDes = ListaScripts.Find(x => x.IdScript == Despues); PVAnt.IdScript = Despues; PVDes.IdScript = Antes; } else { System.Windows.Forms.MessageBox.Show("No existe el indice de script indicado, favor verificar"); TxtCambio.Text = ""; TxtCambio.Focus(); return; } RecargarTabla(); Metodo2(); TxtCambio.Text = ""; TxtCambio.Visible = false; CheckBox1.Checked = false; TxtIdScript.Enabled = false; TxtScript.Enabled = false; CheckBox1.Visible = true; TxtIdScript.Focus(); DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.RowCount - 1; DataGridView1.ClearSelection(); DataGridView1.Rows[DataGridView1.RowCount - 1].Selected = true; TxtIdScript.Text = DataGridView1.Rows[DataGridView1.RowCount - 1].Cells[0].Value.ToString(); TxtScript.Text = DataGridView1.Rows[DataGridView1.RowCount - 1].Cells[1].Value.ToString(); BtnNuevo.Text = "Incorporar"; }
private void DataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { // Workaround to fire CellValueChanged on a Checkbox change via mouse (left click) by switching cell focus if ((e.RowIndex < 0) || (e.ColumnIndex < 0)) { return; } if (DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].GetType().Name == "DataGridViewCheckBoxCell") { // Care with changing the following sequence as during lots of testing // this is the first and only combination that works in Windows and Mono.. om.DataUpdatePending = true; DataGridView1.EndEdit(); DataGridView1.ClearSelection(); om.DataUpdatePending = false; DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true; DataGridView1.Rows[e.RowIndex].Selected = true; } }
private void DataGridView1_KeyUp(object sender, KeyEventArgs e) { // Workaround to fire CellValueChanged on a Checkbox change via keyboard (space) by switching cell focus if (e.KeyCode == Keys.Space) { foreach (DataGridViewCell cell in DataGridView1.SelectedCells) { if (cell.GetType().Name == "DataGridViewCheckBoxCell") { DataGridViewCheckBoxCell SelectedCell = (DataGridViewCheckBoxCell)cell; e.Handled = true; // Care with changing the following sequence as during lots of testing // this is the first and only combination that works in Windows and Mono.. om.DataUpdatePending = true; SelectedCell.Value = !(SelectedCell.Value == null ? /*not set yet, so it's not checked*/ false : (bool)SelectedCell.Value); om.DataUpdatePending = false; DataGridView1.EndEdit(); DataGridView1.ClearSelection(); DataGridView1.Rows[SelectedCell.RowIndex].Cells[SelectedCell.ColumnIndex].Selected = true; } } } }
private void btnAdd_Click(object sender, EventArgs e) { foreach (Control Ctrl in Panel4.Controls) { Ctrl.SendToBack(); } Button NewControl = new Button(); NewControl.Name = "Table" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHMMssfff"); NewControl.Tag = "Table" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHMMssfff"); NewControl.Size = Button2.Size; NewControl.AutoSize = false; NewControl.Text = Button2.Text; NewControl.BackColor = ColorPickEdit1.Color; if (string.IsNullOrEmpty(txtLocacion.Text)) { NewControl.Top = ((Panel4.Height / 2) - (NewControl.Height / 2)) + (5 * NumControlsInteger()); NewControl.Left = ((Panel4.Width / 2) - (NewControl.Width / 2)) + (5 * NumControlsInteger()); } else { NewControl.Top = Convert.ToInt16(txtLocacionY.Text); NewControl.Left = Convert.ToInt16(txtLocacionX.Text); } NewControl.Cursor = Cursors.Hand; NewControl.Tag = Button2.Text; NewControl.BringToFront(); NewControl.MouseMove += new MouseEventHandler(MovingButton); NewControl.MouseDown += new MouseEventHandler(DowningButton); NewControl.MouseUp += new MouseEventHandler(UppingButton); NewControl.MouseClick += new MouseEventHandler(ClickButton); Panel4.Controls.Add(NewControl); DataGridView1.Rows.Add(IDMesaM, NewControl.Name, NewControl.Text, txtOrden.Text, NewControl.Location.ToString(), NewControl.Location.X.ToString(), NewControl.Location.Y.ToString(), NewControl.Size.ToString(), NewControl.Size.Width.ToString(), NewControl.Size.Height.ToString(), NewControl.Tag, ColorPickEdit1.Color.ToArgb(), "", cbxTipoMesa.SelectedValue.ToString(), cbxTipoMesa.Text, false); foreach (DataGridViewRow row in DataGridView1.Rows) { row.Cells[12].Style.BackColor = Color.FromArgb(Convert.ToInt32(row.Cells[11].Value)); } NumControlsInteger(); Label5.Text = "Cant. de Mesas: " + NumControlsInteger(); IDMesaM = ""; ChangeColorDirext = false; txtDescripcion.Text = "Mesa " + (NumControlsInteger() + 1); ColorPickEdit1.Color = SystemColors.Control; txtLocacion.Clear(); txtLocacionY.Clear(); txtLocacionX.Clear(); txtDescripcion.Focus(); txtDescripcion.SelectAll(); txtTag.Clear(); txtTamañoHeight.Text = "70"; txtTamañoWidth.Text = "120"; txtName.Clear(); DataGridView1.ClearSelection(); }
private void BtnNuevo_Click_1(object sender, EventArgs e) { if ((BtnNuevo.Text == "Reubicar")) { CargaDiccionario(); ReacomodarScript2(); RecargarTabla(); Metodo2(); LblCambio.Text = "Indice Script a cambiar"; LblCambio.Visible = false; TxtCambio.Text = ""; TxtCambio.Visible = false; CheckBox1.Checked = false; TxtIdScript.Enabled = false; TxtScript.Enabled = false; CheckBox1.Visible = true; TxtIdScript.Focus(); CheckBox2.Checked = false; BtnModificar.Enabled = true; //DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.RowCount - 1 //DataGridView1.ClearSelection() //DataGridView1.Rows(DataGridView1.RowCount - 1).Selected = True //TxtIdScript.Text = DataGridView1.Rows(DataGridView1.RowCount - 1).Cells(0).Value.ToString() //TxtScript.Text = DataGridView1.Rows(DataGridView1.RowCount - 1).Cells(1).Value.ToString() BtnNuevo.Text = "Incorporar"; return; } if ((BtnNuevo.Text == "Cambio")) { CargaDiccionario(); CambioScripts(); BtnModificar.Enabled = true; return; } if ((BtnNuevo.Text == "Incorporar")) { BtnNuevo.Text = "Registrar"; TxtIdScript.Enabled = true; TxtScript.Enabled = true; ComboBox1.Enabled = true; CbxTipoBorrado.Enabled = true; TxtIdScript.Text = ""; TxtScript.Text = ""; CheckBox1.Visible = false; CheckBox1.Checked = false; TxtIdScript.Focus(); BtnModificar.Enabled = false; IndiceBorrado.Maximum = CantMaxBorrado + 1; IndiceBorrado.Value = CantMaxBorrado + 1; return; } //Dim pv As Script //While (maximo >= nIdScript) // IdScript = Convert.ToString(maximo) // pv = ListaScripts.Find(Function(x) x.IdScript = maximo) // pv.IdScript = Convert.ToString(maximo + 1) if (((TxtIdScript.Text.Length <= 0) | (TxtScript.Text.Length <= 0))) { System.Windows.Forms.MessageBox.Show("Debe completar los datos"); return; } if (((Convert.ToInt32(TxtIdScript.Text) > DataGridView1.RowCount) & ((Convert.ToInt32(TxtIdScript.Text) - DataGridView1.RowCount) >= 2))) { System.Windows.Forms.MessageBox.Show("El indice del script por ingresar debe ser consecutivo al ultimo registrado"); TxtIdScript.Text = ""; TxtScript.Text = ""; TxtIdScript.Focus(); return; } if ((Convert.ToInt32(TxtIdScript.Text) < 1)) { System.Windows.Forms.MessageBox.Show("Id Script no valido"); TxtIdScript.Text = ""; TxtScript.Text = ""; TxtIdScript.Focus(); return; } CargaDiccionario(); ReacomodarScript(); RecargarTabla(); Metodo2(); TxtIdScript.Text = ""; TxtScript.Text = ""; BtnModificar.Enabled = true; TxtIdScript.Enabled = false; TxtScript.Enabled = false; ComboBox1.Enabled = false; CbxTipoBorrado.Enabled = false; CheckBox1.Visible = true; TxtIdScript.Focus(); DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.RowCount - 1; DataGridView1.ClearSelection(); DataGridView1.Rows[DataGridView1.RowCount - 1].Selected = true; TxtIdScript.Text = DataGridView1.Rows[DataGridView1.RowCount - 1].Cells[0].Value.ToString(); TxtScript.Text = DataGridView1.Rows[DataGridView1.RowCount - 1].Cells[1].Value.ToString(); //DataGridView1.Refresh() BtnNuevo.Text = "Incorporar"; }