C# Conditional Pricing issue (+=) - c#

I have some code here:
(It basically checks if a product is a kit product or not then applys the New Price with the Price Modification)
if (!newItem.m_IsAKit)
{
NewPR = AppLogic.DetermineLevelPrice(newItem.m_VariantID, m_ThisCustomer.CustomerLevelID, out IsOnSale);
Decimal PrMod = AppLogic.GetColorAndSizePriceDelta(DB.RSField(rs, "ChosenColor"), DB.RSField(rs, "ChosenSize"), DB.RSFieldInt(rs, "TaxClassID"), ThisCustomer, true, false);
if (PrMod != System.Decimal.Zero)
{
NewPR += PrMod;
}
}
else
{
NewPR = DB.RSFieldDecimal(rs, "ProductPrice");
if (LevelDiscountPercent != 0.0M)
{
NewPR = AppLogic.GetKitTotalPrice(m_ThisCustomer.CustomerID, m_ThisCustomer.CustomerLevelID, newItem.m_ProductID, newItem.m_VariantID, newItem.m_ShoppingCartRecordID);
}
}
I have a product which IS a kit product so i am refering to the code after the else statement.
I need to apply NewPr += PrMod.
NewPr = 22
PrMod = 5
I have tried adding this code:
Decimal PrMod = AppLogic.GetColorAndSizePriceDelta(DB.RSField(rs, "ChosenColor"), DB.RSField(rs, "ChosenSize"), DB.RSFieldInt(rs, "TaxClassID"), ThisCustomer, true, false);
if (PrMod != System.Decimal.Zero)
{
NewPR += PrMod;
}
But during debugging the PrMod doesnt seem to hold a value.
Can you help point me in the right direction?
Thanks
I have the following method but i cant seem to see where the problem is. When the product IS a kit product it works fine.
static public decimal GetColorAndSizePriceDelta(String ChosenColor, String ChosenSize, int TaxClassID, Customer ThisCustomer, bool WithDiscount, bool WithVAT)
{
bool VATEnabled = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("VAT.Enabled");
bool VATOn = (VATEnabled && ThisCustomer.VATSettingReconciled == VATSettingEnum.ShowPricesInclusiveOfVAT);
decimal CustLevelDiscountPct = 1.0M;
decimal price = System.Decimal.Zero;
String ColorPriceModifier = String.Empty;
String SizePriceModifier = String.Empty;
if (ThisCustomer.CustomerLevelID > 0 && WithDiscount)
{
decimal LevelDiscountPercent = System.Decimal.Zero;
using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
{
dbconn.Open();
string sSql = string.Format("select LevelDiscountPercent from CustomerLevel with (NOLOCK) where CustomerLevelID={0}", ThisCustomer.CustomerLevelID);
using (IDataReader rs = DB.GetRS(sSql, dbconn))
{
if (rs.Read())
{
LevelDiscountPercent = DB.RSFieldDecimal(rs, "LevelDiscountPercent");
}
}
}
if (LevelDiscountPercent != System.Decimal.Zero)
{
CustLevelDiscountPct -= LevelDiscountPercent / 100.0M;
}
}
if (ChosenColor.IndexOf("[") != -1)
{
int i1 = ChosenColor.IndexOf("[");
int i2 = ChosenColor.IndexOf("]");
if (i1 != -1 && i2 != -1)
{
ColorPriceModifier = ChosenColor.Substring(i1 + 1, i2 - i1 - 1);
}
}
if (ChosenSize.IndexOf("[") != -1)
{
int i1 = ChosenSize.IndexOf("[");
int i2 = ChosenSize.IndexOf("]");
if (i1 != -1 && i2 != -1)
{
SizePriceModifier = ChosenSize.Substring(i1 + 1, i2 - i1 - 1);
}
}
if (ColorPriceModifier.Length != 0)
{
price += Localization.ParseDBDecimal(ColorPriceModifier);
}
if (SizePriceModifier.Length != 0)
{
price += Localization.ParseDBDecimal(SizePriceModifier);
}
if (VATOn && WithVAT)
{
decimal TaxRate = 0.0M;
TaxRate = ThisCustomer.TaxRate(TaxClassID);
Decimal TaxMultiplier = (1.0M + (TaxRate / 100.00M));
price = TaxMultiplier * price;
}
return price * CustLevelDiscountPct;
}

