protected void rdGridFactura_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cFactura oFactura = new cFactura(ref oConn);
                oFactura.NkeyDeudor  = cmbox_licenciatario.SelectedValue;
                oFactura.NumContrato = cmbox_contrato.SelectedValue;
                if ((ddlist_ano_ini.SelectedValue != "") && (ddlist_mes_ini.SelectedValue != ""))
                {
                    if (ddlist_mes_ini.SelectedValue != "ShortFall")
                    {
                        oFactura.Periodo = ddlist_mes_ini.SelectedValue + (ddlist_mes_ini.SelectedValue == "Advance" ? " " : "/") + ddlist_ano_ini.SelectedValue;
                    }
                    else
                    {
                        oFactura.Periodo     = ddlist_ano_ini.SelectedValue;
                        oFactura.TipoFactura = "S";
                    }
                }
                DataTable dtFacura = oFactura.GetStatusInvoceFinanzas();
                rdGridFactura.DataSource = dtFacura;
            }
            oConn.Close();
        }
Esempio n. 2
0
        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cFactura oFactura = new cFactura(ref oConn);
                oFactura.NkeyDeudor = hdd_nkey_deudor.Value;
                oFactura.CodFactura = (!string.IsNullOrEmpty(txt_factura.Text) ? txt_factura.Text.Substring(2) : string.Empty);
                DataTable dtFacura = oFactura.GetStatusInvoceFinanzas();
                RadGrid1.DataSource = dtFacura;
            }
            oConn.Close();
        }
        public DataTable dtStatusdeFactura()
        {
            DataTable table = new DataTable("StatusdeFactura");

            table.Columns.Add(new DataColumn("Licenciatario", typeof(string)));
            table.Columns.Add(new DataColumn("Contrato", typeof(string)));
            table.Columns.Add(new DataColumn("Número Invoice", typeof(string)));
            table.Columns.Add(new DataColumn("Periodo", typeof(string)));
            table.Columns.Add(new DataColumn("Emisión", typeof(string)));
            table.Columns.Add(new DataColumn("Vencimiento", typeof(string)));
            table.Columns.Add(new DataColumn("Monto", typeof(string)));
            table.Columns.Add(new DataColumn("Saldo", typeof(string)));
            table.Columns.Add(new DataColumn("Fecha de Pago", typeof(string)));

            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cFactura oFactura = new cFactura(ref oConn);
                oFactura.NkeyDeudor  = cmbox_licenciatario.SelectedValue;
                oFactura.NumContrato = cmbox_contrato.SelectedValue;
                if ((ddlist_ano_ini.SelectedValue != "") && (ddlist_mes_ini.SelectedValue != ""))
                {
                    if (ddlist_mes_ini.SelectedValue != "ShortFall")
                    {
                        oFactura.Periodo = ddlist_mes_ini.SelectedValue + (ddlist_mes_ini.SelectedValue == "Advance" ? " " : "/") + ddlist_ano_ini.SelectedValue;
                    }
                    else
                    {
                        oFactura.Periodo     = ddlist_ano_ini.SelectedValue;
                        oFactura.TipoFactura = "S";
                    }
                }
                DataTable dt = oFactura.GetStatusInvoceFinanzas();
                foreach (DataRow oRow in dt.Rows)
                {
                    string   sSaldo            = string.Empty;
                    string   sFechaPago        = string.Empty;
                    cFactura GetSaldoFechaPago = new cFactura(ref oConn);
                    GetSaldoFechaPago.NumContrato = oRow["num_contrato"].ToString();
                    GetSaldoFechaPago.CodFactura  = oRow["codigo_factura"].ToString();
                    DataTable dtFactura = GetSaldoFechaPago.GetSaldoFechaPago();
                    if (dtFactura != null)
                    {
                        if (dtFactura.Rows.Count > 0)
                        {
                            sSaldo     = (!string.IsNullOrEmpty(dtFactura.Rows[0]["saldo"].ToString()) ? dtFactura.Rows[0]["saldo"].ToString() : string.Empty);
                            sFechaPago = (!string.IsNullOrEmpty(dtFactura.Rows[0]["fecha_pago"].ToString()) ? dtFactura.Rows[0]["fecha_pago"].ToString() : string.Empty);
                        }
                    }
                    GetSaldoFechaPago = null;

                    DataRow newRow = table.NewRow();
                    newRow["Licenciatario"]  = oRow["licenciatario"].ToString();
                    newRow["Contrato"]       = oRow["no_contrato"].ToString();
                    newRow["Número Invoice"] = oRow["num_invoice"].ToString();
                    newRow["Periodo"]        = oRow["periodo"].ToString();
                    newRow["Emisión"]        = DateTime.Parse(oRow["date_invoce"].ToString()).ToString("dd-MM-yyyy");                                  // oRow["date_invoce"].ToString();
                    newRow["Vencimiento"]    = DateTime.Parse(oRow["due_date"].ToString()).ToString("dd-MM-yyyy");                                     //oRow["due_date"].ToString();
                    newRow["Monto"]          = double.Parse(oRow["total"].ToString()).ToString("N0", oCulture);                                        //oRow["total"].ToString();
                    newRow["Saldo"]          = (!string.IsNullOrEmpty(sSaldo) ? double.Parse(sSaldo).ToString("N0", oCulture) : string.Empty);         //oRow["saldo"].ToString();
                    newRow["Fecha de Pago"]  = (!string.IsNullOrEmpty(sFechaPago) ? DateTime.Parse(sFechaPago).ToString("dd-MM-yyyy") : string.Empty); //oRow["fecha_pago"].ToString();
                    table.Rows.Add(newRow);
                }
            }
            oConn.Close();

            return(table);
        }