Пример #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            BaseProductionPlanLineTable planline  = new BaseProductionPlanLineTable();
            BaseProductionPlanTable     PlanTable = new BaseProductionPlanTable();
            BaseProductionScheduleProductionProcessTable bpsppmodel = null;
            int CHKchooseCount = 0;

            //int CHKChoosesame = 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++)
            {
                bpsppmodel = new BaseProductionScheduleProductionProcessTable();
                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["PSPP_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS))
                    {
                        if (row.Cells["PSPP_ACTUAL_START_TIME"].Value.ToString() != "")
                        {
                            bpsppmodel.ACTUAL_START_TIME = CConvert.ToDateTime(row.Cells["PSPP_ACTUAL_START_TIME"].Value.ToString());
                        }
                        else
                        {
                            MessageBox.Show("您选择的生产工单加工开始日期不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (row.Cells["PSPP_ACTUAL_END_TIME"].Value.ToString() != "")
                        {
                            bpsppmodel.ACTUAL_END_TIME = CConvert.ToDateTime(row.Cells["PSPP_ACTUAL_END_TIME"].Value.ToString());
                        }
                        else
                        {
                        }
                        bpsppmodel.STATUS_FLAG          = 1;
                        bpsppmodel.SLIP_NUMBER          = row.Cells["SLIP_NUMBER"].Value.ToString();
                        bpsppmodel.SCHEDULE_LINE_NUNBER = CConvert.ToInt32(row.Cells["SCHEDULE_LINE_NUNBER"].Value.ToString());
                        bpsppmodel.LINE_NUMBER          = CConvert.ToInt32(row.Cells["PSPP_LINE_NUMBER"].Value.ToString());
                        // model.AddProductionProcess(bpsppmodel);
                        PlanTable.AddItemProductionProcess(bpsppmodel);
                    }

                    else if (row.Cells["PSPP_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS_START))
                    {
                        MessageBox.Show("您选择的生产工单加工已开始!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else if (row.Cells["PSPP_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS_END))
                    {
                        MessageBox.Show("您选择的生产工单加工已结束!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    #region   更改明细中的status
                    //string strWhere = "SLIP_NUMBER=" + row.Cells["SLIP_NUMBER"].Value.ToString() + " AND SCHEDULE_LINE_NUNBER=" + Convert.ToInt32(row.Cells["SCHEDULE_LINE_NUNBER"].Value.ToString());
                    //DataSet ds = bProductionPlanSearch.GetProductionPlan(strWhere);
                    //int status = 0;
                    //int endstatus = 0;
                    //int count = ds.Tables[0].Rows.Count;
                    //foreach (DataRow dt in ds.Tables[0].Rows)
                    //{
                    //    if (Convert.ToInt32(dt["PSPP_STATUS_FLAG"]) == 0)
                    //    {
                    //        status++;
                    //    }
                    //    else if (Convert.ToInt32(dt["PSPP_STATUS_FLAG"]) == 2)
                    //    {
                    //        endstatus++;
                    //    }
                    //}
                    //if (status == count)
                    //{

                    //}
                    //else if (endstatus == count)
                    //{
                    //    planline = new BaseProductionPlanLineTable();
                    //    planline.SLIP_NUMBER = row.Cells["SLIP_NUMBER"].Value.ToString();
                    //    planline.LINE_NUMBER = Convert.ToInt32(row.Cells["SCHEDULE_LINE_NUNBER"].Value.ToString());
                    //    planline.STATUS_FLAG = 2;
                    //    PlanTable.AddItem(planline);
                    //}
                    //else
                    //{
                    //    planline = new BaseProductionPlanLineTable();
                    //    planline.SLIP_NUMBER = row.Cells["SLIP_NUMBER"].Value.ToString();
                    //    planline.LINE_NUMBER = Convert.ToInt32(row.Cells["SCHEDULE_LINE_NUNBER"].Value.ToString());
                    //    planline.STATUS_FLAG = 1;
                    //    PlanTable.AddItem(planline);
                    //}
                    //#endregion
                    //#region 更改status
                    //string strWhere1 = "SLIP_NUMBER=" + row.Cells["SLIP_NUMBER"].Value.ToString();
                    //DataSet scheduleds = bProductionPlanSearch.GetProductionPlan(strWhere1);
                    //int schedulestatus = 0;
                    //int scheduleendstatus = 0;
                    //int schedulecount = scheduleds.Tables[0].Rows.Count;
                    //foreach (DataRow dt in scheduleds.Tables[0].Rows)
                    //{
                    //    if (Convert.ToInt32(dt["PSL_STATUS_FLAG"]) == 0)
                    //    {
                    //        schedulestatus++;
                    //    }
                    //    else if (Convert.ToInt32(dt["PSL_STATUS_FLAG"]) == 2)
                    //    {
                    //        scheduleendstatus++;
                    //    }
                    //}
                    //if (schedulestatus == schedulecount)
                    //{

                    //}
                    //else if (scheduleendstatus == schedulecount)
                    //{

                    //    PlanTable.SLIP_NUMBER = row.Cells["SLIP_NUMBER"].Value.ToString();
                    //    PlanTable.STATUS_FLAG = 2;
                    //}
                    //else
                    //{
                    //    PlanTable.SLIP_NUMBER = row.Cells["SLIP_NUMBER"].Value.ToString();
                    //    PlanTable.STATUS_FLAG = 1;
                    //}
                    #endregion
                }
            }

            try
            {
                int result = bProductionPlanSearch.StartProcessing(PlanTable);
                if (result < 1)
                {
                    MessageBox.Show("您选择的生产工单加工开始失败,请检查数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    foreach (BaseProductionScheduleProductionProcessTable bpspptable in PlanTable.ItemsProductionProcess)
                    {// + " AND SCHEDULE_LINE_NUNBER=" + bpspptable.SCHEDULE_LINE_NUNBER
                        string  strWhere  = "SLIP_NUMBER=" + bpspptable.SLIP_NUMBER;
                        DataSet ds        = bProductionPlanSearch.GetProductionPlan(strWhere);
                        int     status    = 0;
                        int     endstatus = 0;
                        int     count     = ds.Tables[0].Rows.Count;
                        foreach (DataRow dt in ds.Tables[0].Rows)
                        {
                            if (CConvert.ToInt32(dt["PSPP_STATUS_FLAG"]) == CConvert.ToInt32(CConstant.STATUS))
                            {
                                status++;
                            }
                            else if (CConvert.ToInt32(dt["PSPP_STATUS_FLAG"]) == CConvert.ToInt32(CConstant.STATUS_END))
                            {
                                endstatus++;
                            }
                        }
                        if (status == count)
                        {
                        }
                        else if (endstatus == count)
                        {
                            planline             = new BaseProductionPlanLineTable();
                            planline.SLIP_NUMBER = bpspptable.SLIP_NUMBER;
                            planline.LINE_NUMBER = CConvert.ToInt32(bpspptable.SCHEDULE_LINE_NUNBER);
                            planline.STATUS_FLAG = CConvert.ToInt32(CConstant.STATUS_END);
                            PlanTable.AddItem(planline);
                        }
                        else
                        {
                            planline             = new BaseProductionPlanLineTable();
                            planline.SLIP_NUMBER = bpspptable.SLIP_NUMBER;
                            planline.LINE_NUMBER = CConvert.ToInt32(bpspptable.SCHEDULE_LINE_NUNBER);
                            planline.STATUS_FLAG = CConvert.ToInt32(CConstant.STATUS_START);
                            PlanTable.AddItem(planline);
                        }
                    }

                    try
                    {
                        int resultstatus = bProductionPlanSearch.LineStatus(PlanTable);
                    }
                    catch (Exception ex)
                    {
                    }
                    foreach (BaseProductionScheduleProductionProcessTable bpspptable in PlanTable.ItemsProductionProcess)
                    {
                        //更改status
                        string  strWhere1         = "SLIP_NUMBER=" + bpspptable.SLIP_NUMBER;
                        DataSet scheduleds        = bProductionPlanSearch.GetProductionPlan(strWhere1);
                        int     schedulestatus    = 0;
                        int     scheduleendstatus = 0;
                        int     schedulecount     = scheduleds.Tables[0].Rows.Count;
                        foreach (DataRow dt in scheduleds.Tables[0].Rows)
                        {
                            if (CConvert.ToInt32(dt["PSL_STATUS_FLAG"]) == CConvert.ToInt32(CConstant.STATUS))
                            {
                                schedulestatus++;
                            }
                            else if (CConvert.ToInt32(dt["PSL_STATUS_FLAG"]) == CConvert.ToInt32(CConstant.STATUS_END))
                            {
                                scheduleendstatus++;
                            }
                        }
                        if (schedulestatus == schedulecount)
                        {
                        }
                        else if (scheduleendstatus == schedulecount)
                        {
                            PlanTable.SLIP_NUMBER = bpspptable.SLIP_NUMBER;
                            PlanTable.STATUS_FLAG = CConvert.ToInt32(CConstant.STATUS_END);
                        }
                        else
                        {
                            PlanTable.SLIP_NUMBER = bpspptable.SLIP_NUMBER;
                            PlanTable.STATUS_FLAG = CConvert.ToInt32(CConstant.STATUS_START);
                        }
                    }
                    try
                    {
                        int resultschedule = bProductionPlanSearch.Status(PlanTable);
                    }
                    catch (Exception ex)
                    {
                    }
                    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);
            }
        }