Why dont you initialize the varaible PrMod tp Zero
You need to debbug AppLogic.GetColorAndSizePriceDelta method because if the return type is Decimal, it should atleast return a deafult value as 0.0M

Related

rows with computesd values for time period in net core 6 app

I generating computed values based on a time range, like this:
output
The trouble is that with many rows in takes for ever to do it.
I need to find a quicker way.
For each cell with volumes i do this:
public int GetVolume(int _month, int _year, int companyId, int NVR, string country)
{
var salesCount = 0;
salesCount = (int)(from sale in _context.SalesData.AsNoTracking()
join _company in _context.CompaniesMains.AsNoTracking() on sale.CompanyId equals _company.Id
where (sale.IYear == _year && sale.IMonth == _month) && _company.Id == companyId && sale.Nvr == NVR
&& sale.Country.Trim().Equals(country)
select sale.SalesAmount).Sum();
return salesCount;
}
And in cells with turn over i do this:
public decimal GetPrice(int _month, int _year, int NVR, string country, bool Euros = false)
{
var salesCount = 0m;
var count = (from price in _context.Prices.AsNoTracking()
where price.IYear == _year
&& price.IMonth == _month
&& price.Valuta.Equals(country)
&& price.Nvr.Equals(NVR)
select price.RegisterPrice.Trim()).FirstOrDefault();
if (count != null)
{
var style = NumberStyles.AllowDecimalPoint;
var culture = CultureInfo.CreateSpecificCulture("en-US");
Decimal.TryParse(count, style, culture, out salesCount);
}
if (Euros)
{
var currency = 0m;
switch (country)
{
case "DK":
currency = _memoryCache.GetCacheCurrency("dkk");
break;
case "NO":
currency = _memoryCache.GetCacheCurrency("nok");
break;
case "SE":
currency = _memoryCache.GetCacheCurrency("sek");
break;
case "FI":
currency = _memoryCache.GetCacheCurrency("fin");
break;
}
salesCount /= currency;
}
return (decimal)salesCount;
}
It all runs in a loop where i call the 2 methods.
foreach (var q in selectedLst)
{
if (filters.TableType == TableTypeView.Month)
{
for (var i = 0; i <= GetMonthDifference; i++)
{
var month = filters.StartDate.AddMonths(i);
var d = new Dates();
var salesAmount = GetVolume(month.Month, month.Year, q.CompanyId, q.Nvr, q.CompanyCountry);
if (filters.TurnOver)
{
var RegisterPrice = GetPrice(month.Month, month.Year, q.Nvr, q.CompanyCountry, filters.Euros);
d.TurnOver = (decimal)salesAmount * (RegisterPrice / 100);
d.RegisterPrice = RegisterPrice / 100;
}
d.Amount = (int)salesAmount;
d.Nvr = q.Nvr;
d.Month = month.Month;
d.Year = month.Year;
d.Country = q.CompanyCountry;
dates.Add(d);
}
}
}
Any ideas on how to make this quick?

What is the value of arg in Task.Factory.StartNew

