public void BrokeCheckRequestOPDetail(int IdDetail) { try { var db = new WerkERPContext(); var solicitudOPDetalles = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago_detalle == IdDetail).SingleOrDefault(); solicitudOPDetalles.id_cheque = null; db.SaveChanges(); ErrorLabel.Text = String.Empty; ChequesAsignadosGridView.DataBind(); RequestOPDetailsListView.DataBind(); } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = ex.Message; } catch (Exception exp) { ErrorLabel.Text = exp.Message; ErrorLabel.Visible = true; } }
protected void AsignarChequeBtn_Click(object sender, EventArgs e) { decimal vImporte = 0; int vId; int vIdCheque; try { var db = new WerkERPContext(); vIdCheque = Convert.ToInt32(ddlCheques.SelectedValue.ToString()); for (int i = 0; i <= RequestOPDetailsListView.Items.Count - 1; i++) { ListViewItem row = (ListViewItem)RequestOPDetailsListView.Items[i]; CheckBox chk = (CheckBox)row.FindControl("chkConcept"); if (chk.Checked) { try { vImporte += Convert.ToDecimal(((Label)row.FindControl("lblImporteAprobado")).Text); vId = Convert.ToInt32(((Label)row.FindControl("lblID")).Text); var solicitudOPDetalle = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago_detalle == vId).SingleOrDefault(); solicitudOPDetalle.id_cheque = vIdCheque; } catch (Exception ax) { vImporte = 0; } } } var cheque = db.Cheques.Where(s => s.id_cheque == vIdCheque).SingleOrDefault(); if (cheque.monto == null) { cheque.monto = vImporte; } else { cheque.monto += vImporte; } cheque.id_orden_pago = requestID; cheque.fecha_emision = DateTime.Now; db.SaveChanges(); ErrorLabel.Text = String.Empty; ChequesAsignadosGridView.DataBind(); RequestOPDetailsListView.DataBind(); } catch (Exception exp) { ErrorLabel.Text = exp.Message; ErrorLabel.Visible = true; } }