private void Borrar() { try { oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "0300704"); if (oFuncion.Err) { MessageBox.Show("Disculpe Usted No Tiene Acceso a Esta Accion", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { if (MessageBox.Show("Esta seguro de Borrar este Registro", "Atencion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { App_Code.Inventario.Tallas oRegistro = new App_Code.Inventario.Tallas(int.Parse(this.lblFicha.Text.ToString())); oRegistro.Borrado = true; oRegistro.Actualizar(); this.Nuevo(); this.Consulta(); MessageBox.Show(oRegistro.Msg, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { } }
private void Guardar() { App_Code.Inventario.Tallas oRegistro = new App_Code.Inventario.Tallas(int.Parse(this.lblFicha.Text)); oRegistro.Nombre = this.txtNombre.Text.ToUpper(); oRegistro.Codigo = this.txtCodigo.Text.ToUpper(); oRegistro.Borrado = false; oRegistro.UserLogId = frmPrincipal.id_usuario; try { if (!Validar()) { if (oRegistro.Err) { oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "0300702"); if (oFuncion.Err) { MessageBox.Show("Disculpe Usted No Tiene Acceso a Esta Accion", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { oRegistro.Creado = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy hh:mm tt")); oRegistro.Modificado = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy hh:mm tt")); oRegistro.Insertar(); } } else { oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "0300703"); if (oFuncion.Err) { MessageBox.Show("Disculpe Usted No Tiene Acceso a Esta Accion", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { oRegistro.Modificado = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy hh:mm tt")); oRegistro.Actualizar(); } } MessageBox.Show(oRegistro.Msg, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Consulta(); this.Presentar(oRegistro.Id); } } catch (Exception) { } }
private bool Validar() { if (this.txtCodigo.Text.Length == 0) { this.txtCodigo.BackColor = Color.Red; MessageBox.Show("Disculpe ingrese un codigo", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } if (this.txtNombre.Text.Length == 0) { this.txtNombre.BackColor = Color.Red; MessageBox.Show("Disculpe ingrese un nombre", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } if (this.lblFicha.Text == "0") { DataTable oTabla = new App_Code.Inventario.Tallas().Buscar( 1, "id", "codigo = '" + this.txtCodigo.Text + "'", ""); if (oTabla.Rows.Count > 0) { this.txtCodigo.BackColor = Color.Red; MessageBox.Show("Disculpe ya el codigo existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } } else { DataTable oTabla = new App_Code.Inventario.Tallas().Buscar( 1, "id", "(codigo = '" + this.txtCodigo.Text + "') AND (id <> '" + this.lblFicha.Text + "')", ""); if (oTabla.Rows.Count > 0) { this.txtCodigo.BackColor = Color.Red; MessageBox.Show("Disculpe ya el usuario existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } } return(false); }
private void Presentar(int id) { App_Code.Inventario.Tallas oRegistro = new App_Code.Inventario.Tallas(id); this.lblFicha.Text = oRegistro.Id.ToString("0"); this.txtCodigo.Text = oRegistro.Codigo; this.txtNombre.Text = oRegistro.Nombre; this.txtCodigo.BackColor = Color.White; this.txtNombre.BackColor = Color.White; oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "0300704"); if (!oFuncion.Err) { this.btnEliminar.Enabled = true; } }