//public void LimpiarLbl(params Label[] text) //{ // for (int i = 0; i < text.Length; i++) // { // text[i].Hide(); // } //} private void Toolstborrar_Click(object sender, EventArgs e) { ClientesBl Cambiar = new ClientesBl(); Clientes entidades = new Clientes(); try { if (MessageBox.Show("Esta Seguro de que quiere Borrar este registro?", "Borrando", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { entidades.ID_Cliente = ID; entidades.Estado = "N"; Cambiar.EliminarClientes(entidades); ToolstNuevo.PerformClick(); MessageBox.Show("Registro Borrado.", "Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { throw; } }
private void toolStripButton2_Click(object sender, EventArgs e) { try { if (Validar()) { if (UP == true) { Clientes entidad = new Clientes(); ClientesBl actualizar = new ClientesBl(); if (ID < 1) { MessageBox.Show("Debe seleccionar un registro valido antes de actualizar." + " Por favor seleccione un registro en la pestaña de busqueda que desea actualizar " + "y vuelva a intentarlo.", "Error de eliminación", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { entidad.ID_Cliente = ID; entidad.Nombre = TxtNombre.Text; entidad.Apellido = TxtApellido.Text; entidad.Direccion = TxtDireccion.Text; entidad.Documento = TxtDocumento.Text; entidad.Telefono = TxtTelefono.Text; actualizar.ActualizarClientes(entidad); MessageBox.Show("Registro Actualizado.", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); UP = false; return; } } if (UP == false) { ClientesBl Pro = new ClientesBl(); Clientes entidad = new Clientes(); if (TxtApellido.Text == string.Empty) { TxtApellido.Text = null; } if (TxtDireccion.Text == string.Empty) { TxtDireccion.Text = null; } if (TxtTelefono.Text == string.Empty) { TxtTelefono.Text = null; } //if (TxtApellido.Text == string.Empty) // TxtApellido.Text = null; //if (txtSaldoActual.Text == string.Empty) // txtSaldoActual.Text = "0.0"; //float SaldoIn = float.Parse(txtSaldoInicial.Text); //float SaldoAct = float.Parse(txtSaldoActual.Text); // entidad.ID_Producto = ID; entidad.Nombre = TxtNombre.Text; entidad.Apellido = TxtApellido.Text; entidad.Direccion = TxtDireccion.Text; entidad.Documento = TxtDocumento.Text; entidad.Telefono = TxtTelefono.Text; entidad.Estado = "Y"; Pro.RegClientes(entidad); // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtNombre.Text)) { errorProvider1.SetError(TxtNombre, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtDocumento.Text)) { errorProvider1.SetError(TxtDocumento, "Este Campo es requerido"); } } } catch (Exception) { throw; } }
private void ToolstGuardar_Click(object sender, EventArgs e) { try { if (ValidarT()) { if (UP == true) { Factura entidad = new Factura(); FacturaBl actualizar = new FacturaBl(); } if (UP == false) { FacturaBl fac = new FacturaBl(); Factura entidad = new Factura(); DetalleFacturaBl dtf = new DetalleFacturaBl(); DetalleFacturas entidf = new DetalleFacturas(); ProductosBl pb = new ProductosBl(); Productos pd = new Productos(); // entidad.ID_Producto = ID; entidad.Fecha = Convert.ToDateTime(toolStripStatusLabel1.Text); entidad.Forma_Pago = CbxForamPago.Text; entidad.Vendedor = Usu.ToString(); entidad.Total = double.Parse(LblTotaApagar.Text); entidad.Id_Cliente = Id_Cliente; fac.RegFactura(entidad); foreach (DataGridViewRow row in dgvDetalleF.Rows) { entidf.Monto = Convert.ToDouble(row.Cells["Precio_Producto"].Value); entidf.Cantidad = Convert.ToInt16(row.Cells["Fecha"].Value); entidf.Itbis = Convert.ToDouble(row.Cells["Generales"].Value); entidf.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value); var dt = fac.ObtenerIDFactura(Id_Cliente, Convert.ToDouble(LblTotaApagar.Text)); var Id1 = dt.Rows[0]["ID_Factura"]; entidf.ID_Factura = Convert.ToInt16(Id1); ID_Factura = Convert.ToInt16(Id1); pd.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value);; pd.Inventario = Convert.ToInt16(row.Cells["Fecha"].Value); pb.ActualizarInventario(pd); dtf.RegDetalleFactura(entidf); } // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); if (MessageBox.Show("¿Desea imprimir la factura? ", "Imprimir", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { tsImprimir.PerformClick(); } else { return; } } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtProducto.Text)) { errorProvider1.SetError(TxtProducto, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtCliente.Text)) { errorProvider1.SetError(TxtCliente, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(CbxForamPago.Text)) { errorProvider1.SetError(CbxForamPago, "Este Campo es requerido"); } } } catch (Exception) { throw; } }
private void ToolstGuardar_Click(object sender, EventArgs e) { try { if (Validar()) { if (UP == true) { Productos entidad = new Productos(); ProductosBl actualizar = new ProductosBl(); if (ID < 1) { MessageBox.Show("Debe seleccionar un registro valido antes de actualizar." + " Por favor seleccione un registro en la pestaña de busqueda que desea actualizar " + "y vuelva a intentarlo.", "Error de eliminación", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { DateTime Fecha = DateTime.Today; entidad.ID_Producto = ID; entidad.Descripcion_Producto = TxtDescPro.Text; entidad.Precio_Compra = double.Parse(TxtPCompra.Text); entidad.Precio_Venta = double.Parse(TxtPVenta.Text); entidad.Inventario = Convert.ToInt32(TxtInventario.Text); //string fecha= dateTimePicker1.Value.ToString("yyyy-MM-dd"); entidad.Fecha_Entrada = Convert.ToDateTime(Fecha.ToString("yyyy-MM-dd")); //entidad.ID_Proveedor = int.Parse(CbxProveedor.SelectedValue.ToString()); actualizar.ActualizarProductos(entidad); MessageBox.Show("Registro Actualizado.", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); UP = false; return; } } if (UP == false) { ProductosBl Pro = new ProductosBl(); Productos entidad = new Productos(); //if (TxtApellido.Text == string.Empty) // TxtApellido.Text = null; //if (TxtDireccion.Text == string.Empty) // TxtDireccion.Text = null; //if (TxtTelefono.Text == string.Empty) // TxtTelefono.Text = null; //if (TxtApellido.Text == string.Empty) // TxtApellido.Text = null; //if (txtSaldoActual.Text == string.Empty) // txtSaldoActual.Text = "0.0"; //float SaldoIn = float.Parse(txtSaldoInicial.Text); //float SaldoAct = float.Parse(txtSaldoActual.Text); DateTime Fecha = DateTime.Today; // entidad.ID_Producto = ID; entidad.Descripcion_Producto = TxtDescPro.Text; entidad.Precio_Compra = double.Parse(TxtPCompra.Text); entidad.Precio_Venta = double.Parse(TxtPVenta.Text); entidad.Inventario = Convert.ToInt32(TxtInventario.Text); entidad.ID_Proveedor = int.Parse(CbxProveedor.SelectedValue.ToString()); entidad.ID_Proveedor = int.Parse(CbxProveedor.SelectedValue.ToString()); entidad.Fecha_Entrada = Convert.ToDateTime(Fecha.ToString("yyyy-MM-dd")); Pro.RegProducto(entidad); // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtDescPro.Text)) { errorProvider1.SetError(TxtDescPro, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtPCompra.Text)) { errorProvider1.SetError(TxtPCompra, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtInventario.Text)) { errorProvider1.SetError(TxtInventario, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtPVenta.Text)) { errorProvider1.SetError(TxtPVenta, "Este Campo es requerido"); } } } catch (Exception) { throw; } }