private void txtSucursal_Leave(object sender, EventArgs e) { if (SucursalValida.Valid(txtSucursal.Text, Program.conexion) == null) { MessageBox.Show("La Sucursal no existe!!"); } }
private void txtSucursal_SelectedIndexChanged(object sender, EventArgs e) { var senderbox = (ComboBox)sender; if (sucur != "" && dtaGrid.RowCount > 1) { if (MessageBox.Show("Si cambia de sucursal, la existencias se modifican, por lo que se reiniciara la venta, desea continuar?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { while (dtaGrid.RowCount != 1) { dtaGrid.Rows.RemoveAt(0); } } else { senderbox.Text = sucur; } } try { string nom = SucursalValida.Valid(txtSucursal.Text, Program.conexion); if (nom != null) { txtDirSucursal.Text = nom; } } catch (Exception ex) { MessageBox.Show(ex.Message); } sucur = senderbox.Text; }
private void btnAgregar_Click(object sender, EventArgs e) { if (Tools.checkBoxEmptys(this.Controls)) { MessageBox.Show("faltan campos"); } else if (SucursalValida.Valid(txtIdSucursal.Text, Program.conexion) == null) { MessageBox.Show("La Sucursal no existe!!"); } else { try { builder.insertFields( "empleado", txtIdSucursal.Text, txtIDGenerado.Text, txtNombreEmpleado.Text, txtApellidoEmpleado.Text, txtDireccion.Text, txtTelefono.Text, "0", "0" ); MessageBox.Show("Registro Guardado correctamente..."); Tools.setBoxemptys(Controls); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void txtIdSucursal_SelectedIndexChanged(object sender, EventArgs e) { try { string dir = SucursalValida.Valid(txtIdSucursal.Text, Program.conexion); if (dir != null) { txtSucursal.Text = dir; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnBuscar_Click(object sender, EventArgs e) { if (SucursalValida.Valid(txtID.Text, Program.conexion) == null) { MessageBox.Show("La sucursal no existe"); Tools.setBoxemptys(Controls); btnEditar.Enabled = false; } else { try { IDbConnection conexion = new SqlConnection (Program.conexion); conexion.Open(); IDbCommand dbcmd = conexion.CreateCommand(); dbcmd.CommandText = "SELECT * FROM SUCURSAL where idsucursal='" + txtID.Text + "';"; IDataReader read = dbcmd.ExecuteReader(); while (read.Read()) { char tipo = (char)read.GetString(read.GetOrdinal("idsucursal")).ToCharArray().GetValue(1); switch (tipo) { case 'T': txtTipo.Text = "Tienda"; break; case 'B': txtTipo.Text = "Bodega"; break; } txtDireccion.Text = read.GetString(read.GetOrdinal("direccion")); txtCiudad.Text = read.GetString(read.GetOrdinal("ciudad")); txtEstado.Text = read.GetString(read.GetOrdinal("estado")); txtTelefono.Text = read.GetString(read.GetOrdinal("telefono")); btnEditar.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void txtIDPROD_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (!ProductoValida.Valid(txtIDPROD.Text, Program.conexion)) { MessageBox.Show("no existe"); } else if (txtSucursal.Text == "" || SucursalValida.Valid(txtSucursal.Text, Program.conexion) == null) { Program.retornarError("La sucursal no existe o debe ingresar una correcta", "Sucursal invalida"); } else { try { IDataReader reader = builder.returnReader("PRODUCTO", "WHERE idproducto = '" + txtIDPROD.Text + "'; ", " * "); if (reader.Read()) { if (reader.GetString(reader.GetOrdinal("proveedor")) != txtProveedor.Text) { MessageBox.Show("Este producto no pertenece a el proveedor" + txtProveedor.Text); } else { txtDetalles.Text = reader.GetString(reader.GetOrdinal("detalle")); txtProducto.Text = reader.GetString(reader.GetOrdinal("nombre")); txtPrecio.Text = Convert.ToString(reader.GetDecimal(reader.GetOrdinal("preciolista"))); } } /* else * { * MessageBox.Show("El producto se a añadido, pero aún no hay pedidos del mismo, pida el producto a su proveedor para generar existencias"); * }*/ } catch (Exception msg) { MessageBox.Show(msg.Message); } } } }
private void txtSucursal_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (SucursalValida.Valid(txtSucursal.Text, Program.conexion) == null) { Program.retornarError("La sucursal no existe", "Sucursal no encontrada"); } else { try { txtDirSucursal.Text = builder.getField("SUCURSAL", "direccion", "where idsucursal = '" + txtSucursal.Text + "'"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnmodificar_Click(object sender, EventArgs e) { if (SucursalValida.Valid(txtSucursal.Text, Program.conexion) != null) { Herramientas.ModifyTools.ModifyEmpleadoe(Program.conexion, txtID.Text, txtNombreEmpleado.Text, txtApellidoEmpleado.Text, txtDireccion.Text, txtTelefono.Text, txtSucursal.Text); btnEliminar.Enabled = false; btnmodificar.Enabled = false; txtID.Enabled = true; txtApellidoEmpleado.Enabled = false; txtDireccion.Enabled = false; txtNombreEmpleado.Enabled = false; txtSucursal.Enabled = false; txtTelefono.Enabled = false; txtID.Focus(); } else { Program.retornarError("La sucursal no existe!!", "Error"); } }
private void button1_Click(object sender, EventArgs e) { if (empleadoValida.Valid(txtIdEmpleado.Text, Program.conexion) == null) { Program.retornarError("El proveedor no existe", "Proveedor no encontrado"); } else if (clienteValida.Valid(txtIdCliente.Text, Program.conexion) == null) { Program.retornarError("El Cliente no existe", "Cliente no encontrado"); } else if (SucursalValida.Valid(txtSucursal.Text, Program.conexion) == null) { Program.retornarError("La sucursal no es valida", "sucursal invalida"); } else if (i == 0) { Program.retornarError("No hay productos en la venta", "Venta sin elementos"); } else { try { string igual = "NULL"; string status = "No entregada"; if (btnentregada.Checked) { status = "Entregada"; igual = "'" + txtfecha.Text + "'"; } SqlConnection conexion = new SqlConnection (Program.conexion); conexion.Open(); IDbCommand comando = conexion.CreateCommand(); comando.CommandText = "INSERT INTO VENTA VALUES(" + txtfolio.Text + "," + "'" + status + "'," + "'" + txtfecha.Text + "', " + igual + " ," + "'" + txtIdEmpleado.Text + "'," + "'" + txtIdCliente.Text + "');"; comando.ExecuteNonQuery(); if (!btnentregada.Checked) { comando.CommandText = "Update cliente set saldo = saldo +" + txtTotal.Text.Substring(0, txtTotal.Text.Length - 1).Replace(',', '.') + " where idcliente='" + txtIdCliente.Text + "'"; comando.ExecuteNonQuery(); } int contador = 0, existnew; while (i != contador) { SqlCommand cmdUp; string idproduct = dtaGrid.Rows[contador].Cells[0].Value.ToString(); existnew = Convert.ToInt32(dtaGrid.Rows[contador].Cells[3].Value); string queryUp = "update existencia set cantidad=cantidad - " + existnew + " where producto = '" + idproduct + "' AND SUCURSAL = '" + txtSucursal.Text + "';"; cmdUp = new SqlCommand(queryUp, conexion); cmdUp.ExecuteNonQuery(); string precio = dtaGrid.Rows[contador].Cells[4].Value.ToString(); queryUp = "INSERT INTO detalleventa VALUES(" + "'" + idproduct + "', " + "" + txtfolio.Text + ", " + "" + precio.Substring(0, precio.Length - 1).Replace(',', '.') + ", " + dtaGrid.Rows[contador].Cells[3].Value + ");"; cmdUp = new SqlCommand(queryUp, conexion); cmdUp.ExecuteNonQuery(); contador++; } MessageBox.Show("Venta Guardado correctamente..."); Tools.setBoxemptys(Controls); conexion.Close(); dtaGrid.DataSource = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }