protected void btnguardar_Click(object sender, EventArgs e) { NotaRecojoDAO nota = new NotaRecojoDAO(); Model.Enity.NotaRecojo nt = new Model.Enity.NotaRecojo(); nt.Fecha = txtfecha.Text; nt.Id_Cliente = Convert.ToInt32(ddlcliente.SelectedValue); nt.Id_Vendedor = Convert.ToInt32(Session["IDUsuario"].ToString()); nt.Nota = txtnota.Text; nt.sw = false; nt.swdecrip = " "; Int64 id = nota.InsertarNotaRecojo(nt); foreach (GridViewRow fila in grvDetalles.Rows) { NotaRecojoDetalle det = new NotaRecojoDetalle(); TextBox precio = (TextBox)fila.FindControl("txtprecio"); det.Precio = Math.Round(Convert.ToDecimal(precio.Text), 2); det.Id_Producto = Convert.ToInt32(fila.Cells[0].Text); nota.InsertarNotaRecojoDetalle(det, id); } Response.Redirect("ManteNotaRecojoVendedor.aspx", true); }
protected void btnguardar_Click(object sender, EventArgs e) { try { Model.Enity.NotaRecojo nt = new Model.Enity.NotaRecojo(); nt.Id = Convert.ToInt32(Request.QueryString["IDMP"]); nt.Numero_Recojo = txtnumerorecojo.Text; nt.Id_Vendedor = Convert.ToInt32(txtxvendedor.Text); nt.Id_Cliente = Convert.ToInt32(ddlcliente.SelectedValue); nt.Nota = txtnota.Text; nt.Fecha = txtfecha.Text; nt.sw = chkrecojo.Checked; Int32 id = nt.Id; if (chkrecojo.Checked == true) { nt.swdecrip = "Si Recogio"; } else { nt.swdecrip = "No Recogio"; } NotaRecojoDAO nota = new NotaRecojoDAO(); nota.ActualizarNotaRecojo(nt); nota.EliminarDetalle(id); foreach (GridViewRow fila in grvDetalles.Rows) { NotaRecojoDetalle det = new NotaRecojoDetalle(); TextBox precio = (TextBox)fila.FindControl("txtprecio"); det.Id_Producto = Convert.ToInt32(fila.Cells[0].Text); det.Precio = Convert.ToDecimal(precio.Text); nota.InsertarNotaRecojoDetalle(det, id); } Response.Redirect("ManteNotaRecojo.aspx", true); } catch (Exception ex) { txtmensaje.Text = ex.Message; string script = "openModal();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true); } }