示例#1
0
        private void btnEnd_Click(object sender, EventArgs e)
        {
            BaseProductionPlanLineTable planline  = new BaseProductionPlanLineTable();
            BaseProductionPlanTable     PlanTable = new BaseProductionPlanTable();
            BaseProductionScheduleProductionProcessTable psppTable = new BaseProductionScheduleProductionProcessTable();
            BaseProductionTechnologyTable productionTechnology     = null;
            int CHKchooseCount = 0;

            foreach (DataGridViewRow dr in dgvData.Rows)
            {
                if (Convert.ToBoolean(dr.Cells["CHK"].Value) == true)
                {
                    CHKchooseCount++;
                }
            }
            if (CHKchooseCount < 1)
            {
                MessageBox.Show("请选择结束的数据!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string CHKSLIPNUMBER = "";

            for (int i = 0; i < dgvData.Rows.Count; i++)
            {
                productionTechnology = new BaseProductionTechnologyTable();
                if (Convert.ToBoolean(dgvData.Rows[i].Cells["CHK"].Value) == true)
                {
                    DataGridViewRow row = dgvData.Rows[i];
                    if (CHKSLIPNUMBER == "")
                    {
                        CHKSLIPNUMBER = row.Cells["SLIP_NUMBER"].Value.ToString();
                    }
                    else if (CHKSLIPNUMBER != row.Cells["SLIP_NUMBER"].Value.ToString())
                    {
                        MessageBox.Show("您选择的生产工单不相同,请重新选择!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (row.Cells["PST_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS))
                    {
                        if (row.Cells["END_DATE"].Value.ToString() != "")
                        {
                            productionTechnology.ACTUAL_END_TIME = CConvert.ToDateTime(row.Cells["END_DATE"].Value.ToString());
                        }
                        else
                        {
                            MessageBox.Show("您选择的生产工单技术结束日期不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        productionTechnology.STATUS_FLAG          = CConvert.ToInt32(CConstant.STATUS_START);
                        productionTechnology.SLIP_NUMBER          = row.Cells["SLIP_NUMBER"].Value.ToString();
                        productionTechnology.SCHEDULE_LINE_NUMBER = CConvert.ToInt32(row.Cells["PST_SCHEDULE_LINE_NUMBER"].Value.ToString());
                        productionTechnology.SCHEDULE_PRODUCTION_PROCESS_LINE_NUNBER = CConvert.ToInt32(row.Cells["PST_SCHEDULE_PRODUCTION_PROCESS_LINE_NUNBER"].Value.ToString());
                        productionTechnology.LINE_NUMBER = CConvert.ToInt32(row.Cells["PST_TECHNOLOGY_LINE_NUMBER"].Value.ToString());
                        psppTable.AddProductionTechnology(productionTechnology);
                    }

                    else if (row.Cells["PST_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS_START))
                    {
                        MessageBox.Show("您选择的生产工单技术已结束!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }

            try
            {
                int result = bProductionPlanSearch.EndTechnology(psppTable);
                if (result < 1)
                {
                    MessageBox.Show("您选择的生产工单技术结束失败,请检查数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("您选择的生产工单技术结束成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtSlipNumber.Text      = "";
                    cboStatus.SelectedIndex = 0;
                    Search();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("您选择的生产工单技术结束失败,请检查数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }