private void UpWorkpiece()
        {
            Models.ProductionPlan production = this.gridView.GetRow(this.gridView.FocusedRowHandle) as Models.ProductionPlan;
            //productionPlans.Add(production);

            if (m_xmlSettings == null)
            {
                m_xmlSettings = new XMLSettings();
                m_xmlSettings.ReadXMLSettings();
            }

            int result = opcClient.ReadDataFromOpcServer(m_xmlSettings.Count);

            if (!_isStop && result > 0)
            {
                this.gridView.SetRowCellValue(m_focusedRowHandle, "TotalNum", result);
            }

            _isStop            = true;
            m_focusedRowHandle = this.gridView.FocusedRowHandle;

            opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0);

            opcClient.WriteDataToOpcServer(production);
            RunAsync(() =>
            {
                ReadAsync(production.WorkpieceType, production.TotalNum, 0);
            });
        }
        /// <summary>
        /// 上移
        /// </summary>
        private void MoveUp()
        {
            int dsRowIndex = this.gridView.GetFocusedDataSourceRowIndex();

            if (this.gridView.IsFirstRow == true)
            {               //当前节点是第一个节点,不用上移
                return;
            }
            //this.gridView.GetFocusedRow
            Models.ProductionPlan role = this.gridView.GetFocusedRow() as Models.ProductionPlan;
            if (role != null)
            {
                //
                int tIndex     = dsRowIndex - 1;
                int tRowHandle = this.gridView.GetRowHandle(tIndex);
                Models.ProductionPlan t_role = this.gridView.GetRow(tRowHandle) as Models.ProductionPlan;
                //t_role.SID = t_role.SID + 1;
                //tService.SaveRole(t_role);
                //
                //显示
                List <Models.ProductionPlan> roleList = this.gridControl.DataSource as List <Models.ProductionPlan>;
                int selectIndex = roleList.IndexOf(role);
                roleList[selectIndex]     = roleList[selectIndex - 1];
                roleList[selectIndex - 1] = role;
                //
                productionPlans             = roleList;
                this.gridControl.DataSource = roleList;
                this.gridControl.RefreshDataSource();
                this.gridView.MovePrev();
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            int totalNum = txt_TotalNum.EditValue == null ? 0 : Convert.ToInt32(txt_TotalNum.EditValue);

            Models.ProductionPlan production = new Models.ProductionPlan
            {
                BatchNo = txt_BatchNo.EditValue.ToString(),
                //WorkpieceNo = txt_WorkpieceNo.EditValue.ToString(),
                WorkpieceType = txt_WorkpieceType.EditValue.ToString(),
                PrimerColor   = txt_PrimerColor.EditValue.ToString(),
                //PrimerFirm = txt_PrimerFirm.EditValue.ToString(),
                //PrimerCraft = txt_PrimerCraft.EditValue.ToString(),
                PigmentedCoatingColor = txt_PigmentedCoatingColor.EditValue.ToString(),
                //PigmentedCoatingFirm = txt_PigmentedCoatingFirm.EditValue.ToString(),
                //PigmentedCoatingCraft = txt_PigmentedCoatingCraft.EditValue.ToString(),
                VarnishColor = txt_VarnishColor.EditValue.ToString(),
                //VarnishFirm = txt_VarnishFirm.EditValue.ToString(),
                //VarnishCraft = txt_VarnishCraft.EditValue.ToString(),
                TotalNum        = totalNum,
                Validity        = 1,
                UpTime          = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                RecordTimestamp = DateTime.Now,
                UID             = 1
            };

            int result = m_productionPlanDao.InsertProductionPlan(production);

            if (result > 0)
            {
                dialogResult = MessageBox.Show("添加成功");
                if (dialogResult == DialogResult.OK)
                {
                    m_parent.m_productionPlanList.Add(production);

                    m_parent.gridControl.DataSource = m_parent.m_productionPlanList;

                    /*
                     * Dictionary<object, string> dicButtons = new Dictionary<object, string>();
                     * dicButtons.Add("Up", "上件");
                     * dicButtons.Add("Stop", "暂停");
                     * dicButtons.Add("Finish", "结束");
                     * RepositoryItemButtonEdit ribe = CreateRepositoryItemButtonEdit(dicButtons);
                     * ribe.ButtonClick += new ButtonPressedEventHandler(m_parent.ribe_ButtonClick);   //绑定事件
                     *
                     * m_parent.gridView.Columns["Operating"].ColumnEdit = ribe;
                     */
                    this.Close();
                }
            }
            else
            {
                dialogResult = MessageBox.Show("添加失败");
            }
        }
Example #4
0
 /// <summary>
 /// 设置编辑框的值
 /// </summary>
 /// <param name="model"></param>
 public void SetEditValues(Models.ProductionPlan model)
 {
     txt_BatchNo.EditValue = model.BatchNo;
     txt_PigmentedCoatingColor.EditValue = model.PigmentedCoatingColor;
     txt_PigmentedCoatingCraft.EditValue = model.PigmentedCoatingCraft;
     txt_PigmentedCoatingFirm.EditValue  = model.PigmentedCoatingFirm;
     txt_PrimerColor.EditValue           = model.PrimerColor;
     txt_PrimerCraft.EditValue           = model.PrimerCraft;
     txt_PrimerFirm.EditValue            = model.PrimerFirm;
     txt_VarnishColor.EditValue          = model.VarnishColor;
     txt_VarnishCraft.EditValue          = model.VarnishCraft;
     txt_VarnishFirm.EditValue           = model.VarnishFirm;
     txt_WorkpieceNo.EditValue           = model.WorkpieceNo;
     txt_WorkpieceType.EditValue         = model.WorkpieceType;
     date_UpTime.EditValue = string.IsNullOrEmpty(model.UpTime) ?
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : model.UpTime;
 }
        private void StopWorkpiece()
        {
            Models.ProductionPlan production = this.gridView.GetRow(this.gridView.FocusedRowHandle) as Models.ProductionPlan;
            int result = opcClient.ReadDataFromOpcServer(m_xmlSettings.Count);

            this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, "TotalNum", result);

            if (opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0))
            {
                opcClient.WriteDataToOpcServer(new Models.ProductionPlan
                {
                    BatchNo               = "0",
                    WorkpieceType         = "0",
                    PrimerColor           = "0",
                    PigmentedCoatingColor = "0",
                    VarnishColor          = "0",
                    WorkpieceNo           = "0",
                    PrimerFirm            = "0",
                    PrimerCraft           = "0",
                    PigmentedCoatingFirm  = "0",
                    PigmentedCoatingCraft = "0",
                    VarnishFirm           = "0",
                    VarnishCraft          = "0",
                    TotalNum              = 0
                });
            }

            _isStop = true;

            RunInMainthread(() =>
            {
                foreach (var windowsUIButton in this.windowsUIButtonPanel.Buttons)
                {
                    if (windowsUIButton.GetType() == typeof(WindowsUIButton))
                    {
                        WindowsUIButton button = (WindowsUIButton)windowsUIButton;
                        if (button.Caption == "全部上件")
                        {
                            button.Enabled = true;
                        }
                    }
                }
                this.lbl_CurrentInstall.Text = $"当前没有上件";
            });
        }
 /// <summary>
 /// 删除选中行
 /// </summary>
 private void DeleteSelect()
 {
     if (MessageBox.Show("确认删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         int index = this.gridView.FocusedRowHandle;
         Models.ProductionPlan production = this.gridView.GetRow(index) as Models.ProductionPlan;
         //int result = m_productionPlanDao.DeleteById(production.Id);
         for (int i = 0; i < productionPlans.Count; i++)
         {
             if (productionPlans[i].Id == production.Id)
             {
                 productionPlans.RemoveAt(i);
             }
         }
         this.gridControl.DataSource = productionPlans;
         this.gridControl.RefreshDataSource();
     }
 }
        private void gridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            Models.ProductionPlan role = this.gridView.GetFocusedRow() as Models.ProductionPlan;
            int result = m_productionPlanDao.UpdateProductionPlan(role);

            if (result > 0)
            {
                for (int i = 0; i < productionPlans.Count; i++)
                {
                    if (productionPlans[i].Id == role.Id)
                    {
                        productionPlans[i].BatchNo               = role.BatchNo;
                        productionPlans[i].WorkpieceType         = role.WorkpieceType;
                        productionPlans[i].PrimerColor           = role.PrimerColor;
                        productionPlans[i].PigmentedCoatingColor = role.PigmentedCoatingColor;
                        productionPlans[i].VarnishColor          = role.VarnishColor;
                        productionPlans[i].TotalNum              = role.TotalNum;
                    }
                }

                this.gridControl.DataSource = productionPlans;
                this.gridControl.RefreshDataSource();
            }
        }
