Beispiel #1
0
 public void Refresh(int sortNo)
 {
     if (sortNo != -1)
     {
         gridControl.DataSource = channelDal.FindChannelQuantity(sortNo);
     }
     else
     {
         OrderDal  orderDal = new OrderDal();
         string    sortNo_A = orderDal.FindMaxSortedMaster("A");
         string    sortNo_B = orderDal.FindMaxSortedMaster("B");
         DataTable channel  = channelDal.FindAllChannelQuantity(sortNo_A, sortNo_B);
         short[]   quantity = new short[140];
         object    state_A  = Ops.Read(Global.ServiceName_SortingOPC, "A_Led_Process_Check");
         if (state_A is Array)
         {
             Array arrayA = (Array)state_A;
             if (arrayA.Length == 70)
             {
                 arrayA.CopyTo(quantity, 0);
             }
         }
         object state_B = Ops.Read(Global.ServiceName_SortingOPC, "B_Led_Process_Check");
         if (state_B is Array)
         {
             Array arrayB = (Array)state_B;
             if (arrayB.Length == 70)
             {
                 arrayB.CopyTo(quantity, 70);
             }
         }
         for (int i = 0; i < channel.Rows.Count; i++)
         {
             if (i < 70)
             {
                 channel.Rows[i]["SORTQUANTITY"]   = Convert.ToInt32(channel.Rows[i]["SORTQUANTITY"]) - quantity[Convert.ToInt32(channel.Rows[i]["CHANNELADDRESS"]) - 1];
                 channel.Rows[i]["REMAINQUANTITY"] = Convert.ToInt32(channel.Rows[i]["REMAINQUANTITY"]) + quantity[Convert.ToInt32(channel.Rows[i]["CHANNELADDRESS"]) - 1];
                 channel.Rows[i]["BOXQUANTITY"]    = Convert.ToInt32(channel.Rows[i]["REMAINQUANTITY"]) / 50;
                 channel.Rows[i]["ITEMQUANTITY"]   = Convert.ToInt32(channel.Rows[i]["REMAINQUANTITY"]) % 50;
             }
             if (i >= 70)
             {
                 channel.Rows[i]["SORTQUANTITY"]   = Convert.ToInt32(channel.Rows[i]["SORTQUANTITY"]) - quantity[Convert.ToInt32(channel.Rows[i]["CHANNELADDRESS"]) + 69];
                 channel.Rows[i]["REMAINQUANTITY"] = Convert.ToInt32(channel.Rows[i]["REMAINQUANTITY"]) + quantity[Convert.ToInt32(channel.Rows[i]["CHANNELADDRESS"]) + 69];
                 channel.Rows[i]["BOXQUANTITY"]    = Convert.ToInt32(channel.Rows[i]["REMAINQUANTITY"]) / 50;
                 channel.Rows[i]["ITEMQUANTITY"]   = Convert.ToInt32(channel.Rows[i]["REMAINQUANTITY"]) % 50;
             }
         }
         gridControl.DataSource = channel;
         //todo:刷新LED
         //Global.Context.Processes["LEDProcess"].Resume();
         //Global.Context.ProcessDispatcher.WriteToProcess("LEDProcess", "Check", null);
     }
 }