示例#1
0
        private void CargaGrilla()
        {
            NEGDocumento conCli = new NEGDocumento();
            Documento    doc    = new Documento();

            gvFacturas.DataSource = conCli.ConsultaDocumento(doc);
            gvFacturas.DataBind();


            gvdetFact.DataSource = detdoc;
            gvdetFact.DataBind();
        }
示例#2
0
        protected void btnguardar_Click(object sender, EventArgs e)
        {
            int nomemp          = int.Parse(ddlNomEmp.SelectedValue);
            int nomcli          = int.Parse(ddlNomCli.SelectedValue);
            int forpago         = int.Parse(ddlFormPago.SelectedValue);
            int tipdoc          = int.Parse(ddlTipoDoc.SelectedValue);
            int totalneto       = int.Parse(txtTotalNeto.Value.Replace(".", ""));
            int totalporcentaje = int.Parse(txtTotalPorcentaje.Value.Replace(".", ""));
            int totaliva        = int.Parse(txtTotalIva.Value.Replace(".", ""));
            int totaldescuento  = int.Parse(txtTotalDescuento.Value.Replace(".", ""));
            int totalgeneral    = int.Parse(txtTotalGeneral.Value.Replace(".", ""));

            if (ddlNomEmp.SelectedIndex == 0)
            {
                Response.Write("<script>alert('Debe selecionar Empresa');</script>");
                return;
            }
            if (ddlNomCli.SelectedIndex == 0)
            {
                Response.Write("<script>alert('Debe selecionar Cliente');</script>");
                return;
            }
            if (ddlFormPago.SelectedIndex == 0)
            {
                Response.Write("<script>alert('Debe selecionar Forma de pago');</script>");
                return;
            }
            else if (gvdetFact.Rows.Count == 0)
            {
                Response.Write("<script>alert('Debe Agregar detalle al documeno');</script>");
                return;
            }
            else
            {
                NEGDocumento doc    = new NEGDocumento();
                Documento    docval = new Documento();

                docval.Id_Empresa       = int.Parse(ddlNomEmp.SelectedValue);
                docval.Id_Cliente       = int.Parse(ddlNomCli.SelectedValue);
                docval.Id_FormaPago     = int.Parse(ddlFormPago.SelectedValue);
                docval.Id_TipoDoc       = int.Parse(ddlTipoDoc.SelectedValue);
                docval.iTotalNeto       = int.Parse(txtTotalNeto.Value.Replace(".", ""));
                docval.dTotalPorcentaje = int.Parse(txtTotalPorcentaje.Value.Replace(".", ""));
                docval.iTotalIva        = int.Parse(txtTotalIva.Value.Replace(".", ""));
                docval.iTotalDescuento  = int.Parse(txtTotalDescuento.Value.Replace(".", ""));
                docval.iTotalGeneral    = int.Parse(txtTotalGeneral.Value.Replace(".", ""));
                string fecdocs = string.Format("{0:yyyy-MM-dd}", fecdoc.Value);
                string fecvigs = string.Format("{0:yyyy-MM-dd}", fecvig.Value);
                docval.dFechaDocumento = fecdocs;
                docval.dFechaVigencia  = fecvigs;

                NEGDetDetDocumento negdetdoc    = new NEGDetDetDocumento();
                DetDocumento       DetDocumento = new DetDocumento();



                for (var x = 0; x < gvdetFact.Rows.Count; x++)
                {
                    DetDocumento.Id_Producto   = int.Parse(gvdetFact.Rows[x].Cells[0].Text);
                    DetDocumento.iTotalParcial = int.Parse(gvdetFact.Rows[x].Cells[3].Text.Replace(".", "").Replace("$", ""));
                    DetDocumento.iCantidad     = int.Parse(gvdetFact.Rows[x].Cells[2].Text);
                }


                //List<DetDocumento> detdoc = new List<DetDocumento>();

                Session["cntUsuario"] = int.Parse(Session["cntUsuario"].ToString()) + 1;
                Session["MtoUsuario"] = int.Parse(Session["MtoUsuario"].ToString()) + totalgeneral;


                if (doc.registrarDocumento(docval))
                {
                    int idDocumento = doc.ConsutaCorrelativo();
                    DetDocumento.Id_Documento    = int.Parse(idDocumento.ToString());
                    DetDocumento.Id_NCorrelativo = int.Parse(idDocumento.ToString());

                    if (negdetdoc.registrarDetDocumento(DetDocumento))
                    {
                        Response.Write("<script>alert('Registro Correcto!');</script>");
                        Response.Redirect("~/Pages/Facturacion.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('Registro Incorrecto!');</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Registro Incorrecto!');</script>");
                }
            }
        }