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

                    //

                }
            }

  • 相关阅读:
    [LeetCode]*124.Binary Tree Maximum Path Sum
    HDU3336-Count the string(KMP)
    各种配置环境变量总结
    数据结构与算法-为什么要使用算法
    request 对象
    Codeforces 15B Laser
    使用jq工具在Shell命令行处理JSON数据
    Android中的FrameLayout帧布局
    iOS 8 设置导航栏的背景颜色和背景图片
    Creating HTML table with vertically oriented text as table header 表头文字方向
  • 原文地址:https://www.cnblogs.com/hutie1980/p/5960821.html
Copyright © 2011-2022 走看看