private void AddEmisor() { try { FContext = new FacturadorEntities1(); var Formadepago = new TblFormadePago(); Formadepago.FormadePago = this.txtFormadePago.Text; FContext.AddToTblFormadePagoes(Formadepago); FContext.SaveChanges(); Response.Redirect("ListFormasdePago.aspx"); } catch (Exception ex) { lblError.Text = "Ha Ocurrido un Error Al guardar La Compania: " + ex.Message; } }
protected void GdFormasdePago_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { FContext = new FacturadorEntities1(); var formadepago = new TblFormadePago(); int _idformadepago = Convert.ToInt32(this.GdFormasdePago.DataKeys[e.RowIndex].Value); formadepago = FContext.TblFormadePagoes.Single(Formadepago => Formadepago.PkFormadePagoId == _idformadepago); FContext.TblFormadePagoes.DeleteObject(formadepago); FContext.SaveChanges(); Response.Redirect("ListFormasdePago.aspx"); } catch (Exception ex) { lblError.Text = "Ha Ocurrido un Error Al Eliminar: " + ex.Message; } }
private void EditEmisor() { try { FContext = new FacturadorEntities1(); var FormadePago = new TblFormadePago(); int _idFormadepago = Convert.ToInt32(ViewState["IdFormadepago"]); FormadePago = FContext.TblFormadePagoes.Single(FP => FP.PkFormadePagoId == _idFormadepago); FormadePago.FormadePago = this.txtFormadePago.Text; FContext.SaveChanges(); Response.Redirect("ListFormasdePago.aspx"); } catch (Exception ex) { lblError.Text = "Ha Ocurrido un Error Al guardar La Compania: " + ex.Message; } }