private async void dgvDetalles_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 12 || e.ColumnIndex == 10) { int empeñoId = int.Parse(dgvDetalles.SelectedRows[0].Cells[0].Value.ToString()); var temporal = empeños.Where(x => x.EmpenoId == empeñoId).SingleOrDefault(); var empeño = _context.Empenos.Where(x => x.EmpenoId == empeñoId).SingleOrDefault(); temporal.EditorId = await funciones.GetEmpleadoIdByUser(Program.Usuario.Usuario); empeño.EditorId = await funciones.GetEmpleadoIdByUser(Program.Usuario.Usuario); temporal.FechaRetiroAdministrador = DateTime.Now; empeño.FechaRetiroAdministrador = DateTime.Now; temporal.RetiradoAdministrador = true; empeño.RetiradoAdministrador = true; empeño.Estado = Estado.Retirado; _context.Entry(empeño).State = EntityState.Modified; await _context.SaveChangesAsync(); } else if (e.ColumnIndex == 13 || e.ColumnIndex == 9) { int empeñoId = int.Parse(dgvDetalles.SelectedRows[0].Cells[0].Value.ToString()); var temporal = empeños.Where(x => x.EmpenoId == empeñoId).SingleOrDefault(); var empeño = empeños.Where(x => x.EmpenoId == empeñoId).SingleOrDefault(); temporal.EditorId = await funciones.GetEmpleadoIdByUser(Program.Usuario.Usuario); empeño.EditorId = await funciones.GetEmpleadoIdByUser(Program.Usuario.Usuario); frmOscuro oscuro = new frmOscuro(); oscuro.Show(); frmProroga frmProroga = new frmProroga(empeño.EmpenoId); frmProroga.ShowDialog(); oscuro.Close(); if (Program.Proroga) { var proroga = _context.Prorrogas.Where(p => p.EmpenoId == empeñoId).FirstOrDefault(); temporal.Prorroga = true; empeño.Prorroga = true; if (!string.IsNullOrEmpty(empeño.Cliente.Correo)) { EmailFuncion emailFuncion = new EmailFuncion(); var str = "Se le a otorgado una <b>prórroga de " + proroga.DiasProrroga + " días</b>, para que pueda retirar su Empeño #" + empeño.EmpenoId + " <b>vencido el " + empeño.FechaVencimiento.ToString("dd/MM/yyyy") + "</b> por : <br /><i>" + empeño.Descripcion + "</i><br /><br />"; await emailFuncion.SendMail(empeño.Cliente.Correo, "Proróga de Empeño #" + empeñoId + " en " + configuracion.Compañia, str, empeño); } } _context.Entry(empeño).State = EntityState.Modified; await _context.SaveChangesAsync(); } index = dgvDetalles.SelectedRows[0].Index; LoadDetalle(); dgvDetalles.Rows[0].Selected = false; dgvDetalles.Rows[index].Selected = true; dgvDetalles.FirstDisplayedScrollingRowIndex = dgvDetalles.SelectedRows[0].Index; }
private async void btnGuardarCierreCaja_Click(object sender, EventArgs e) { if (!funciones.ValidatePIN("Empeño")) { return; } var fecha = DateTime.ParseExact(txtFecha.Text, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); var cierreCaja = new CierreCaja { Fecha = fecha, EmpleadoId = Program.EmpleadoId, SaldoInicial = double.Parse(textBox1.Text), IsDelete = false, }; _context.CierreCajas.Add(cierreCaja); await _context.SaveChangesAsync(); detalles.ForEach(d => d.CierreCajaId = cierreCaja.CierreCajaId); _context.DetalleCierreCajas.AddRange(detalles); await _context.SaveChangesAsync(); MessageBox.Show("Cierre de caja realizado correctamente!!!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); Print(cierreCaja); var configuracion = _context.Configuraciones.FirstOrDefault(); if (!string.IsNullOrEmpty(configuracion.EmailNotification)) { EmailFuncion emailFuncion = new EmailFuncion(); var empleado = await _context.Empleados.FindAsync(Program.EmpleadoId); string str = "Se ha realizado el cierre de caja al ser el <b>" + cierreCaja.Fecha.ToLongDateString() + " " + cierreCaja.Fecha.ToLongTimeString() + "</b> por <b>" + empleado.Nombre + "</b>. <br /><br />"; await emailFuncion.SendMail(configuracion.EmailNotification, "Cierre de Caja " + cierreCaja.Fecha, str, detalles); } //printDocument1.Print(); // MessageBox.Show("Imprimiendo..."); }