private void PageProducePlan_Loaded(object sender, RoutedEventArgs e)
        {
            #region 加载数据

            lblUserInfo.Content = string.Format(@"姓名:{0}    工号:{1}", StoreInfoModel.WorkGroupInfo.GetWorkGroupDetail.UserName, StoreInfoModel.WorkGroupInfo.GetWorkGroupDetail.UserCode);

            ProducePlanInfoModel GetPPlanInfo = new BLL.ExtraBLL.ProducePlanInfoBLL().GetProducePlanInfo();
            if (!GetPPlanInfo.Result)
            {
                MessageBox.Show(GetPPlanInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            ItemsCount = StoreInfoModel.ProducePlanInfos.Count;
            List <object> PlanList = new List <object>();
            foreach (var item in StoreInfoModel.ProducePlanInfos)
            {
                PlanList.Add(new
                {
                    ContractCode = item.GetProjectProduceDetial.ContractCode,                                                   //合同编号
                    ProjectName  = item.GetProject.ProjectName,                                                                 //工程项目
                    ProcessName  = item.GetProductProcessRoute.ProcessName + "(" + item.GetProjectProduceDetial.Quantity + ")", //工序名称
                    PlanDate     = item.GetProjectProduceDetial.PlanedStartTime == null ? (item.GetProjectProduceDetial.PlanedFinishTime == null ? "--------" :
                                                                                           Convert.ToDateTime(item.GetProjectProduceDetial.PlanedFinishTime).ToString("---- - MM:dd HH:mm:ss")) : (item.GetProjectProduceDetial.PlanedFinishTime == null ?
                                                                                                                                                                                                   Convert.ToDateTime(item.GetProjectProduceDetial.PlanedStartTime).ToString("MM-dd HH:mm:ss - ----") : (Convert.ToDateTime(item.GetProjectProduceDetial.PlanedStartTime).ToString("MM-dd HH:mm:ss - ") +
                                                                                                                                                                                                                                                                                                         Convert.ToDateTime(item.GetProjectProduceDetial.PlanedFinishTime).ToString("HH:mm:ss"))),
                    Tag               = item,
                    BackGround        = Helpers.WpfHelper.GetRandomColorStr(),
                    PartNameAndFigure = item.GetProcessBOM.PartName + "【" + item.GetProcessBOM.PartFigureCode + "】"
                });
            }
            PlanCardItems.ItemsSource = PlanList;

            #endregion

            MainPage.Focus();


            var temp = BLL.Helpers.ClientHelper.RecordOperateLog(string.Format(@"用户【{0}】进入了生产计划页面!", StoreInfoModel.UserName));
            if (PlanList.Count > 0)
            {
                //RemoveBorderThickness(FocusIndex);
                AddBorderThickness(0);
            }
        }
        private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Grid grid = sender as Grid;

            if (GridContainer != null && GridContainer.Equals(grid))
            {
                StoreInfoModel.ProducePlanInfo = grid.Tag as ProducePlanInfoModel.DataModel;
                //初始化-加载该生产计划所需物料详情
                var getMaterialInfo = new BLL.ExtraBLL.MaterialInfoBLL().GetMaterialDetail();
                if (!getMaterialInfo.Result)
                {
                    MessageBox.Show(getMaterialInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                //下载图纸文件
                var drawResult = new BLL.ExtraBLL.ProducePlanInfoBLL().DownLoadDrawing();
                if (!drawResult.Result)
                {
                    MessageBox.Show(drawResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                NavigationService.GetNavigationService(this).Navigate(new Uri("ProductProcessPage.xaml", UriKind.Relative));
            }
            GridContainer = null;
        }
        private void MainPage_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape || e.Key == Key.Back)
            {
                if (MessageBox.Show("是否关机", "警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    ProcessStartInfo ps = new ProcessStartInfo();
                    ps.FileName  = "shutdown.exe";
                    ps.Arguments = "-s -t 600";
                    Process.Start(ps);
                }
            }


            switch (e.Key)
            {
            case Key.Left:
                RemoveBorderThickness(FocusIndex);
                FocusIndex = (FocusIndex - 1).Equals(-1) ? (ItemsCount - 1) : (FocusIndex - 1);
                AddBorderThickness(FocusIndex);
                break;

            case Key.Right:
                RemoveBorderThickness(FocusIndex);
                FocusIndex = (FocusIndex + 1).Equals(ItemsCount) ? 0 : (FocusIndex + 1);
                AddBorderThickness(FocusIndex);
                break;

            case Key.Up:
                var positionA = PlanCardScrollViewer.VerticalOffset;
                PlanCardScrollViewer.ScrollToVerticalOffset(positionA - 60);
                break;

            case Key.Down:
                var positionB = PlanCardScrollViewer.VerticalOffset;
                PlanCardScrollViewer.ScrollToVerticalOffset(positionB + 60);
                break;

            case Key.Enter:
                //保存当前所选计划
                var obj  = PlanCardItems.Items[FocusIndex];
                var attr = obj.GetType().GetProperty("Tag");
                StoreInfoModel.ProducePlanInfo = attr.GetValue(obj, null) as ProducePlanInfoModel.DataModel;

                //下料
                if (StoreInfoModel.WorkGroupInfo.GetWorkGroup.DepartID.Equals("0218" /*"0209"*/))
                {
                    NavigationService.GetNavigationService(this).Navigate(new Uri(@"View/BlankingRecordPage.xaml", UriKind.Relative));
                }
                //非下料车间 需要 看图纸
                else
                {
                    var temp = BLL.Helpers.ClientHelper.RecordOperateLog(string.Format(@"用户【{0}】选择了生产计划ID为【{1}】、项目名称为【{2}】的生产计划!",
                                                                                       StoreInfoModel.UserName, StoreInfoModel.ProducePlanInfo.GetProjectProduceDetial.ID, StoreInfoModel.ProducePlanInfo.GetProject.ProjectName));

                    //初始化-加载该生产计划所需物料详情
                    var getMaterialInfo = new BLL.ExtraBLL.MaterialInfoBLL().GetMaterialDetail();
                    if (!getMaterialInfo.Result)
                    {
                        MessageBox.Show(getMaterialInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    //下载图纸文件
                    var drawResult = new BLL.ExtraBLL.ProducePlanInfoBLL().DownLoadDrawing();
                    if (!drawResult.Result)
                    {
                        MessageBox.Show(drawResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }

                    NavigationService.GetNavigationService(this).Navigate(new Uri(@"View/ProduceProcePage.xaml", UriKind.Relative));
                }
                break;

            default: break;
            }

            e.Handled = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 页面按键抬起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PageContainer_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            //偏移量
            int num = 50;

            switch ((int)e.Key)
            {
            //tab键-切换焦点区域
            case 3:
                #region
                focusArea = ((int)focusArea + 1).Equals(3) ? 0 : (FocusAreaEnum)((int)focusArea + 1);
                Border border = new Border();
                border.BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 255, 255));
                border.BorderThickness = new Thickness(2);
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    for (int i = 0; i < tbDrawingList.Children.Count; i++)
                    {
                        if (tbDrawingList.Children[i] is Border)
                        {
                            tbDrawingList.Children.Remove(tbDrawingList.Children[i]);
                        }
                    }
                    tbMaterialInfo.Children.Add(border);
                    break;

                case FocusAreaEnum.CenterFocus:
                    for (int i = 0; i < tbMaterialInfo.Children.Count; i++)
                    {
                        if (tbMaterialInfo.Children[i] is Border)
                        {
                            tbMaterialInfo.Children.Remove(tbMaterialInfo.Children[i]);
                        }
                    }
                    tbDrawingShow.Children.Add(border);
                    break;

                case FocusAreaEnum.RightFocus:
                    for (int i = 0; i < tbDrawingShow.Children.Count; i++)
                    {
                        if (tbDrawingShow.Children[i] is Border)
                        {
                            tbDrawingShow.Children.Remove(tbDrawingShow.Children[i]);
                        }
                    }
                    tbDrawingList.Children.Add(border);
                    gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(240, 0, 240));
                    break;

                default: break;
                }
                #endregion
                break;

            //左
            case 23:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.CenterFocus:
                    pointX += num;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus: break;

                default: break;
                }
                #endregion
                break;

            //上
            case 24:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.CenterFocus:
                    pointY -= num;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus:
                    #region
                    gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(65, 65, 65));
                    gridDrawingIndex = (gridDrawingIndex - 1).Equals(-1) ? gridDrawings.Length - 1 : (gridDrawingIndex - 1);
                    gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(240, 0, 240));

                    //详情
                    if (gridDrawingIndex.Equals(0))
                    {
                        Grid pInfoGrid = new Grid()
                        {
                            Margin     = new Thickness(0, 1, 0, 0),
                            Background = new SolidColorBrush(Color.FromRgb(65, 65, 65))
                        };
                        TextBlock pInfoTextBlock = new TextBlock()
                        {
                            Foreground   = new SolidColorBrush(Color.FromRgb(240, 240, 240)),
                            Margin       = new Thickness(5),
                            FontSize     = 14,
                            TextWrapping = TextWrapping.Wrap,
                            Text         = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.ProcessDesc
                        };
                        pInfoGrid.Children.Add(pInfoTextBlock);
                        projectInfo.Children.Add(pInfoGrid);
                    }
                    //地图
                    else
                    {
                        if (projectInfo.Children.Count > 0)
                        {
                            projectInfo.Children.Clear();
                        }

                        OpenDrawing(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[gridDrawingIndex - 1].FileName));
                    }
                    #endregion
                    break;

                default: break;
                }
                #endregion
                break;

            //右
            case 25:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.CenterFocus:
                    pointX -= num;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus: break;

                default: break;
                }
                #endregion
                break;

            //下
            case 26:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.CenterFocus:
                    pointY += num;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus:
                    #region
                    gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(65, 65, 65));
                    gridDrawingIndex = (gridDrawingIndex + 1).Equals(gridDrawings.Length) ? 0 : (gridDrawingIndex + 1);
                    gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(240, 0, 240));

                    //详情
                    if (gridDrawingIndex.Equals(0))
                    {
                        Grid pInfoGrid = new Grid()
                        {
                            Margin     = new Thickness(0, 1, 0, 0),
                            Background = new SolidColorBrush(Color.FromRgb(65, 65, 65))
                        };
                        TextBlock pInfoTextBlock = new TextBlock()
                        {
                            Foreground   = new SolidColorBrush(Color.FromRgb(240, 240, 240)),
                            Margin       = new Thickness(5),
                            FontSize     = 14,
                            TextWrapping = TextWrapping.Wrap,
                            Text         = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.ProcessDesc
                        };
                        pInfoGrid.Children.Add(pInfoTextBlock);
                        projectInfo.Children.Add(pInfoGrid);
                    }
                    //地图
                    else
                    {
                        if (projectInfo.Children.Count > 0)
                        {
                            projectInfo.Children.Clear();
                        }

                        OpenDrawing(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[gridDrawingIndex - 1].FileName));
                    }
                    #endregion
                    break;

                default: break;
                }
                #endregion
                break;

            //-
            case 143:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.CenterFocus:
                    MouseSimulateWheelEvent(-120);
                    break;

                case FocusAreaEnum.RightFocus: break;

                default: break;
                }
                #endregion
                break;

            //+
            case 141:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.CenterFocus:
                    MouseSimulateWheelEvent(120);
                    break;

                case FocusAreaEnum.RightFocus: break;

                default: break;
                }
                #endregion
                break;

            //Ctrl键-在图纸界面焦点区域:弹出是否完工,暂停,取消对话框
            case 118:
            case 119:
                #region
                if (focusArea.Equals(FocusAreaEnum.CenterFocus))
                {
                    //MessageBoxResult dr = MessageBox.Show("如果“完工”,请选择“是”;\n如果“暂停”,请选择“否”;\n如果误操作,请选择“取消”;", "提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);

                    ProduceStateWindow window = new ProduceStateWindow();
                    window.ShowDialog();
                    MessageBoxResult dr = window.Result;

                    //完工
                    if (dr == MessageBoxResult.Yes)
                    {
                        //物料出库
                        ResultModel OutPutResult = new BLL.ExtraBLL.MaterialInfoBLL().MaterialInventory(BLL.ExtraBLL.MaterialInfoBLL.MaterialStateEnum.OtherOutput);
                        if (!OutPutResult.Result)
                        {
                            MessageBox.Show(OutPutResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }

                        //记录生产转序入库数量
                        StoreInfoModel.ProducePlanInfo.GetProjectProduceDetial.Quantity = window.Num;

                        //录入计划实际结束时间
                        ResultModel actualDateResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ActualProducePlanDate(BLL.ExtraBLL.ProducePlanInfoBLL.ProducePlanStateEnum.End);

                        //获取工艺路线,判断是否需要报检
                        var IsInspectionReport = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.IsInspectionReport ?? 0;

                        //不需要报检
                        if (IsInspectionReport.Equals(1))
                        {
                            if (string.IsNullOrEmpty(StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.WarehouseName))
                            {
                                MessageBox.Show(@"你生产的那啥没人要啊!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                            else
                            {
                                //转序入库
                                ResultModel TurnInputResult = new BLL.ExtraBLL.MaterialInfoBLL().MaterialInventory(BLL.ExtraBLL.MaterialInfoBLL.MaterialStateEnum.TurnInput);

                                if (!TurnInputResult.Result)
                                {
                                    MessageBox.Show(TurnInputResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                                }
                            }
                        }
                        //需要报检
                        else
                        {
                            //生成报检单
                            ResultModel result = new BLL.ExtraBLL.MaterialInfoBLL().InspectionReport();
                        }

                        //记录生产日志
                        ResultModel logResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ProduceLog(BLL.ExtraBLL.ProducePlanInfoBLL.ProduceLogTypeEnum.End);

                        //跳转至选择任务计划页面

                        NavigationService.GetNavigationService(this).Navigate(new Uri("ProductPlanPage.xaml", UriKind.Relative));
                    }
                    //暂停
                    else if (dr == MessageBoxResult.No)
                    {
                        //记录生产日志
                        ResultModel logResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ProduceLog(BLL.ExtraBLL.ProducePlanInfoBLL.ProduceLogTypeEnum.Pause);

                        //跳转至选择任务计划页面

                        NavigationService.GetNavigationService(this).Navigate(new Uri("ProductPlanPage.xaml", UriKind.Relative));
                    }
                    //取消
                    else
                    {
                    }
                }
                #endregion
                break;

            default: break;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region 加载基本数据

            //要加工的零件本体
            StoreInfoModel.MaterialInfo = StoreInfoModel.MaterialInfos.FirstOrDefault(item => item.GetPart.PartCode.Equals(StoreInfoModel.ProducePlanInfo.GetProjectProduceDetial.PartCode));
            //要加工的零件子集
            StoreInfoModel.MaterialChildInfos = StoreInfoModel.MaterialInfos.Where(item => !item.GetPart.PartCode.Equals(StoreInfoModel.ProducePlanInfo.GetProjectProduceDetial.PartCode)).ToList();

            #region 加载物料详情



            for (int i = 0; i < StoreInfoModel.MaterialChildInfos.Count; i++)
            {
                Viewbox viewbox = new Viewbox();

                Grid grid = new Grid();
                grid.Margin     = new Thickness(5);
                grid.Background = new SolidColorBrush(Color.FromRgb(60, 60, 60));
                grid.Width      = 200;
                grid.Height     = 100;

                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(24)
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(24)
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(24)
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(28)
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(60)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(140)
                });

                Label lblA = new Label()
                {
                    HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Color.FromRgb(0, 140, 255)), Content = "零件编码:"
                };
                Label lblB = new Label()
                {
                    HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Color.FromRgb(0, 140, 255)), Content = StoreInfoModel.MaterialChildInfos[i].GetMaterialDetail.PartCode
                };
                Label lblC = new Label()
                {
                    HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Color.FromRgb(140, 255, 26)), Content = "零件名称:"
                };
                Label lblD = new Label()
                {
                    HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Color.FromRgb(140, 255, 26)), Content = StoreInfoModel.MaterialChildInfos[i].GetMaterialDetail.PartName
                };
                Label lblE = new Label()
                {
                    HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Color.FromRgb(255, 128, 0)), Content = "已录数量:"
                };
                Label lblF = new Label()
                {
                    HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Color.FromRgb(255, 128, 0)), Content = "0/0"
                };
                TextBox txtPartCode = new TextBox()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Padding = new Thickness(6, 2, 6, 2), Margin = new Thickness(5, 0, 5, 0)
                };

                grid.Children.Add(lblA);
                grid.Children.Add(lblB);
                grid.Children.Add(lblC);
                grid.Children.Add(lblD);
                grid.Children.Add(lblE);
                grid.Children.Add(lblF);
                grid.Children.Add(txtPartCode);

                Grid.SetColumn(lblA, 0);
                Grid.SetColumn(lblB, 1);
                Grid.SetColumn(lblC, 0);
                Grid.SetColumn(lblD, 1);
                Grid.SetColumn(lblE, 0);
                Grid.SetColumn(lblF, 1);
                Grid.SetColumnSpan(txtPartCode, 2);
                Grid.SetColumn(txtPartCode, 0);

                Grid.SetRow(lblA, 0);
                Grid.SetRow(lblB, 0);
                Grid.SetRow(lblC, 1);
                Grid.SetRow(lblD, 1);
                Grid.SetRow(lblE, 2);
                Grid.SetRow(lblF, 2);
                Grid.SetRow(txtPartCode, 3);

                viewbox.Child = grid;

                MaterialInfoContainer.Children.Add(viewbox);
            }

            #endregion

            #region 加载图纸显示

            lblProjectName.Content = StoreInfoModel.ProducePlanInfo.GetProject.ProjectName;

            ((System.ComponentModel.ISupportInitialize)axMxDrawX).BeginInit();
            System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost()
            {
                Child = axMxDrawX
            };
            ((System.ComponentModel.ISupportInitialize)axMxDrawX).EndInit();

            axMxDrawX.ShowCommandWindow = false;
            axMxDrawX.ShowModelBar      = false;
            axMxDrawX.ShowStatusBar     = false;
            axMxDrawX.ShowToolBars      = false;
            axMxDrawX.Padding           = new System.Windows.Forms.Padding(0);
            axMxDrawX.Margin            = new System.Windows.Forms.Padding(0);
            axMxDrawX.IsFirstRunPan     = true;
            axMxDrawX.IsDrawCoord       = false;

            mxDraw.Children.Add(host);

            if (StoreInfoModel.ProducePlanInfo.GetPartFiles.Count > 0)
            {
                axMxDrawX.OpenDwgFile(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[0].FileName));
                axMxDrawX.GetMcDbDatabaseBound(ref pLbx, ref pLby, ref pRtx, ref pRty);
                pointX = (pRtx - pLbx) / 2;
                pointY = (pRty - pLby) / 2;
                axMxDrawX.ZoomCenter(pointX, pointY);
                axMxDrawX.ZoomScale(0.08);
            }

            #endregion

            #region 加载图纸列表

            for (int i = 0; i < StoreInfoModel.ProducePlanInfo.GetPartFiles.Count + 1; i++)
            {
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(i.Equals(0) ? 60 : 80);
                drawingListContainer.RowDefinitions.Add(row);

                gridDrawings[i] = new Grid();
                Grid.SetRow(gridDrawings[i], i);

                Binding binding = new Binding()
                {
                    RelativeSource = RelativeSource.Self,
                    Path           = new PropertyPath("FontSize")
                };
                TextBlock textBlock = new TextBlock
                {
                    TextWrapping      = TextWrapping.Wrap,
                    Foreground        = new SolidColorBrush(Color.FromRgb(240, 240, 240)),
                    VerticalAlignment = VerticalAlignment.Center,
                    Text = i.Equals(0) ? "详情" : ("图纸" + i)
                };
                textBlock.SetBinding(WidthProperty, binding);

                gridDrawings[i].Children.Add(textBlock);

                drawingListContainer.Children.Add(gridDrawings[i]);
            }

            //******************************************************************************//
            //默认显示详情
            Grid pInfoGrid = new Grid()
            {
                Margin     = new Thickness(0, 1, 0, 0),
                Background = new SolidColorBrush(Color.FromRgb(65, 65, 65))
            };
            TextBlock pInfoTextBlock = new TextBlock()
            {
                Foreground   = new SolidColorBrush(Color.FromRgb(240, 240, 240)),
                Margin       = new Thickness(5),
                FontSize     = 14,
                TextWrapping = TextWrapping.Wrap,
                Text         = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.ProcessDesc
            };
            pInfoGrid.Children.Add(pInfoTextBlock);
            projectInfo.Children.Add(pInfoGrid);
            //******************************************************************************//

            #endregion

            #endregion

            #region 录入生产日志,录入计划开始时间

            #region 录入生产日志

            //记录生产日志
            ResultModel logResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ProduceLog(BLL.ExtraBLL.ProducePlanInfoBLL.ProduceLogTypeEnum.Start);

            #endregion

            #region 录入计划开始时间

            //录入计划实际开始时间
            ResultModel actualDateResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ActualProducePlanDate(BLL.ExtraBLL.ProducePlanInfoBLL.ProducePlanStateEnum.Start);

            #endregion

            #endregion

            #region 默认焦点在左边

            Border border = new Border();
            border.BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 255, 255));
            border.BorderThickness = new Thickness(2);
            tbMaterialInfo.Children.Add(border);

            #endregion
        }
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region 加载数据

            lblUserName.Content = StoreInfoModel.WorkGroupInfo.GetWorkGroupDetail.UserName;
            lblUserCode.Content = StoreInfoModel.WorkGroupInfo.GetWorkGroupDetail.UserCode;

            //获取计划任务
            ProducePlanInfoModel GetPPlanInfo = new BLL.ExtraBLL.ProducePlanInfoBLL().GetProducePlanInfo();
            if (!GetPPlanInfo.Result)
            {
                MessageBox.Show(GetPPlanInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            //获取班组所有生产计划
            planGridContainers = new Grid[GetPPlanInfo.Data.Count];

            #endregion

            #region 加载任务计划列表数据

            long Num = 0;
            lvwPlanInfo.ItemsSource = GetPPlanInfo.Data.Select(item =>
            {
                Num++;
                return(new
                {
                    Num = Num,
                    //PartFigureCode = item.GetProductProcessRoute.FigureCode,
                    PartFigureCode = item.GetProcessBOM.PartFigureCode,
                    ProductName = item.GetProductProcessRoute.ProcessName
                });
            }).ToList();

            #endregion

            #region 加载任务计划磁贴

            for (int i = 0; i < GetPPlanInfo.Data.Count; i++)
            {
                ProducePlanInfoModel.DataModel model = GetPPlanInfo.Data[i];

                planGridContainers[i] = new Grid
                {
                    Margin     = new Thickness(5),
                    Cursor     = Cursors.Hand,
                    MinWidth   = 250,
                    Background = new SolidColorBrush(GetRandomColor()),
                    Focusable  = true,
                    Tag        = model
                };

                Grid grid = new Grid()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };

                Binding bdingGridWidth = new Binding
                {
                    ElementName = "pInfoColWidth",
                    Path        = new PropertyPath("Width")
                };
                grid.SetBinding(WidthProperty, bdingGridWidth);

                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5)
                });
                for (int j = 0; j < 4; j++)
                {
                    RowDefinition rowHeight      = new RowDefinition();
                    Binding       bdingRowHeight = new Binding
                    {
                        ElementName = "pInfoRowHeight",
                        Path        = new PropertyPath("Height")
                    };
                    rowHeight.SetBinding(RowDefinition.HeightProperty, bdingRowHeight);

                    grid.RowDefinitions.Add(rowHeight);
                }
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5)
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5)
                });
                ColumnDefinition colWidth      = new ColumnDefinition();
                Binding          bdingColWidth = new Binding
                {
                    ElementName = "pInfoColWidth",
                    Path        = new PropertyPath("Width")
                };
                colWidth.SetBinding(ColumnDefinition.WidthProperty, bdingColWidth);
                grid.ColumnDefinitions.Add(colWidth);
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5)
                });

                string[] contentArr = new string[] {
                    model.GetProjectProduceDetial.ContractCode,                                                    //合同编号
                    model.GetProject.ProjectName,                                                                  //工程项目
                    model.GetProductProcessRoute.ProcessName + "(" + model.GetProjectProduceDetial.Quantity + ")", //工序名称
                    model.GetProjectProduceDetial.PlanedStartTime == null?(model.GetProjectProduceDetial.PlanedFinishTime == null?"--------":
                                                                           Convert.ToDateTime(model.GetProjectProduceDetial.PlanedFinishTime).ToString("---- - MM:dd HH:mm:ss")):(model.GetProjectProduceDetial.PlanedFinishTime == null?
                                                                                                                                                                                  Convert.ToDateTime(model.GetProjectProduceDetial.PlanedStartTime).ToString("MM-dd HH:mm:ss - ----"):(Convert.ToDateTime(model.GetProjectProduceDetial.PlanedStartTime).ToString("MM-dd HH:mm:ss - ") +
                                                                                                                                                                                                                                                                                       Convert.ToDateTime(model.GetProjectProduceDetial.PlanedFinishTime).ToString("HH:mm:ss")))
                };
                for (int j = 0; j < 4; j++)
                {
                    Label lblContent = new Label()
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Center,
                        FontSize            = j.Equals(3) ? 16 : 20,
                        Foreground          = new SolidColorBrush(ConfigInfoModel.ColorSetting.TxtColorA),
                        Content             = contentArr[j]
                    };
                    grid.Children.Add(lblContent);

                    Grid.SetColumn(lblContent, 1);
                    Grid.SetRow(lblContent, j + 1);
                }

                planGridContainers[i].MouseDown += new MouseButtonEventHandler(Grid_MouseDown);
                planGridContainers[i].MouseUp   += new MouseButtonEventHandler(Grid_MouseUp);

                planGridContainers[i].Children.Add(grid);
                planInfoContainer.Children.Add(planGridContainers[i]);
            }

            #endregion

            #region 页面区域焦点

            //默认选择第一个生产计划
            if (planGridContainers.Length > 0)
            {
                Border borderGrid = new Border();
                borderGrid.BorderBrush     = new SolidColorBrush(Color.FromRgb(158, 183, 241));
                borderGrid.BorderThickness = new Thickness(2);
                planGridContainers[0].Children.Add(borderGrid);
            }

            Border border = new Border();
            border.BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 255, 255));
            border.BorderThickness = new Thickness(2);
            if (focusArea.Equals(FocusAreaEnum.LeftFocus))
            {
                tbPlanInfoList.Children.Add(border);
            }
            else if (focusArea.Equals(FocusAreaEnum.RightFocus))
            {
                tbPlanInfoContainer.Children.Add(border);
            }
            else
            {
            }

            //任务计划列表默认选中第一条
            lvwPlanInfo.Focus();
            if (lvwPlanInfo.Items.Count > 0)
            {
                lvwPlanInfo.SelectedIndex = 0;
            }

            #endregion
        }
        /// <summary>
        /// 页面按键抬起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PageContainer_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            //获取焦点后的边框
            Border border = new Border();

            border.BorderBrush     = new SolidColorBrush(Color.FromRgb(158, 183, 241));
            border.BorderThickness = new Thickness(2);

            switch ((int)e.Key)
            {
            //tab键-切换焦点区域
            case 3:
                #region
                focusArea = ((int)focusArea + 1).Equals(2) ? 0 : (FocusAreaEnum)((int)focusArea + 1);
                Border focusBorder = new Border();
                focusBorder.BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 255, 255));
                focusBorder.BorderThickness = new Thickness(2);
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    for (int i = 0; i < tbPlanInfoContainer.Children.Count; i++)
                    {
                        if (tbPlanInfoContainer.Children[i] is Border)
                        {
                            tbPlanInfoContainer.Children.Remove(tbPlanInfoContainer.Children[i]);
                        }
                    }
                    tbPlanInfoList.Children.Add(focusBorder);
                    break;

                case FocusAreaEnum.RightFocus:
                    for (int i = 0; i < tbPlanInfoList.Children.Count; i++)
                    {
                        if (tbPlanInfoList.Children[i] is Border)
                        {
                            tbPlanInfoList.Children.Remove(tbPlanInfoList.Children[i]);
                        }
                    }
                    tbPlanInfoContainer.Children.Add(focusBorder);
                    break;

                default: break;
                }
                #endregion
                break;

            //enter键-回车
            case 6:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.RightFocus:
                    StoreInfoModel.ProducePlanInfo = planGridContainers[planGridIndex].Tag as ProducePlanInfoModel.DataModel;
                    //初始化-加载该生产计划所需物料详情
                    var getMaterialInfo = new BLL.ExtraBLL.MaterialInfoBLL().GetMaterialDetail();
                    if (!getMaterialInfo.Result)
                    {
                        MessageBox.Show(getMaterialInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    //下载图纸文件
                    var drawResult = new BLL.ExtraBLL.ProducePlanInfoBLL().DownLoadDrawing();
                    if (!drawResult.Result)
                    {
                        MessageBox.Show(drawResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }

                    NavigationService.GetNavigationService(this).Navigate(new Uri("ProductProcessPage.xaml", UriKind.Relative));
                    break;

                default: break;
                }
                #endregion
                break;

            //左
            case 23:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.RightFocus:
                    if (planGridContainers.Length > 0)
                    {
                        for (int i = 0; i < planGridContainers[planGridIndex].Children.Count; i++)
                        {
                            if (planGridContainers[planGridIndex].Children[i] is Border)
                            {
                                planGridContainers[planGridIndex].Children.Remove(planGridContainers[planGridIndex].Children[i]);
                            }
                        }
                        planGridIndex = (planGridIndex - 1).Equals(-1) ? (planGridContainers.Length - 1) : (planGridIndex - 1);
                        planGridContainers[planGridIndex].Children.Add(border);
                    }
                    break;

                default: break;
                }
                #endregion
                break;

            //上
            case 24:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    int n = lvwPlanInfo.SelectedIndex;
                    n = (n - 1) <= -1 ? (lvwPlanInfo.Items.Count - 1) : (n - 1);
                    lvwPlanInfo.SelectedIndex = n;
                    break;

                case FocusAreaEnum.RightFocus:
                    double ah  = svPInfoContainer.VerticalOffset;
                    double num = svPInfoContainer.ScrollableHeight / 10;
                    ah = (ah - num) < 0 ? 0 : (ah - num);
                    svPInfoContainer.ScrollToVerticalOffset(ah);
                    break;

                default: break;
                }
                #endregion
                break;

            //右
            case 25:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus: break;

                case FocusAreaEnum.RightFocus:
                    if (planGridContainers.Length > 0)
                    {
                        for (int i = 0; i < planGridContainers[planGridIndex].Children.Count; i++)
                        {
                            if (planGridContainers[planGridIndex].Children[i] is Border)
                            {
                                planGridContainers[planGridIndex].Children.Remove(planGridContainers[planGridIndex].Children[i]);
                            }
                        }
                        planGridIndex = (planGridIndex + 1).Equals(planGridContainers.Length) ? 0 : (planGridIndex + 1);
                        planGridContainers[planGridIndex].Children.Add(border);
                    }
                    break;

                default: break;
                }
                #endregion
                break;

            //下
            case 26:
                #region
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    int n = lvwPlanInfo.SelectedIndex;
                    n = (n + 1).Equals(lvwPlanInfo.Items.Count) ? 0 : (n + 1);
                    lvwPlanInfo.SelectedIndex = n;
                    break;

                case FocusAreaEnum.RightFocus:
                    double ah  = svPInfoContainer.VerticalOffset;
                    double num = svPInfoContainer.ScrollableHeight / 10;
                    ah = (ah + num) > svPInfoContainer.ScrollableHeight ? svPInfoContainer.ScrollableHeight : (ah + num);
                    svPInfoContainer.ScrollToVerticalOffset(ah);
                    break;

                default: break;
                }
                #endregion
                break;

            default: break;
            }
        }