קאוד: וועל אויס אלע
private void CalcRecipeCost(DataGridView dgv)
{
try
{
int position = this.BindingContext[recipesBindingSource].Position;
if (position > -1)
{
decimal ingCost = 0m;
foreach (DataGridViewRow r in dgv.Rows)
{
ingCost += Convert.ToDecimal(r.Cells[5].Value);
}
DataRow dr = ((DataRowView)this.recipesBindingSource.Current).Row;
decimal laborCost = 0m;
if (recipeIDTextBox.Text != "")
{
laborCost = RecipeDB.GetLaborCost(Convert.ToInt32(recipeIDTextBox.Text));
dr["LaborCost"] = laborCost;
}
dr["IngredientsCost"] = ingCost;
decimal totalCost = (ingCost + laborCost);
//dr["TotalCost"] = totalCost;
decimal costPerUnit = totalCost / Convert.ToDecimal(this.recipeQTTextBox.Text);
dr["CostPerUnit"] = costPerUnit;
decimal profitMargin = decimal.Parse(this.sellingPricePerUnitTextBox.Text, NumberStyles.Currency) - (costPerUnit / decimal.Parse(this.sellingPricePerUnitTextBox.Text, NumberStyles.Currency));
dr["Margin"] = profitMargin;
}
}
catch (FormatException ex)
{
//MessageBox.Show(ex.Message);
}
}
ביי די ליין
קאוד: וועל אויס אלע
dr["LaborCost"] = laborCost;
באקום איך די ערראר
קאוד: וועל אויס אלע
I get error "DataTable internal index is corrupted: '5'."