protected void rdGridFactura_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; DataRowView row = (DataRowView)e.Item.DataItem; string sSaldo = string.Empty; string sFechaPago = string.Empty; DBConn oConn = new DBConn(); if (oConn.Open()) { cFactura oFactura = new cFactura(ref oConn); oFactura.NumContrato = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["num_contrato"].ToString(); oFactura.CodFactura = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["codigo_factura"].ToString(); DataTable dtFactura = oFactura.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); } } dtFactura = null; } oConn.Close(); item["date_invoce"].Text = DateTime.Parse(row["date_invoce"].ToString()).ToString("dd-MM-yyyy"); item["due_date"].Text = DateTime.Parse(row["due_date"].ToString()).ToString("dd-MM-yyyy"); item["total"].Text = double.Parse(row["total"].ToString()).ToString("N0"); item["saldo"].Text = string.Empty; item["fecha_pago"].Text = string.Empty; item["saldo"].Text = (!string.IsNullOrEmpty(sSaldo) ? double.Parse(sSaldo).ToString("N0") : string.Empty); item["fecha_pago"].Text = (!string.IsNullOrEmpty(sFechaPago) ? DateTime.Parse(sFechaPago).ToString("dd-MM-yyyy") : string.Empty); } }
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); }