예제 #1
0
 private void Initialize()
 {
     using (var context = new Model())
     {
         _cProductProcessing = context.C_ProductProcessing.FirstOrDefault(s => s.ProductBornCode == _productBornCode);
     }
 }
예제 #2
0
        private void OfflineCntLogicTurn()
        {
            using (var context = new Model())
            {
                //在产品加工过程表中根据产品出生证  获取元数据
                _cProductProcessing = context.C_ProductProcessing.FirstOrDefault(s => s.ProductBornCode == ProductIDTxt.Text.Trim());
                //在控制点过程表中 根据产品出生证 工序编号 控制点id 设备编号(需要修改) 查到相关集合
                var cBWuECntlLogicPros = context.C_BWuE_CntlLogicPro.Where(s =>
                                                                           s.ProductBornCode == ProductIDTxt.Text.Trim() && s.ProcedureCode == _cProductProcessing.ProcedureCode &&
                                                                           s.ControlPointID == 8 && s.EquipmentCode == _equipmentCode)
                                         .OrderByDescending(s => s.StartTime).ToList();
                //判断过程表中有无数据  如果没有(说明已经转档过了) 那就不操作了弟弟
                if (cBWuECntlLogicPros.Any())
                {
                    cBWuECntlLogicPros[0].State      = "2";
                    cBWuECntlLogicPros[0].FinishTime = context.GetServerDate();

                    //遍历  添加后删除过程表中所有选中数据
                    foreach (var cBWuECntlLogicPro in cBWuECntlLogicPros)
                    {
                        var mapperConfiguration = new MapperConfiguration(cfg =>
                                                                          cfg.CreateMap <C_BWuE_CntlLogicPro, C_BWuE_CntlLogicDoc>());
                        var mapper            = mapperConfiguration.CreateMapper();
                        var cBWuECntlLogicDoc = mapper.Map <C_BWuE_CntlLogicDoc>(cBWuECntlLogicPro);

                        context.C_BWuE_CntlLogicDoc.Add(cBWuECntlLogicDoc);
                        context.C_BWuE_CntlLogicPro.Remove(cBWuECntlLogicPro);
                    }
                    context.SaveChanges();
                }
            }
        }
예제 #3
0
        private void AddCntLogicProOffline(string remark = "")
        {
            using (var context = new Model())
            {
                //在产品加工过程表中根据产品出生证  获取元数据
                _cProductProcessing = context.C_ProductProcessing.FirstOrDefault(s => s.ProductBornCode == ProductIDTxt.Text.Trim());
                var cBWuECntlLogicPro = new C_BWuE_CntlLogicPro
                {
                    ProductBornCode = ProductIDTxt.Text.Trim(),
                    ProcedureCode   = _cProductProcessing.ProcedureCode,
                    ControlPointID  = 8,
                    Sort            = "2",
                    EquipmentCode   = _equipmentCode,
                    State           = "1",
                    StartTime       = context.GetServerDate(),
                    Remarks         = remark
                };

                context.Entry(cBWuECntlLogicPro).State = EntityState.Added;
                context.SaveChanges();
            }
        }
