public void SortChannelSwap()
        {
            if (gridView.SelectedRowsCount <= 0)
            {
                XtraMessageBox.Show("请选择要交换的烟道!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            Assembly assembly = Assembly.GetEntryAssembly();
            int handle = gridView.GetSelectedRows()[0];
            string lineCode = gridView.GetRowCellValue(handle, "LINECODE").ToString();
            string channelGroup = gridView.GetRowCellValue(handle, "CHANNELGROUP").ToString();
            string channelCode = gridView.GetRowCellValue(handle, "CHANNELCODE").ToString();
            string channelType = gridView.GetRowCellValue(handle, "CHANNELTYPE").ToString();
            DataTable table = channelDal.FindSortChannel(lineCode, channelType, channelGroup, channelCode);
            SortChannelSwapDialog swapDialog = new SortChannelSwapDialog();
            swapDialog.Icon = ((Form)Shell).Icon ?? Icon.ExtractAssociatedIcon(assembly.Location);
            swapDialog.txtStartPosition.Text = lineCode + "-" + channelGroup + "-" + channelType + "-" + gridView.GetRowCellValue(handle, "CHANNELNAME").ToString();
            swapDialog.cmbTargetPosition.Properties.DataSource = table;
            swapDialog.cmbTargetPosition.Properties.ValueMember = "CODE";
            swapDialog.cmbTargetPosition.Properties.DisplayMember = "CHANNEL";
            if (swapDialog.ShowDialog() == DialogResult.OK)
            {
                if (swapDialog.cmbTargetPosition.EditValue == null)
                    return;
                string tagetChannelCode = swapDialog.cmbTargetPosition.EditValue.ToString();
                DataRow sourceChannelRow = channelDal.FindSortChannelUSED(lineCode, channelCode);
                DataRow targetChannelRow = channelDal.FindSortChannelUSED(lineCode, tagetChannelCode);
                channelDal.UpdateSortChannelUSED(lineCode, tagetChannelCode,
                            sourceChannelRow["CIGARETTECODE"].ToString(),
                            sourceChannelRow["CIGARETTENAME"].ToString(),
                            sourceChannelRow["QUANTITY"].ToString(),
                            sourceChannelRow["SORTNO"].ToString());

                channelDal.UpdateSortChannelUSED(lineCode, channelCode,
                     targetChannelRow["CIGARETTECODE"].ToString(),
                     targetChannelRow["CIGARETTENAME"].ToString(),
                     targetChannelRow["QUANTITY"].ToString(),
                     targetChannelRow["SORTNO"].ToString());
                StockingDal stockingDal = new StockingDal();
                stockingDal.UpdateSortChannelUSED(lineCode, channelCode, "000000", targetChannelRow["GROUPNO"].ToString());
                stockingDal.UpdateSortChannelUSED(lineCode, tagetChannelCode, channelCode, sourceChannelRow["GROUPNO"].ToString());
                stockingDal.UpdateSortChannelUSED(lineCode, "000000", tagetChannelCode, targetChannelRow["GROUPNO"].ToString());

                Logger.Info(string.Format("{0}{1}号烟道与{2}号烟道交换成功!", channelGroup, channelCode, tagetChannelCode));
                Refresh();
            }
        }
 public void SortChannelSwap()
 {
     if (gridView.SelectedRowsCount <= 0)
     {
         XtraMessageBox.Show("请选择要交换的烟道!", "提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
         return;
     }
     Assembly assembly = Assembly.GetEntryAssembly();
     int handle = gridView.GetSelectedRows()[0];
     string lineCode = gridView.GetRowCellValue(handle, "LINECODE").ToString();
     string channelGroup = gridView.GetRowCellValue(handle, "CHANNELGROUP").ToString();
     string channelCode = gridView.GetRowCellValue(handle, "CHANNELCODE").ToString();
     string channelType = gridView.GetRowCellValue(handle, "CHANNELTYPE").ToString();
     DataTable table = channelDal.FindSortChannel(lineCode, channelType, channelGroup, channelCode);
     SortChannelSwapDialog swapDialog = new SortChannelSwapDialog();
     swapDialog.Icon=((Form)Shell).Icon ?? Icon.ExtractAssociatedIcon(assembly.Location);
     swapDialog.txtStartPosition.Text = lineCode + "-" + channelGroup + "-" + channelType + "-" + gridView.GetRowCellValue(handle, "CHANNELNAME").ToString();
     swapDialog.cmbTargetPosition.Properties.DataSource = table;
     swapDialog.cmbTargetPosition.Properties.ValueMember = "CODE";
     swapDialog.cmbTargetPosition.Properties.DisplayMember = "CHANNEL";
     if (swapDialog.ShowDialog() == DialogResult.OK)
     {
         if (swapDialog.cmbTargetPosition.EditValue == null)
             return;
         string tagetChannelCode=swapDialog.cmbTargetPosition.EditValue.ToString();
         string[] data = new string[3];
         orderDal.UpdateOrderDetailByChannelCode(channelCode, "000000");
         orderDal.UpdateOrderDetailByChannelCode(tagetChannelCode, channelCode);
         orderDal.UpdateOrderDetailByChannelCode("000000",tagetChannelCode);
         DataRow row1=channelDal.FindSortChannelByCode(tagetChannelCode);
         DataRow row2 = channelDal.FindSortChannelByCode(channelCode);
         channelDal.UpdateSortChannelByChannelCode(channelCode, row1["CIGARETTECODE"].ToString(), row1["CIGARETTENAME"].ToString(), 
             row1["QUANTITY"].ToString(), row1["SORTNO"].ToString(), row1["STATUS"].ToString());
         data[0] = row1["CHANNELADDRESS"].ToString();
         channelDal.UpdateSortChannelByChannelCode(tagetChannelCode, row2["CIGARETTECODE"].ToString(), row2["CIGARETTENAME"].ToString(),
             row2["QUANTITY"].ToString(), row2["SORTNO"].ToString(), row2["STATUS"].ToString());
         data[1] = row2["CHANNELADDRESS"].ToString();
         data[2] = "1";
         if (channelGroup == "A线")
             Ops.Write(Global.ServiceName_SortingOPC, "A_Channel_Change", data);
         else
             Ops.Write(Global.ServiceName_SortingOPC, "B_Channel_Change", data);
         Logger.Info(string.Format("{0}{1}号烟道与{2}号烟道交换成功!", channelGroup, data[0], data[1]));
         Refresh(-1);
     }
 }