Exemplo n.º 1
0
        //cancel the scheduled dispatches
        private void button7_Click(object sender, EventArgs e)
        {
            int        i;
            int        index;
            int        ID;
            string     updateStr;
            APSProcess APSProcessImpl = new APSProcess();

            try
            {
                if (listView1.CheckedItems.Count != 0)
                {
                    for (i = 0; i < listView1.CheckedItems.Count; i++)
                    {
                        index = listView1.CheckedItems[i].Index;
                        if (salesTableArray[index, mySQLClass.STATUS_IN_SALESORDER_DATABASE] == gVariable.SALES_ORDER_STATUS_ERP_PUBLISHED.ToString())
                        {
                            MessageBox.Show("请确认所选择的订单处于已排程状态,只有该状态的订单才可以取消排程。", "提示信息", MessageBoxButtons.OK);
                            return;
                        }
                    }

                    for (i = 0; i < listView1.CheckedItems.Count; i++)
                    {
                        index = listView1.CheckedItems[i].Index;
                        APSProcessImpl.cancelAPSProcess(Convert.ToInt32(salesTableArray[index, mySQLClass.ID_VALUE_IN_SALESORDER_DATABASE]));

                        ID        = Convert.ToInt32(salesTableArray[index, mySQLClass.ID_VALUE_IN_SALESORDER_DATABASE]);
                        updateStr = "update `" + gVariable.salesOrderTableName + "` set orderStatus = '" + gVariable.SALES_ORDER_STATUS_ERP_PUBLISHED + "', planTime1 = null, planTime2 = null, APSTime = null where id = '" + ID + "'";

                        mySQLClass.updateTableItems(gVariable.globalDatabaseName, updateStr);
                    }

                    toolClass.systemDelay(2000);
                    gVariable.APSScreenRefresh = 1;
                }
                else
                {
                    //no row selected, return directly
                    MessageBox.Show("请先在工单列表左侧的复选框中选中需要取消排程的订单,然后再点选'排程结果取消'按钮。", "提示信息", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("formal APS failed!" + ex);
            }
        }
Exemplo n.º 2
0
        //formal APS
        private void button3_Click(object sender, EventArgs e)
        {
            int i;
            int index;
            int startTimeStamp;
            int endTimeStamp;

            //int[] dispatchIndexList = new int[SALES_ORDER_NUM_MAX];
            int[]  assignedMachineByUserArray = new int[3];
            int[]  indexArray;
            string commandText;
            string companyName;

            string[] strArray;
            string[,] tableArray;
            APSProcess APSProcessImpl = new APSProcess();

            try
            {
                if (listView1.CheckedItems.Count == 0)
                {
                    index = -1;
                    //if (listView1.SelectedItems.Count != 0)
                    //    index = listView1.SelectedItems[0].Index;
                    MessageBox.Show("请先在工单列表左侧的复选框中选中需要排程的订单,然后再点选'勾选订单排程'按钮开始排程。", "提示信息", MessageBoxButtons.OK);
                    //this function still has problem, after pop up info box, the original reversely displayed lines will become normal display, need more study
                    if (listView1.SelectedItems.Count != 0)
                    {
                        //listView1.Items[index].Selected = false;
                        //toolClass.systemDelay(2000);
                        //listView1.Items[index].Selected = true;
                        //listView1.Items[index].EnsureVisible();
                    }
                    return;
                }

                for (i = 0; i < listView1.CheckedItems.Count; i++)
                {
                    index = listView1.CheckedItems[i].Index;
                    if (salesTableArray[index, mySQLClass.STATUS_IN_SALESORDER_DATABASE] != gVariable.SALES_ORDER_STATUS_ERP_PUBLISHED.ToString())
                    {
                        MessageBox.Show("请确认所选择的订单处于已导入状态,因为已排程的订单不能再次排程。若确实需要重新排程,请先取消该订单的排程结果后再尝试。", "提示信息", MessageBoxButtons.OK);
                        //  listView1.SelectedItems = index;
                        return;
                    }
                }

                indexArray = new int[listView1.CheckedItems.Count];
                strArray   = new string[listView1.CheckedItems.Count];

                //get sales order list for APS
                switch (salesOrderPrioritySelected)
                {
                case PROIRITY_ORDER_NOT_SELECTED:     //do APS by sales order receive order
                    for (i = 0; i < listView1.CheckedItems.Count; i++)
                    {
                        indexArray[i] = listView1.CheckedItems[i].Index;
                    }
                    break;

                case PROIRITY_ORDER_CUSTOMER_IMPORTANCE:      //do APS by the order of the importance of the customer company
                    //put sales order info in array and then do sorting by the importance of customer company
                    for (i = 0; i < listView1.CheckedItems.Count; i++)
                    {
                        index       = listView1.CheckedItems[i].Index;
                        companyName = salesTableArray[index, mySQLClass.CUSTOMER_IN_SALESORDER_DATABASE];

                        commandText = "select * from `" + gVariable.customerListTableName + "` where customerName = '" + companyName + "'";
                        tableArray  = mySQLClass.databaseCommonReading(gVariable.basicInfoDatabaseName, commandText);
                        if (tableArray == null)
                        {
                            MessageBox.Show("基础数据中无法找到客户名称:" + companyName + ",请确认订单信息", "提示信息", MessageBoxButtons.OK);
                            return;
                        }
                        strArray[i]   = tableArray[0, 3];
                        indexArray[i] = Convert.ToInt32(salesTableArray[index, mySQLClass.ID_VALUE_IN_SALESORDER_DATABASE]);
                    }
                    toolClass.stringSortingRecordIndex(strArray, indexArray);
                    break;

                case PROIRITY_ORDER_OUTPUT_QUANTITY:   //do APS by the order of the output quantity, function not support at this time
                case PROIRITY_ORDER_DELIVERY_TIME:     //do APS by delivery time order
                default:
                    //put sales order info in array and then do sorting by delivery time
                    for (i = 0; i < listView1.CheckedItems.Count; i++)
                    {
                        index         = listView1.CheckedItems[i].Index;
                        strArray[i]   = salesTableArray[index, mySQLClass.DELIVERY_TIME_IN_SALESORDER_DATABASE];
                        indexArray[i] = Convert.ToInt32(salesTableArray[index, mySQLClass.ID_VALUE_IN_SALESORDER_DATABASE]);
                    }
                    toolClass.stringSortingRecordIndex(strArray, indexArray);
                    break;
                }

                if (listView1.CheckedItems.Count != 0)
                {
                    assignedMachineByUserArray[0] = machineSelected1 - 1;
                    assignedMachineByUserArray[1] = machineSelected2 - 1;
                    assignedMachineByUserArray[2] = machineSelected3 - 1;

                    //start time assigned
                    if (checkBox2.Checked == true)
                    {
                        startTimeStamp = toolClass.ConvertDateTimeInt(dateTimePicker1.Value);
                    }
                    else
                    {
                        //if we use reversed APS, start time should not be considered, the user will make a judgment whether this APS result is acceptable
                        startTimeStamp = -1;
                    }

                    //complete time assigned
                    if (checkBox1.Checked == true)
                    {
                        //we need to use reversed APS by this end time
                        endTimeStamp = toolClass.ConvertDateTimeInt(dateTimePicker2.Value);
                    }
                    else
                    {
                        //if we use forwarding APS, end time should not be considered, the user will make a judgment whether this APS result is acceptable
                        endTimeStamp = -1;
                    }

                    //Console.WriteLine("start +" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    for (i = 0; i < indexArray.Length; i++)
                    {
                        APSProcessImpl.runAPSProcess(Convert.ToInt32(salesTableArray[indexArray[i], mySQLClass.ID_VALUE_IN_SALESORDER_DATABASE]), assignedMachineByUserArray, startTimeStamp, endTimeStamp);
                    }
                    //Console.WriteLine("end -" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));

                    toolClass.systemDelay(2000);
                    gVariable.APSScreenRefresh = 1;
                }
                else
                {
                    //no row selected, return directly
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("formal APS failed!" + ex);
            }
        }