private void agregar_button_Click(object sender, EventArgs e) { if (cliente_combobox.Text.Equals("")) { MessageBox.Show("Debes escoger un cliente", "Crédito", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { string idCliente = null; string palabra = cliente_combobox.Text; for (int i = 0; i < palabra.Length; i++) { int id = 0; if (int.TryParse(palabra[i].ToString(), out id)) { idCliente = idCliente + cliente_combobox.Text[i]; } else { break; } } Credito credito = new Credito(); credito = new DAOCredito().GetCredito(int.Parse(idCliente)); credito.deuda = credito.deuda + float.Parse(deuda_textbox.Text); new DAOCredito().IncrementarDeudaCliente(credito); Agregar_Deuda_Cliente formAgregarDeuda = new Agregar_Deuda_Cliente(usuarioActual); Detalles_credito_cliente detallito = new Detalles_credito_cliente(); detallito.id_venta = this.id_venta; detallito.id_cliente = int.Parse(idCliente); new DAODetalles_credito_cliente().InsertDetalleCredito(detallito); this.Dispose(); } }
private void button2_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Está seguro que desea eliminar a este cliente?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Clientes clie = new DAOClientes().GetCustomer(idClientSelected); Credito credito = new DAOCredito().GetCredito(idClientSelected); bool bandera = true; if (credito != null) { if (credito.deuda > 0) { if (MessageBox.Show("Este cliente aun tiene deuda, ¿Desea eliminarlo?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { bandera = true; new DAOCredito().DeleteCredito(clie.Id); } else { bandera = false; } } } if (bandera) { new DAOClientes().DeleteCustomer(clie.Id); new DAOCredito().DeleteCredito(clie.Id); } } actualizaDGV(); Agregar_Clientes_Button.Enabled = true; eliminar_button.Enabled = false; Modificar_Clientes_Button.Enabled = false; }
private void hacer_pago_button_Click(object sender, EventArgs e) { float num = 0; if (aportacion_textbox.Text.Equals("") || recibido_textbox.Text.Equals("") || recibido_textbox.Text.Equals(" ") || aportacion_textbox.Text.Equals(" ")) { MessageBox.Show("Lo sentimos, debe de llenar todos los campos (Aportación y recibido).", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); aportacion_textbox.Enabled = false; recibido_textbox.Enabled = false; hacer_pago_button.Enabled = false; cliente_textbox.Text = null; deuda_textbox.Text = null; aportacion_textbox.Text = null; recibido_textbox.Text = null; cambio_textbox.Text = null; detalles_button.Enabled = false; } else if (!float.TryParse(aportacion_textbox.Text, out num) || !float.TryParse(recibido_textbox.Text, out num)) { MessageBox.Show("Lo sentimos, debe ingresar números y no caracteres.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); aportacion_textbox.Enabled = false; recibido_textbox.Enabled = false; hacer_pago_button.Enabled = false; cliente_textbox.Text = null; deuda_textbox.Text = null; aportacion_textbox.Text = null; recibido_textbox.Text = null; cambio_textbox.Text = null; detalles_button.Enabled = false; } else if (deuda_textbox.Text.Equals("0")) { MessageBox.Show("El cliente no tiene deuda.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); aportacion_textbox.Enabled = false; recibido_textbox.Enabled = false; hacer_pago_button.Enabled = false; cliente_textbox.Text = null; deuda_textbox.Text = null; aportacion_textbox.Text = null; recibido_textbox.Text = null; cambio_textbox.Text = null; detalles_button.Enabled = false; } else { Credito cre = new DAOCredito().GetCredito(selectClienID); if (float.Parse(aportacion_textbox.Text) > cre.deuda) { MessageBox.Show("Lo sentimos, debe de agregar una cantidad menor o igual a la deuda.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); aportacion_textbox.Enabled = false; recibido_textbox.Enabled = false; hacer_pago_button.Enabled = false; cliente_textbox.Text = null; deuda_textbox.Text = null; aportacion_textbox.Text = null; recibido_textbox.Text = null; cambio_textbox.Text = null; detalles_button.Enabled = false; } else { //Aqui agrego la parte de ventas y detalles cre.deuda = cre.deuda - float.Parse(aportacion_textbox.Text); new DAOCredito().DecrementarDeudaCliente(cre); credito = new DAOCredito().GetCredito(); clientes = new DAOClientes().GetCustomer(); PantallaCredito recolectorPantalla = new PantallaCredito(); //Buscare los nombres de los clientes por medio del ID que tiene el credito Ventas ventaCredito = new Ventas(); ventaCredito.Id = DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); ventaCredito.Tipo = "Pago de crédito"; ventaCredito.Fecha = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(DateTime.Now)); ventaCredito.Hora = string.Format("{0:HH:mm:ss}", Convert.ToDateTime(DateTime.Now)); ventaCredito.Total = float.Parse(aportacion_textbox.Text); //Agrego a Detalle Detalle detalle = new Detalle(); detalle.id_venta = ventaCredito.Id; detalle.id_producto = "ABONO"; detalle.cantidad = 1; detalle.precio = float.Parse(aportacion_textbox.Text); detalle.total = float.Parse(aportacion_textbox.Text); new DAODetalle().InsertDetails(detalle); //Agrego el abono Abonos abono = new Abonos(); abono.id_cliente = cre.id_cliente; abono.fecha = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Convert.ToDateTime(DateTime.Now)); abono.abono = float.Parse(aportacion_textbox.Text); new DAOAbonos().InsertAbono(abono); // new DAOImpresion().ImprimirTicketCredito(recibido_textbox.Text,cambio_textbox.Text,aportacion_textbox.Text,usuarioActual.Nombre); actualizarDGV(); aportacion_textbox.Enabled = false; recibido_textbox.Enabled = false; hacer_pago_button.Enabled = false; cliente_textbox.Text = null; deuda_textbox.Text = null; aportacion_textbox.Text = null; recibido_textbox.Text = null; cambio_textbox.Text = null; detalles_button.Enabled = false; } } }