I have Task.Factory.StartNew in C# code with args argument. I am not quite understand what value will arg be. So what value will args be and how the value is determined?
int count = table.Rows.Count;
Dictionary<int, string> expDic = new Dictionary<int, string>();
List<Task> taskList = new List<Task>();
for (int f = 0; f < count; f++)
{
DataRow tempformula = table.Rows[f];
string formulaSymbol = Convert.ToString(tempformula[Common.Systems.Sustainability.Constants.IndicatorFormula.Symbol]);
var t = Task.Factory.StartNew(new Action<object>((args) => {
int i = (int)args;
_sem.Wait();
StringBuilder expression = new StringBuilder(1024);
DataRow formula = table.Rows[i];
int indID = Convert.ToInt32(formula[Common.Systems.Sustainability.Constants.IndicatorFormula.IndicatorID]);
int sequence = Convert.ToInt32(formula[Common.Systems.Sustainability.Constants.IndicatorFormula.Sequence]);
int? referenceIndID = Common.Util.TryToConvertToInt32(formula, Common.Systems.Sustainability.Constants.IndicatorFormula.ReferenceIndicatorID);
decimal? val = Common.Util.TryToConvertToDecimal(formula, Common.Systems.Sustainability.Constants.IndicatorFormula.Value);
string symbol = Convert.ToString(formula[Common.Systems.Sustainability.Constants.IndicatorFormula.Symbol]);
string formulaOutputUnit = Convert.ToString(formula[Common.Systems.Sustainability.Constants.Indicator.Unit]);
if (!string.IsNullOrWhiteSpace(callerAcceptedUnit)) // added by HC on 2016-05-27
{
formulaOutputUnit = callerAcceptedUnit;
}
if (referenceIndID == null)
{
if (val == null)
{
DataSet indicator = GetIndicatorByIDFromCache(companyID, indID); // added by HC on 2017-05-12, for performance tuning.
//using (DataSet indicator = indicatorMgr.GetIndicatorByID(companyID, indID))
{
DataRow dr = indicator.Tables[0].Rows[0];
int indicatorType = Convert.ToInt32(dr[Common.Systems.Sustainability.Constants.Indicator.IndicatorType]);
if (indicatorType == (int)Common.Systems.Sustainability.Constants.IndicatorTypes.Currency
|| indicatorType == (int)Common.Systems.Sustainability.Constants.IndicatorTypes.Numeric)
{
decimal? total = SumTotal(companyID, indID, indicatorType, fromDate, toDate, formulaOutputUnit, callerIndicatorID, breakToMonthly, specifiedLocations, approvalStatus
, usageDataSet, interval
, indicatorIDsChain
, allowNull
);
expression.Append(total.ToString());
}
else if (symbol == "+"
|| symbol == "-"
|| symbol == "*"
|| symbol == "/")
{
expression.Append(symbol);
}
}
}
else
{
expression.Append(val.ToString());
}
}
else
{
string exp = GetExpression(companyID, fromDate, toDate, referenceIndID.Value.ToString(), indID.ToString(), formulaOutputUnit, breakToMonthly, specifiedLocations, approvalStatus
, usageDataSet, interval
, indicatorIDsChain
);
//expression.Append(exp);
using (DataTable dt = new DataTable())
{
// fault tolerance, for in-case users assigned symbol in the last line of formula
if (exp.EndsWith("+")
|| exp.EndsWith("-")
|| exp.EndsWith("*")
|| exp.EndsWith("/"))
{
exp = exp.Substring(0, exp.Length - 1);
}
object result = dt.Compute(exp, "");
expression.Append(result);
}
} // end if (referenceIndID == null)...
if ("IF".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| "THEN".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| "ELSE IF".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| "ELSE".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| ">".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| ">=".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| "=".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| "<=".Equals(symbol, StringComparison.OrdinalIgnoreCase)
|| "<".Equals(symbol, StringComparison.OrdinalIgnoreCase)
)
{
//--------------------------------------------------------
// Begin, added by HC on 2016-12-14
// as requested by CQS users, add "IF" statement for GRI indicators
string exp = HandleIFCondition(table, i, companyID, fromDate, toDate, indicatorIDs, callerIndicatorID, callerAcceptedUnit, breakToMonthly, specifiedLocations, approvalStatus, usageDataSet, interval, indicatorIDsChain);
expression.Append(exp);
// End, added by HC on 2016-12-14
//--------------------------------------------------------
// Find End if, added by Alex Poon on 20190306
int ifIndex = i;
for (var j = ifIndex; j < count; j++)
{
string endIfSymbol = Convert.ToString(table.Rows[j][Common.Systems.Sustainability.Constants.IndicatorFormula.Symbol]);
if ("END IF".Equals(endIfSymbol, StringComparison.OrdinalIgnoreCase))
{
i = j;
break;
}
}
}
else
{
if (!string.IsNullOrWhiteSpace(symbol)
&& expression.Length > 0 // added by HC on 2016-06-24
)
{
if (i + 1 >= count && symbol != ")")
{
// ignore the symbol
}
else if (expression.ToString() != symbol)
{
expression.Append(symbol);
}
}
else if (expression.Length == 0 && symbol == "(")
{
expression.Append(symbol);
}
if (symbol == "days")
{
// added by HC on 2017-01-23, a new requirements for calculating average values by days.
if (fromDate != null && toDate != null)
{
int days = toDate.Value.Subtract(fromDate.Value).Days + 1;
expression.Append(days);
}
else
{
expression.Append(1);
}
}
} // end if ("IF".Equals(symbol, StringComparison.OrdinalIgnoreCase)...
if (expDic != null && expression != null)
{
expDic.Add(i, expression.ToString());
}
_sem.Release();
}), f);
taskList.Add(t);
if ("IF".Equals(formulaSymbol, StringComparison.OrdinalIgnoreCase))
{
for (var j = f; j < count; j++)
{
string endIfSymbol = Convert.ToString(table.Rows[j][Common.Systems.Sustainability.Constants.IndicatorFormula.Symbol]);
if ("END IF".Equals(endIfSymbol, StringComparison.OrdinalIgnoreCase))
{
f = j;
break;
}
}
}
}
Task.WaitAll(taskList.ToArray());
List<int> keys = expDic.Keys.ToList();
keys.Sort();
string finalExpression = "";
foreach (var key in keys)
{
finalExpression += expDic[key];
}
return finalExpression;
}
args in your case is data that will be passed to a delegate specified by Action<object> parameter.
See docs.
When using overload of StartNew with Action<object>, you need to supply next argument of type object, which will be used in passed delegate.
Task.Factory.StartNew((o) => {/* 1 will be used here */}, 1, token, options, scheduler);
MSDN
The args argument (referred to as "state" in the documentation) is a parameter you need to specify when you call to Task.Factory.StartNew.
state (Object): An object containing data to be used by the action delegate.
Sample:
object param = somevalue;
Task.Factory.StartNew( (arg) =>
{ /* get the arg value here.*/
}, param);