예제 #4
0
        public void DataFill()
        {
            using (var context = new Model())
            {
                //在产品加工过程表中根据产品出生证  获取元数据
                _cProductProcessing = context.C_ProductProcessing.FirstOrDefault(s => s.ProductBornCode == _productBornCode);

                var procedureIdInt16 = Convert.ToInt16(_cProductProcessing.ProcedureID);

                //在工序自检项配置表中根据工序主键/是否启用/有效性  获得自检项数据
                //类型转换问题  数据库设计有误吗???
                _aProcedureSelfCheckingConfigs = context.A_ProcedureSelfCheckingConfig.Where(s =>
                                                                                             s.ProcedureID == procedureIdInt16 &&
                                                                                             s.IsEnable == true && s.IsAvailable == true).OrderByDescending(s => s.IsRequired).ToList();

                //动态加载txt和lbl控件
                int tabIndex      = 1;
                int localLblY     = 73;
                int localTextBoxY = 70;
                foreach (var aProcedureSelfCheckingConfig in _aProcedureSelfCheckingConfigs)
                {
                    panel3.Controls.Add(new Label()
                    {
                        Location  = new Point(110, localLblY),
                        Size      = new Size(86, 26),
                        Text      = aProcedureSelfCheckingConfig.ItemName + ':',
                        ForeColor = Color.Black,
                        TabIndex  = tabIndex,
                        BackColor = Color.Transparent,
                        Font      = new Font("微软雅黑", 10.8F, FontStyle.Bold,
                                             GraphicsUnit.Point, ((byte)(134))),
                        Name = aProcedureSelfCheckingConfig.ItemCode + "lbl"
                    });
                    localLblY += 60;

                    panel3.Controls.Add(new TextBox()
                    {
                        Location = new Point(204, localTextBoxY),
                        Size     = new Size(168, 32),
                        Name     = aProcedureSelfCheckingConfig.ItemCode + "txt"
                    });
                    localTextBoxY += 60;
                    _txtNameList.Add(aProcedureSelfCheckingConfig.ItemCode + "txt");

                    if (aProcedureSelfCheckingConfig.IsRequired != null && (bool)aProcedureSelfCheckingConfig.IsRequired)
                    {
                        panel3.Controls[$"{aProcedureSelfCheckingConfig.ItemCode + "lbl"}"].Text =
                            panel3.Controls[$"{aProcedureSelfCheckingConfig.ItemCode + "lbl"}"].Text
                            .Insert(panel3.Controls[$"{aProcedureSelfCheckingConfig.ItemCode + "lbl"}"].Text.Length - 1, "*");
                        panel3.Controls[$"{aProcedureSelfCheckingConfig.ItemCode + "lbl"}"].ForeColor = Color.Red;
                        panel3.Controls[$"{aProcedureSelfCheckingConfig.ItemCode + "txt"}"].Tag       = "*";
                        _mbNameList.Add(aProcedureSelfCheckingConfig.ItemCode);
                    }

                    //在产品质量数据表中根据 订单号项目号计划好产品号出生证工序号检验类型(自检)及检测项编号  获得特定数据(检测实际值)
                    var cProductQualityData = context.C_ProductQualityData.FirstOrDefault(s =>
                                                                                          s.OrderID == _cProductProcessing.OrderID && s.ProjectID == _cProductProcessing.ProjectID && s.PlanID == _cProductProcessing.PlanID &&
                                                                                          s.ProductID == _cProductProcessing.ProductID && s.ProductBornCode == _cProductProcessing.ProductBornCode &&
                                                                                          s.ProcedureID == _cProductProcessing.ProcedureID && s.CheckType == 1 && s.ItemCode == aProcedureSelfCheckingConfig.ItemCode);

                    if (cProductQualityData != null && cProductQualityData.CollectValue != null)
                    {
                        panel3.Controls[$"{aProcedureSelfCheckingConfig.ItemCode + "txt"}"].Text = cProductQualityData.CollectValue.ToString();
                    }
                }
            }
        }
