private void dgvAlias_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { try { if (e.Clicks == 2) { if (e.RowHandle >= 0 && ModoOperacion == ModoOperacion.Modificacion) { // Cambiar imagen del botón agregar y mostrar el boton de quitar btnAgregarAlias.BackgroundImage = Properties.Resources.edit_validated_40458; btnQuitarAlias.Visible = true; // Obtener datos de la fila selecciona y llenar objeto entidad y controles con dichos datos DataRow FilaSeleccionada = dgvAlias.GetDataRow(e.RowHandle); Alias = new Pro.ALIAS { IdAlias = (int)FilaSeleccionada["IdAlias"], IdProducto = Producto.IdProducto, Alias = FilaSeleccionada["ALias"].ToString(), }; txtAlias.Text = Alias.Alias; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnAgregarAlias.BackgroundImage = Properties.Resources.anadir; btnQuitarAlias.Visible = false; } }
public void ABCALIAS(char Op, Pro.ALIAS ALIAS) { const string querySql = "Pro.prALIAS"; int IntReturn; try { using (SqlConnection connection = _objPersistencia.GetSqlConnection()) { connection.Open(); using (SqlCommand sqlCmnd = _objPersistencia.GetSqlCommand(connection, querySql, CommandType.StoredProcedure)) { sqlCmnd.Parameters.AddWithValue("@Op", Op); sqlCmnd.Parameters.AddWithValue("@IdAlias", ALIAS.IdAlias); sqlCmnd.Parameters.AddWithValue("@IdProducto", ALIAS.IdProducto); sqlCmnd.Parameters.AddWithValue("@Alias", ALIAS.Alias); // Ejecucion del sqlCommand using (SqlDataReader reader = sqlCmnd.ExecuteReader()) { if (!reader.Read()) { throw new Exception("La ejecución del Store Procedure no arrojó ningun dato"); } // Verificamos el resultado de la ejecucion de sp 0 = correcto y 1 existe algun error IntReturn = (int)reader["Result"]; if (IntReturn >= 1) { throw new Exception(reader["MensajeError"].ToString()); } if (IntReturn == 1) { throw new Exception($"{reader["MensajeError"]}\n\nSP: {querySql}"); } reader.Close(); } connection.Close(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void btnQuitarAlias_Click(object sender, EventArgs e) { try { LnPro.ABCALIAS('B', Alias); txtAlias.ResetText(); LlenaGridAlias(); Alias = null; } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { btnAgregarAlias.BackgroundImage = Properties.Resources.anadir; btnQuitarAlias.Visible = false; } }
private void btnAgregarAlias_Click(object sender, EventArgs e) { try { if (ValidarAlias()) { // Se trata de una alta if (Alias == null) { Alias = new Pro.ALIAS { IdProducto = Producto.IdProducto, Alias = txtAlias.Text.Trim() }; LnPro.ABCALIAS('A', Alias); } else // Es una modificación { Alias.Alias = txtAlias.Text.Trim(); LnPro.ABCALIAS('C', Alias); btnAgregarAlias.BackgroundImage = Properties.Resources.anadir; } // Limpiar los controles de captura txtAlias.ResetText(); LlenaGridAlias(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { btnAgregarAlias.BackgroundImage = Properties.Resources.anadir; btnQuitarAlias.Visible = false; Alias = null; } }
public void ABCALIAS(char Op, Pro.ALIAS ALIAS) { _objAdProductos.ABCALIAS(Op, ALIAS); }