Excel takes only that no of rows which has data in c#...my code works for some excel sheet not for all

Excel sheets made by different different clients...that code works when i make but not when user make..is anything problem with excel sheet so , i can tell user make like that way..or i can do anything with my code.
private void MeterUpdateByExcelSheet(HttpPostedFileBase file)
{
List<string> errorMessages = new List<string>();
int siteId = Helpers.SiteHelpers.Functions.GetSiteIdOfLoginUser().Value;
var stream = file.InputStream;
using (var package = new ExcelPackage(stream))
{
//getting number of sheets
var sheets = package.Workbook.Worksheets;
int totalProcessedMeters = 0;
if (sheets.Count > 0)
{
var sheet = sheets.FirstOrDefault();
//getting number of rows
var rows = sheet.Dimension.End.Row;
for (int row = 2; row <= rows; row++)
{
//get data for a row from excel
var meterNo = Convert.ToString(sheet.Cells[row, 1].Value);
int? sanctionLoadMains = (int)Convert.ToDecimal(sheet.Cells[row, 2].Value);
int? sanctionLoadDG = (int)Convert.ToDecimal(sheet.Cells[row, 3].Value);
int? unitArea = (int)Convert.ToDecimal(sheet.Cells[row, 4].Value);
int? creditLimit = (int)Convert.ToDecimal(sheet.Cells[row, 5].Value);
int? sMSWarning = (int)Convert.ToDecimal(sheet.Cells[row, 6].Value);
int? sMSWarning1 = (int)Convert.ToDecimal(sheet.Cells[row, 7].Value);
string date = sheet.Cells[row, 8].Value.ToString();
DateTime billingDate;
if (string.IsNullOrEmpty(date))
{
errorMessages.Add("Date is not given for MeterNo " + meterNo + " at row " + row);
continue;
}
if (!DateTime.TryParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out billingDate))
{
errorMessages.Add("Date format is not correct for MeterNo. " + meterNo + " at row " + row);
continue;
}
if (!string.IsNullOrEmpty(meterNo))
{
meterNo = meterNo.PadLeft(9, '0');
var oldMeter = _meterRepository.GetBySiteIdAndMeterNo(siteId, meterNo);
var newMeter = _meterRepository.GetBySiteIdAndMeterNo(siteId, meterNo);
int wattUnit = 1000;//loads should be multiple of 1000(watt)
int smsWarningUnit = 100;//sms warnings should be multiple of 100
if (newMeter == null)
{
errorMessages.Add("MeterNo. " + meterNo + " does not exist.");
continue;
}
if (sanctionLoadMains.HasValue && sanctionLoadMains >= 500)
{
newMeter.LoadSenctionMain = sanctionLoadMains.Value;
}
if (sanctionLoadDG.HasValue && sanctionLoadDG >= 500)
{
newMeter.LoadSenctionDG = sanctionLoadDG.Value;
}
if (unitArea.HasValue)
{
newMeter.UnitArea = unitArea.Value;
}
if (creditLimit.HasValue)
{
newMeter.CreditLimit = creditLimit.Value;
}
if (sMSWarning.HasValue && sMSWarning >= 100)
{
newMeter.SMSWarningAmount = sMSWarning.Value;
}
if (sMSWarning1.HasValue && sMSWarning1 >= 100)
{
newMeter.SMSWarning1Amount = sMSWarning1.Value;
}
if (billingDate != null)
{
newMeter.BillingDate = billingDate.ToIndiaDateTime();
}
_meterRepository.AddOrUpdate(newMeter);
var meterNotes = Helpers.MeterHelpers.Functions.GetMeterNote(oldMeter, newMeter);
Helpers.MeterHelpers.Functions.AddMeterNotes(meterNo, meterNotes);
totalProcessedMeters++;
}
}
TempData["SuccessMessage"] = totalProcessedMeters + " Meter(s) have been updated successfully";
}

Not getting the Total Amount(Without VAT)

Country: Bahrain( i am selecting)
Amount:1000
Bank charges: 100(i am entering)
Vat:5%(entering) result:50(autogenerate)
Discount:6%(entering) result:60(autogenerate)
Total:1070(autogenerate)
This is working fine.I am getting the Total(with VAT).
Country:India(i am selecting)
Amount:1000
Bank charges: 100(i am entering)
Discount:5%(entering) result:50(autogenerate)
Total:(here i am not getting the amount)(may be because i set the visibility of VAT field false)
Here i am hidding the field VAT by using vattr.Visible=false. What should i do in order to sort out this issue?
Code behind:
protected void lstCountryy_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstCountryy.SelectedItem.Text == "U.A.E" || lstCountryy.SelectedItem.Text == "BAHRAIN" || lstCountryy.SelectedItem.Text=="SAUDI ARABIA")
{
vattr.Visible = true;
trdeclaration.Visible = false;
}
else
{
vattr.Visible = false;
trdeclaration.Visible = true;
}
}
Javascript:
function calculate(amount) {
var bankcharge = document.getElementById("<%=txtBankCharge.ClientID%>").value;
var vat = document.getElementById("<%=txtvatt.ClientID%>").value;
var discount = document.getElementById("<%=txtDiscount.ClientID%>").value;
var sum = 0;
$(".amt").each(function () {
if (isNaN(this.value))
{
alert("Please enter numbers only");
return false;
}
if (!isNaN(this.value) && this.value.length != 0) {
sum += parseFloat(this.value);
}
});
if (bankcharge.length > 0) {
if (isNaN(bankcharge)) {
alert("Bank charge should be numbers only !!");
return false;
}
else {
sum = sum + parseFloat(bankcharge);
}
}
if (vat.length > 0)
{
if (isNaN(vat)) {
alert("VAT should be numbers only !!");
return false;
}
else {
sum = sum + parseFloat(vat);
}
}
if (discount.length > 0) {
if (isNaN(discount)) {
alert("Discount amount should be numbers only !!");
return false;
}
else {
sum = sum - parseFloat(discount);
}
}
var atemp = sum.toString().split(".");
if (atemp.length > 1) {
sum = sum.toFixed(2);
}
document.getElementById("<%=txtTotal.ClientID%>").value = sum;
document.getElementById("<%=txtAmountInWords.ClientID%>").value = convertNumberToWords(sum);
}
function vatCalc()//added by chetan
{
var sum = 0;
$(".amt").each(function () {
if (isNaN(this.value)) {
alert("Please enter numbers only");
return false;
}
if (!isNaN(this.value) && this.value.length != 0) {
sum += parseFloat(this.value);
}
});
var _txt2 = document.getElementById('<%= txtvat.ClientID %>');
var _txt3 = document.getElementById('<%= txtvatt.ClientID %>');
var t1=0, t2=0;
//if(_txt1.value != "") t1=_txt1.value;
if(_txt2.value != "") t2=_txt2.value;
_txt3.value = (sum * parseFloat(t2) )/ 100;
}
function discountCalc()
{
var sum = 0;
$(".amt").each(function () {
if (isNaN(this.value)) {
alert("Please enter numbers only");
return false;
}
if (!isNaN(this.value) && this.value.length != 0) {
sum += parseFloat(this.value);
}
});
var _txt2 = document.getElementById('<%= txtDiscountText.ClientID %>');
var _txt3 = document.getElementById('<%= txtDiscount.ClientID %>');
var t1=0, t2=0;
//if(_txt1.value != "") t1=_txt1.value;
if(_txt2.value != "") t2=_txt2.value;
_txt3.value = (sum * parseFloat(t2)) / 100;
}
The problem is here:
if (vat.length > 0)
{
if (isNaN(vat)) {
alert("VAT should be numbers only !!");
return false;
}
else {
sum = sum + parseFloat(vat);
}
}
I wanted to write this condition in such a way that when use selects bahrain,vat should be visible and should be calculated.
when user selects india,vat should be hidden and will yield the total amount.
Finally i got solution.This w orked perfectly.
if (lstCountryy.SelectedValue == "U.A.E" || lstCountryy.SelectedValue == "BAHRAIN" || lstCountryy.SelectedValue == "SAUDI ARABIA")
{
txtvat.Text = "";
txtvatt.Text = "";
txtBankCharge.Text = "";
txtDiscount.Text = "";
txtDiscountText.Text = "";
txtTotal.Text = "";
vattr.Style.Add("display", "float");
trdeclaration.Visible = false;
//txtvat.Enabled = true;
}
else
{
txtvat.Text = "";
txtvatt.Text = "";
txtBankCharge.Text = "";
txtDiscount.Text = "";
txtDiscountText.Text = "";
txtTotal.Text = "";
vattr.Style.Add("display", "none");
trdeclaration.Visible = true;
}

