zoukankan      html  css  js  c++  java
  • 20161014001 DataGridView 单元格内容 自动计算

    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());
                        }
                    }

                    //

                }
            }

  • 相关阅读:
    设计模式03-工厂方法
    设计模式02-抽象工厂
    设计模式01-什么是设计模式
    工作流activiti-03数据查询(流程定义 流程实例 代办任务) 以及个人小练习
    工作流activiti-02事物控制、流程引擎创建
    工作流activiti-01个人小结
    jQuery.extend 函数详解
    hibernate框架学习之数据查询(QBC)
    hibernate框架学习之多表查询helloworld
    hibernate框架学习之数据查询(HQL)helloworld
  • 原文地址:https://www.cnblogs.com/hutie1980/p/5960821.html
Copyright © 2011-2022 走看看