예제 #5
0
        private void MainPanel_Load(object sender, EventArgs e)
        {
            var addXmlFile = new ConfigurationBuilder().SetBasePath("E:\\project\\visual Studio Project\\HotPressing")
                             .AddXmlFile("config.xml");
            var configuration = addXmlFile.Build();

            _workshopId    = configuration["WorkshopID"];
            _workshopCode  = configuration["WorkshopCode"];
            _workshopName  = configuration["WorkshopName"];
            _equipmentId   = configuration["EquipmentID"];
            _equipmentCode = configuration["EquipmentCode"];
            _equipmentName = configuration["EquipmentName"];

            //使用hzh控件自带的图标库 tuple

            //解析tuple 加载顶部菜单栏 绑定事件
            var workersGaugeLabel = GenerateLabel();

            workersGaugeLabel.Click += lbl_DoubleClick;

            var scanGunStateLabel = GenerateLabel();

            scanGunStateLabel.DoubleClick += lbl_DoubleClick;

            // var onlineLabel = GenerateLabel();
            // onlineLabel.Click += OpenScanOnlineForm;

            var programFilesLabel = GenerateLabel();

            programFilesLabel.Click += OpenProgramFile;

            var workInstructionLabel = GenerateLabel();

            workInstructionLabel.Click += OpenWorkInstruction;

            // var selfCheckItemInputLabel = GenerateLabel();
            // selfCheckItemInputLabel.Click += OpenSelfCheckItemForm;

            // var offlineLabel = GenerateLabel();
            // offlineLabel.Click += OpenScanOfflineForm;

            var forceOfflineLabel = GenerateLabel();

            forceOfflineLabel.Click += OpenForceOfflineForm;

            var forceOfflineLabel1 = GenerateLabel();

            forceOfflineLabel1.Click += OpenForceOfflineForm;

            var switchAccountLabel = GenerateLabel();

            switchAccountLabel.Click += OpenLoginForm;

            var exitLabel = GenerateLabel();

            exitLabel.Click += CloseForms;

            // 加载人员信息图标
            var tuple1      = new Tuple <string, string>("人员信息", "A_fa_address_card_o");
            var icon1       = (FontIcons)Enum.Parse(typeof(FontIcons), tuple1.Item2);
            var pictureBox1 = new PictureBox
            {
                AutoSize  = false,
                Size      = new Size(240, 160),
                ForeColor = Color.FromArgb(255, 77, 59),
                Image     = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59)),
                Location  = new Point(110, 20)
            };

            PersonnelInfoPanel.Controls.Add(pictureBox1);

            // 加载箭头图标
            var tuple2 = new Tuple <string, string>("Arrow", "A_fa_arrow_down");
            var icon2  = (FontIcons)Enum.Parse(typeof(FontIcons), tuple2.Item2);
            int localY = 72;

            for (var i = 0; i < 1; i++)
            {
                ProductionStatusInfoPanel.Controls.Add(new PictureBox()
                {
                    AutoSize  = false,
                    Size      = new Size(40, 40),
                    ForeColor = Color.FromArgb(255, 77, 59),
                    Image     = FontImages.GetImage(icon2, 40, Color.FromArgb(255, 77, 59)),
                    Location  = new Point(270, localY)
                });
                localY += 98;
            }

            //修改自定义控件label.text文本
            CompletedTask.label1.Text       = " 已完成任务";
            ProductionTaskQueue.label1.Text = "热压任务队列";

            InitialDidTasks();

            ucSignalLamp1.LampColor = new Color[] { Color.Green };
            ucSignalLamp2.LampColor = new Color[] { Color.Red };

            InialToDoTasks();

            //初始化生产状态信息面板
            using (var context = new Model())
            {
                //这里需要配置修改xml
                var cBBdbRCntlPntBases = context.C_BBdbR_CntlPntBase.Where(s =>
                                                                           s.CntlPntTyp == "3" && s.Enabled == 1.ToString())
                                         .OrderBy(s => s.CntlPntSort).ToList();

                int localLblY = 25;
                foreach (var cBBdbRCntlPntBase in cBBdbRCntlPntBases)
                {
                    var label = new Label()
                    {
                        Location  = new Point(239, localLblY),
                        Size      = new Size(112, 39),
                        Name      = cBBdbRCntlPntBase.CntlPntCd,
                        BackColor = Color.LightSlateGray,
                        Font      = new Font("微软雅黑", 10.8F, FontStyle.Bold,
                                             GraphicsUnit.Point, ((byte)(134))),
                        Text      = cBBdbRCntlPntBase.CntlPntNm,
                        TextAlign = ContentAlignment.MiddleCenter,
                    };
                    if (label.Name.Equals("control001"))
                    {
                        label.Click += ProductOnlineEvent;
                    }
                    // else if (label.Name.Equals("control002"))
                    // {
                    // label.Click += SelfCheckItemEvent;
                    // }
                    else if (label.Name.Equals("control002"))
                    {
                        label.Click += ProductOfflineEvent;
                    }
                    ProductionStatusInfoPanel.Controls.Add(label);
                    localLblY += 96;
                }
            }

            //获取当前加工中心的生产任务(已上线)
            using (var context = new Model())
            {
                var cProductProcessing = context.C_ProductProcessing
                                         .FirstOrDefault(s => s.WorkshopCode == _workshopCode && s.OnlineTime != null);
                if (cProductProcessing != null)
                {
                    ProductIDTxt.Text          = cProductProcessing.ProductBornCode;
                    ProductIDTxt.ReadOnly      = true;
                    ProductNameTxt.Text        = cProductProcessing.ProductName;
                    ProductNameTxt.ReadOnly    = true;
                    CurrentProcessTxt.Text     = cProductProcessing.ProcedureName;
                    CurrentProcessTxt.ReadOnly = true;
                    OnlineTimeTxt.Text         = cProductProcessing.OnlineTime.ToString();
                    OnlineTimeTxt.ReadOnly     = true;
                    // ProductOnlineLbl.BackColor = Color.MediumSeaGreen;
                    ProductionStatusInfoPanel.Controls.Find("control001", false).First().BackColor =
                        Color.MediumSeaGreen;
                }

                if (!string.IsNullOrEmpty(ProductIDTxt.Text))
                {
                    //在产品加工过程表中根据产品出生证  获取元数据
                    _cProductProcessing = context.C_ProductProcessing.FirstOrDefault(s => s.ProductBornCode == ProductIDTxt.Text.Trim());
                }
            }

            timer1.Enabled = true;
        }