Store values from selected checkBox to a array

I have a foreach that if the checkbox of the row is selected it should do some calculations and after that store the result values in something,i'm trying to store in a array.In the end i need to have, for example 4 rows that were selected with his values inside the array,after that i need to put this values inside a session,and recover in other page(A confirmation page).I'm trying this.But i cant figure out a way to store the select rows in a array.I dont necessary need to be array if someone knows a better way.
string[] valoresSelecionados;
foreach (GridViewRow grdCount in grdSimulacao.Rows)
{
if (((CheckBox)grdCount.FindControl("chkSeleciona")).Checked)
{
if (double.Parse(grdCount.Cells[5].Text) >= 0)
vlNotas += double.Parse(grdCount.Cells[5].Text);
else
vlDebito += double.Parse(grdCount.Cells[5].Text);
if (!string.IsNullOrEmpty(grdCount.Cells[8].Text) && grdCount.Cells[8].Text != " ")
vlEncargos += double.Parse(grdCount.Cells[8].Text);
_simulacao.Notas.Rows.Add(grdCount.Cells[1].Text);
if (Culture== "English (United States)")
{
//DateTime data =DateTime.Parse(grdCount.Cells[2].Text);
//var dataInicial = data.ToString("mm-DD-yyyy");
_simulacao.Notas.Rows[u]["DTEMISSAO"] = grdCount.Cells[2].Text;
_simulacao.Notas.Rows[u]["DTVENCIMENTO"] = grdCount.Cells[3].Text;
}
else
{
_simulacao.Notas.Rows[u]["DTEMISSAO"] = grdCount.Cells[2].Text;
_simulacao.Notas.Rows[u]["DTVENCIMENTO"] = grdCount.Cells[3].Text;
}
_simulacao.Notas.Rows[u]["PRAZOPGTO"] = "5";
_simulacao.Notas.Rows[u]["VALTOTAL"] = grdCount.Cells[5].Text;
_simulacao.Notas.Rows[u]["DOCCOMPRAS"] = grdCount.Cells[6].Text;
if (DateTime.Parse(grdCount.Cells[3].Text) < DateTime.Parse(txtDtCredito.Text))
dtok = true;
DateTime antigaData = DateTime.Parse(grdCount.Cells[3].Text);
DateTime novaData = DateTime.Parse(txtDtCredito.Text);
DateTime dataAtual = DateTime.Today;
int diaAtual = dataAtual.DayOfYear;
int diaNovo = novaData.DayOfYear;
int diaAntigo = antigaData.DayOfYear;
int anoAtual = dataAtual.Year;
int anoNovo = novaData.Year;
if (diaAntigo <= diaNovo)
{
dataErro++;
}
if (diaNovo == diaAtual || diaNovo == diaAtual + 1 || diaNovo == diaAtual + 2 ||
diaNovo == diaAtual + 3 || diaNovo < diaAtual || anoAtual < anoNovo)
{
error++;
}
else
{
TimeSpan ts = antigaData - novaData;
if ((double.Parse(grdCount.Cells[5].Text)) < 0)
{
}
else
{
_simulacao.Notas.Rows[u]["DIASANTEC"] = ts.Days;
}
}
if (grdCount.Cells[7].Text != " ")
_simulacao.Notas.Rows[u]["DIASANTEC"] = "10";
else
_simulacao.Notas.Rows[u]["DIASANTEC"] = "0";
if (!string.IsNullOrEmpty(grdCount.Cells[8].Text) && grdCount.Cells[8].Text != " ")
{
_simulacao.Notas.Rows[u]["VLFINAL"] = double.Parse(grdCount.Cells[5].Text) - double.Parse(grdCount.Cells[8].Text);
_simulacao.Notas.Rows[u]["VLENCARGOS"] = grdCount.Cells[8].Text;
}
else
{
_simulacao.Notas.Rows[u]["VLFINAL"] = double.Parse(grdCount.Cells[5].Text);
_simulacao.Notas.Rows[u]["VLENCARGOS"] = "0,00";
}
valoresSelecionados[] = _simulacao.Notas.Rows.Add[u];
u++;
}
}
The first Picture show the first grid with all values.I selected 4 for example,after the calculations of the method i need to show only the 4 select in a model (second Picture),under the first grid of Picture two i will put the new grid with the selected values from before.

Categories