protected void btnguardar_Click(object sender, EventArgs e) { PedidoDAO db = new PedidoDAO(); Encabezado en = new Encabezado(); if (lblzona.Text.Length == 0) { txtmensaje.Text = "No se puede guardar el pedido porque no tiene una zona para hoy."; string script = "openModal();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true); } else { try { en.Id_cliente = Convert.ToInt32(ddlclientes.SelectedValue); en.fechaCheque = txtfecha.Text; en.Id_Vendedor = Convert.ToInt32(Session["IDUsuario"]); en.Total_Venta = Math.Round(Convert.ToDecimal(lbltotal.Text), 2); en.Id_Moneda = Convert.ToInt32(ddlmoneda.SelectedValue); en.Id_FormaPago = Convert.ToInt32(ddlformapago.SelectedValue); en.IGV = Math.Round(Convert.ToDecimal(lbligv.Text), 2); en.Estado_Docmto = false; en.Estado_Pago = " "; en.Notas = txtnota.Text; Int64 id = db.InsertarCabecera(en); foreach (GridViewRow fila in grvDetalles.Rows) { Detalles det = new Detalles(); TextBox cantidad = (TextBox)fila.FindControl("txtcantidad"); det.Paquetes = Convert.ToInt32(cantidad.Text); TextBox precio = (TextBox)fila.FindControl("txtprecio"); det.PrecioUnit = Math.Round(Convert.ToDecimal(precio.Text), 2); TextBox peso = (TextBox)fila.FindControl("txtpeso"); TextBox unidad = (TextBox)fila.FindControl("txtunidad"); det.CantidadKilos = Math.Round(Convert.ToDecimal(peso.Text), 2); det.Id_prod = Convert.ToInt32(fila.Cells[0].Text); det.IGV = Math.Round(Convert.ToDecimal(fila.Cells[5].Text), 2); det.SubTotal = Math.Round(Convert.ToDecimal(fila.Cells[6].Text), 2); det.Unidad = Convert.ToInt32(unidad.Text); det.Id_UMedida = Convert.ToInt32(fila.Cells[9].Text); db.InsertarDetalles(det, id); } Response.Redirect("MantePedidoVendedor.aspx", true); } catch (Exception ex) { txtmensaje.Text = ex.Message; string script = "openModal();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true); } } }
protected void btnguardar_Click(object sender, EventArgs e) { try { PedidoDAO db = new PedidoDAO(); Encabezado en = new Encabezado(); en.Id_cliente = Convert.ToInt32(txtcodigo.Text); en.fechaCheque = txtfecha.Text; en.Id_Vendedor = Convert.ToInt32(ddlvendedor.SelectedValue); en.Total_Venta = Math.Round(Convert.ToDecimal(lbltotal.Text), 2); en.Id_Moneda = Convert.ToInt32(ddlmoneda.SelectedValue); en.Id_FormaPago = Convert.ToInt32(ddlformapago.SelectedValue); en.IGV = Math.Round(Convert.ToDecimal(lbligv.Text), 2); en.Estado_Docmto = chkrecibio.Checked; if (en.Estado_Docmto == true) { en.Estado_Pago = "Recibió"; } else { en.Estado_Pago = "No recibió"; } en.Notas = txtnota.Text; Int64 id = db.InsertarCabecera(en); Session["IDPEDIDO"] = id; foreach (GridViewRow fila in grvDetalles.Rows) { Detalles det = new Detalles(); TextBox cantidad = (TextBox)fila.FindControl("txtcantidad"); det.Paquetes = Convert.ToInt32(cantidad.Text); TextBox precio = (TextBox)fila.FindControl("txtprecio"); det.PrecioUnit = Math.Round(Convert.ToDecimal(precio.Text), 2); TextBox peso = (TextBox)fila.FindControl("txtpeso"); TextBox unidad = (TextBox)fila.FindControl("txtunidad"); det.IGV = Math.Round(Convert.ToDecimal(fila.Cells[5].Text), 2); det.CantidadKilos = Math.Round(Convert.ToDecimal(peso.Text), 2); det.Id_prod = Convert.ToInt32(fila.Cells[0].Text); det.SubTotal = Math.Round(Convert.ToDecimal(fila.Cells[6].Text), 2); det.Unidad = Convert.ToInt32(unidad.Text); det.Id_UMedida = Convert.ToInt32(fila.Cells[9].Text); db.InsertarDetalles(det, id); } Response.Redirect("MantePedido.aspx", true); //txtmensaje.Text = "El pedido se guardo con exito."; //string script = "openModal();"; //ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true); //ddlmercados.Enabled = false; //txtfecha.Enabled = false; //ddlclientes.Enabled = false; //ddlproducto.Enabled = false; //grvDetalles.Enabled = false; //btnimprimir.Enabled = true; //txtnumeropuesto.Enabled = false; //txtcodproducto.Enabled = false; //btnguardar.Enabled = false; } catch (Exception ex) { txtmensaje.Text = ex.Message; string script = "openModal();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true); } }