Example #8
0
 /// <summary>
 /// 选择已有记录自动充填编辑框
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void historyRecordGridView_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     Models.ProductionPlan model = this.gridView.GetRow(e.RowHandle) as Models.ProductionPlan;
     SetEditValues(model);
 }
Example #9
0
        /// <summary>
        /// 导入数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Import_Click(object sender, EventArgs e)
        {
            List <Models.ProductionPlan> productionPlans = new List <Models.ProductionPlan>();

            Models.ProductionPlan productionPlan;
            for (int i = 0; i < this.excelGridView.RowCount; i++)
            {
                DataRow dr = this.excelGridView.GetDataRow(i);
                productionPlan = new Models.ProductionPlan
                {
                    BatchNo               = dr.ItemArray[0].ToString(),
                    WorkpieceNo           = dr.ItemArray[1].ToString(),
                    WorkpieceType         = dr.ItemArray[2].ToString(),
                    PrimerColor           = dr.ItemArray[3].ToString(),
                    PrimerFirm            = dr.ItemArray[4].ToString(),
                    PrimerCraft           = dr.ItemArray[5].ToString(),
                    PigmentedCoatingColor = dr.ItemArray[6].ToString(),
                    PigmentedCoatingFirm  = dr.ItemArray[7].ToString(),
                    PigmentedCoatingCraft = dr.ItemArray[8].ToString(),
                    VarnishColor          = dr.ItemArray[9].ToString(),
                    VarnishFirm           = dr.ItemArray[10].ToString(),
                    VarnishCraft          = dr.ItemArray[11].ToString(),
                    Validity              = 1,
                    UpTime          = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    RecordTimestamp = DateTime.Now
                };

                productionPlans.Add(productionPlan);
            }

            int result = m_productionPlanDao.InsertProductionPlans(productionPlans);

            if (result > 0)
            {
                dialogResult = MessageBox.Show("添加成功");
                if (dialogResult == DialogResult.OK)
                {
                    //BindingList<Models.ProductionPlan> list = new BindingList<Models.ProductionPlan>();

                    foreach (var production in productionPlans)
                    {
                        m_parent.m_productionPlanList.Add(production);
                    }

                    m_parent.gridControl.DataSource = m_parent.m_productionPlanList;

                    /*
                     * Dictionary<object, string> dicButtons = new Dictionary<object, string>();
                     * dicButtons.Add("Up", "上件");
                     * dicButtons.Add("Stop", "暂停");
                     * dicButtons.Add("Finish", "结束");
                     * RepositoryItemButtonEdit ribe = ItemOperation.CreateRepositoryItemButtonEdit(dicButtons);
                     * ribe.ButtonClick += new ButtonPressedEventHandler(m_parent.ribe_ButtonClick);   //绑定事件
                     *
                     * m_parent.gridView.Columns["Operating"].ColumnEdit = ribe;
                     */

                    this.Close();
                }
            }
            else
            {
                dialogResult = MessageBox.Show("添加失败");
            }
        }
        /// <summary>
        /// 全部上件
        /// </summary>
        private void InstallAllWorkpiece()
        {
            _isStop = false;
            if (m_xmlSettings == null)
            {
                m_xmlSettings = new XMLSettings();
                m_xmlSettings.ReadXMLSettings();
            }

            opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0);

            int rowCount = this.gridView.RowCount;

            productionPlans = new List <Models.ProductionPlan>();
            for (int i = 0; i < rowCount; i++)
            {
                Models.ProductionPlan productionPlan = this.gridView.GetRow(i) as Models.ProductionPlan;
                productionPlans.Add(productionPlan);
            }

            Task t = Task.Run(() =>
            {
                for (int i = 0; i < productionPlans.Count; i++)
                {
                    Models.ProductionPlan production = productionPlans[i];
                    opcClient.WriteDataToOpcServer(production);
                    int result = 0;
                    while (production.TotalNum > result)
                    {
                        result = opcClient.ReadDataFromOpcServer(m_xmlSettings.Count);
                        RunInMainthread(() =>
                        {
                            this.lbl_CurrentInstall.Text   = $"当前上件的程序号:{production.WorkpieceType},已经上件{result}";
                            this.gridView.FocusedRowHandle = i;
                        });

                        if (_isStop)
                        {
                            RunInMainthread(() =>
                            {
                                this.lbl_CurrentInstall.Text = $"当前没有上件";
                            });
                            return;
                        }
                    }

                    if (production.TotalNum <= result)
                    {
                        if (opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0))
                        {
                            opcClient.WriteDataToOpcServer(new Models.ProductionPlan
                            {
                                BatchNo               = "0",
                                WorkpieceType         = "0",
                                PrimerColor           = "0",
                                PigmentedCoatingColor = "0",
                                VarnishColor          = "0",
                                WorkpieceNo           = "0",
                                PrimerFirm            = "0",
                                PrimerCraft           = "0",
                                PigmentedCoatingFirm  = "0",
                                PigmentedCoatingCraft = "0",
                                VarnishFirm           = "0",
                                VarnishCraft          = "0",
                                TotalNum              = 0
                            });
                        }
                        RunInMainthread(() =>
                        {
                            foreach (var windowsUIButton in this.windowsUIButtonPanel.Buttons)
                            {
                                if (windowsUIButton.GetType() == typeof(WindowsUIButton))
                                {
                                    WindowsUIButton button = (WindowsUIButton)windowsUIButton;
                                    if (button.Caption == "全部上件")
                                    {
                                        button.Enabled = true;
                                    }
                                }
                            }
                            this.lbl_CurrentInstall.Text   = $"当前没有上件";
                            this.gridView.FocusedRowHandle = 0;
                        });
                    }
                }
            });
        }