private void PopulateUsedInvoices() { gridUsedInvoices.ItemsSource = ClsPEZAData.GetPEZA8106itemInvoices(tbPEZAFormNumber.Text.Trim(), Convert.ToInt16(tb8106ItemNo.Text.Trim())).DefaultView; if (gridUsedInvoices.Items.Count > 0) { btnRemove8106.IsEnabled = false; } else { btnRemove8106.IsEnabled = false; } }
private void PopulateUsedInvoices() { dtUsedInvoice.Clear(); foreach (var column in dtUsedInvoice.Columns.Cast <DataColumn>().ToArray()) { if (dtUsedInvoice.AsEnumerable().All(dr => dr.IsNull(column))) { dtUsedInvoice.Columns.Remove(column); } } gridUsedSI.ItemsSource = null; dtUsedInvoice.Columns.Add("invoiceNo", typeof(string)); dtUsedInvoice.Columns.Add("invoiceQty", typeof(string)); dtUsedInvoice.Columns.Add("BalanceQty", typeof(string)); dtUsedInvoice.Columns.Add("invoiceAmt", typeof(string)); dtUsedInvoice.Columns.Add("BalanceAmt", typeof(string)); dtUsedInvoice.Columns.Add("TripNo", typeof(string)); foreach (DataRow dr in ClsPEZAData.GetPEZA8106itemInvoices(_formNo, 1).Rows) { DataRow drw = dtUsedInvoice.NewRow(); drw["invoiceNo"] = dr["invoiceNo"].ToString().Trim(); drw["invoiceQty"] = Convert.ToInt32(dr["invoiceQty"]).ToString("#,##0").Trim(); drw["BalanceQty"] = Convert.ToInt32(tbEstimatedQuantity.Text == string.Empty ? 0 : Convert.ToInt32(tbEstimatedQuantity.Text.Replace(",", "")) - Convert.ToInt32(dr["invoiceQty"])).ToString("#,##0"); drw["invoiceAmt"] = Convert.ToDecimal(Convert.ToDecimal(dr["invoiceAmt"]).ToString("#,##0.00")); drw["BalanceAmt"] = Convert.ToDecimal((Convert.ToDecimal(tbEstimatedAmount.Text == string.Empty ? 0 : Convert.ToDouble(tbEstimatedAmount.Text.Replace(",", ""))) - Convert.ToDecimal(dr["invoiceAmt"]))).ToString("#,##0.00"); drw["TripNo"] = dr["TripNo"].ToString().Trim(); dtUsedInvoice.Rows.Add(drw); } gridUsedSI.ItemsSource = dtUsedInvoice.DefaultView; }