示例#1
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow.Cells["已下订单数"].Value.ToString() == "")
            {
                dataGridView1.CurrentRow.Cells["已下订单数"].Value = 0;
            }

            dataGridView1.CurrentRow.Cells["计算已下订单数"].Value =
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["计算已下订单数"].Value) - m_dcmOrderFormCount +
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["已下订单数"].Value);

            DataTable dtJumblyGoods = m_serverBom.GetJumblyGoods(Convert.ToInt32(dataGridView1.CurrentRow.Cells["物品ID"].Value));

            for (int i = 0; i < dtJumblyGoods.Rows.Count; i++)
            {
                for (int k = 0; k < dataGridView1.Rows.Count; k++)
                {
                    if (Convert.ToInt32(dtJumblyGoods.Rows[i]["JumblyGoodsID"])
                        == Convert.ToInt32(dataGridView1.Rows[k].Cells["物品ID"].Value))
                    {
                        dataGridView1.Rows[k].Cells["计算已下订单数"].Value =
                            Convert.ToDecimal(dataGridView1.CurrentRow.Cells["计算已下订单数"].Value);


                        dataGridView1.Rows[k].Cells["第一月订货总数"].Value =
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["第一月计划数"].Value) +
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["计算安全库存数"].Value) -
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["计算库存数"].Value) -
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["计算待检数"].Value) -
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["计算已下订单数"].Value);

                        dataGridView1.Rows[k].Cells["第二月订货总数"].Value =
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["第一月订货总数"].Value) +
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["第二月计划数"].Value);

                        if (Convert.ToDecimal(dataGridView1.Rows[k].Cells["第二月订货总数"].Value) > 0)
                        {
                            dataGridView1.Rows[k].Cells["第三月订货总数"].Value =
                                Convert.ToDecimal(dataGridView1.Rows[k].Cells["第三月计划数"].Value);
                        }
                        else
                        {
                            dataGridView1.Rows[k].Cells["第三月订货总数"].Value =
                                Convert.ToDecimal(dataGridView1.Rows[k].Cells["第二月订货总数"].Value) +
                                Convert.ToDecimal(dataGridView1.Rows[k].Cells["第三月计划数"].Value);
                        }


                        dataGridView1.Rows[k].Cells["第一月订货数"].Value =
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["第一月订货总数"].Value) *
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["采购份额"].Value) *
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["装配采购份额"].Value);

                        dataGridView1.Rows[k].Cells["第二月订货数"].Value =
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["第二月订货总数"].Value) *
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["采购份额"].Value) *
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["装配采购份额"].Value);

                        dataGridView1.Rows[k].Cells["第三月订货数"].Value =
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["第三月订货总数"].Value) *
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["采购份额"].Value) *
                            Convert.ToDecimal(dataGridView1.Rows[k].Cells["装配采购份额"].Value);
                    }
                }
            }

            dataGridView1.CurrentRow.Cells["第一月订货总数"].Value =
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第一月计划数"].Value) +
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["计算安全库存数"].Value) -
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["计算库存数"].Value) -
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["计算待检数"].Value) -
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["计算已下订单数"].Value);

            dataGridView1.CurrentRow.Cells["第二月订货总数"].Value =
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第一月订货总数"].Value) +
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第二月计划数"].Value);

            if (Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第二月订货总数"].Value) > 0)
            {
                dataGridView1.CurrentRow.Cells["第三月订货总数"].Value =
                    Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第三月计划数"].Value);
            }
            else
            {
                dataGridView1.CurrentRow.Cells["第三月订货总数"].Value =
                    Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第二月订货总数"].Value) +
                    Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第三月计划数"].Value);
            }


            dataGridView1.CurrentRow.Cells["第一月订货数"].Value =
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第一月订货总数"].Value) *
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["采购份额"].Value) *
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["装配采购份额"].Value);

            dataGridView1.CurrentRow.Cells["第二月订货数"].Value =
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第二月订货总数"].Value) *
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["采购份额"].Value) *
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["装配采购份额"].Value);

            dataGridView1.CurrentRow.Cells["第三月订货数"].Value =
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["第三月订货总数"].Value) *
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["采购份额"].Value) *
                Convert.ToDecimal(dataGridView1.CurrentRow.Cells["装配采购份额"].Value);
        }