private void T_Form_CY_CBD_D_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (T_Form_CY_CBD_D.Rows.Count > 0 && e.RowIndex >= 0)
{
// 计算制造成本的公式依据:工费率/产能/直通率.
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "DFWorkRate" || T_Form_CY_CBD_D.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "DFCapacity" || T_Form_CY_CBD_D.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "DFFPY")
{
try
{
T_Form_CY_CBD_D.Columns["DFManufacturingCost"].ReadOnly = true;
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFWorkRate"].Value.ToString().Trim() == "")
{
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFWorkRate"].Value = "1";
}
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFCapacity"].Value.ToString().Trim() == "")
{
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFCapacity"].Value = "1";
}
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFFPY"].Value.ToString().Trim() == "")
{
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFFPY"].Value = "1";
}
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFManufacturingCost"].Value =
System.Convert.ToDecimal(T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFWorkRate"].Value) /
System.Convert.ToDecimal(T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFCapacity"].Value) /
System.Convert.ToDecimal(T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFFPY"].Value);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
// 计算浪费成本的公式依据: (制造成本)*(1-效率)/ 效率)
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "DFManufacturingCost"
|| T_Form_CY_CBD_D.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "DFEfficiency")
{
try
{
T_Form_CY_CBD_D.Columns["DFWasteCost"].ReadOnly = true;
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFManufacturingCost"].Value.ToString().Trim() == "")
{
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFManufacturingCost"].Value = "0.00";
}
if (T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFEfficiency"].Value.ToString().Trim() == "")
{
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFEfficiency"].Value = "1";
}
T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFWasteCost"].Value =
System.Convert.ToDecimal(T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFManufacturingCost"].Value) *
(1 - System.Convert.ToDecimal(T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFEfficiency"].Value)) /
System.Convert.ToDecimal(T_Form_CY_CBD_D.Rows[e.RowIndex].Cells["DFEfficiency"].Value);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//
}
}