Ejemplo n.º 1
0
        //右键菜单功能
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (!(sender is MenuItem))
            {
                return;
            }
            MenuItem mi = (MenuItem)sender;

            switch (mi.Header.ToString())
            {
            case "删除":
                if (this.dgPrdctTest.SelectedItem != null)
                {
                    if (MessageBox.Show("确定要删除选中的试验数据吗?", "删除提示", MessageBoxButton.OKCancel, MessageBoxImage.Question)
                        == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                    PrdctTestBindEntity prdctTest = this.dgPrdctTest.SelectedItem as PrdctTestBindEntity;
                    if (dbPrdctTestDelete(prdctTest.Id.ToString()))
                    {
                        schedulingRefresh();    //刷新数据
                    }
                }
                else
                {
                    MessageBox.Show("没有选中要删除的项", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从库中读取对应条件的数据
        /// </summary>
        private void dbGetPrdctTest(string cmdText)
        {
            if (string.IsNullOrEmpty(cmdText))
            {
                return;
            }
            try
            {
                rwLockLpt.AcquireWriterLock(CHECKINTERVAL);//申请写锁(超过设定时间退出等待)
                try
                {
                    this.listPrdctTest.Clear();//清空上次数据

                    DataTable dtPrdctTest = DatabaseUtils.GetDataTable(cmdText);
                    if (dtPrdctTest != null && dtPrdctTest.Rows.Count > 0)
                    {
                        int serNumber = 1;
                        foreach (DataRow item in dtPrdctTest.Rows)
                        {
                            PrdctTestBindEntity prdctTest = new PrdctTestBindEntity();
                            prdctTest.SerNumber    = serNumber++;
                            prdctTest.Id           = Convert.ToInt64(item["Id"]);               //ID
                            prdctTest.PrdctId      = Convert.ToInt64(item["ProductId"]);        //产品ID
                            prdctTest.PrdctNumber  = Convert.ToString(item["PrdctNumber"]);     //品号
                            prdctTest.PrdctName    = Convert.ToString(item["PrdctName"]);       //品名
                            prdctTest.TreatType    = Convert.ToString(item["TreatType"]);       //处理类型
                            prdctTest.WeDuration   = Convert.ToString(item["WeDuration"]);      //白锈时长
                            prdctTest.ReDuration   = Convert.ToString(item["ReDuration"]);      //红锈时长
                            prdctTest.StartTime    = Convert.ToString(item["StartTime"]);       //开始时间
                            prdctTest.WeLossTime   = Convert.ToString(item["WeLossTime"]);      //白锈损失时长
                            prdctTest.ReLossTime   = Convert.ToString(item["ReLossTime"]);      //红锈损失时长
                            prdctTest.WeEndTime    = Convert.ToString(item["WeEndTime"]);       //白锈结束时间
                            prdctTest.ReEndTime    = Convert.ToString(item["ReEndTime"]);       //红锈结束时间
                            prdctTest.WeTestResult = Convert.ToString(item["WeTestResult"]);    //白锈试验结果
                            prdctTest.ReTestResult = Convert.ToString(item["ReTestResult"]);    //红锈试验结果
                            prdctTest.Remark       = Convert.ToString(item["PrdctTestRemark"]); //备注
                            //开始时间格式取MM-dd HH:mm格式
                            prdctTest.FmtStartTime = (!string.IsNullOrEmpty(prdctTest.StartTime) && prdctTest.StartTime.Length == 19) ?
                                                     prdctTest.StartTime.Substring(5, 11) : prdctTest.StartTime;
                            //白锈结束时间格式取MM-dd HH:mm格式
                            prdctTest.FmtWeEndTime = (!string.IsNullOrEmpty(prdctTest.WeEndTime) && prdctTest.WeEndTime != CommonUtils.EMPTYVALUE &&
                                                      prdctTest.WeEndTime.Length == 19) ? prdctTest.WeEndTime.Substring(5, 11) : prdctTest.WeEndTime;
                            //红锈结束时间格式取MM-dd HH:mm格式
                            prdctTest.FmtReEndTime = (!string.IsNullOrEmpty(prdctTest.ReEndTime) && prdctTest.ReEndTime != CommonUtils.EMPTYVALUE &&
                                                      prdctTest.ReEndTime.Length == 19) ? prdctTest.ReEndTime.Substring(5, 11) : prdctTest.ReEndTime;
                            this.listPrdctTest.Add(prdctTest);
                        }
                    }
                }
                finally
                {
                    rwLockLpt.ReleaseWriterLock();//释放写锁
                }
            }
            catch (Exception ex)
            {
                Logger.Error(MethodBase.GetCurrentMethod(), "读取产品数据异常:" + ex.Message);
            }
        }
Ejemplo n.º 3
0
        //右键菜单红锈处理结果
        private void MenuItemReRes_Click(object sender, RoutedEventArgs e)
        {
            if (!(sender is MenuItem))
            {
                return;
            }
            MenuItem mi = (MenuItem)sender;

            switch (mi.Header.ToString())
            {
            case "合格":
                if (this.dgPrdctTest.SelectedItem != null)
                {
                    if (MessageBox.Show("确定要将该试验记录的红锈试验结果设为合格吗?", "修改提示", MessageBoxButton.OKCancel, MessageBoxImage.Question)
                        == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                    PrdctTestBindEntity prdctTest = this.dgPrdctTest.SelectedItem as PrdctTestBindEntity;
                    if (dbPrdctTestUpd_Prop("ReTestResult", "合格", prdctTest.Id.ToString()))
                    {
                        schedulingRefresh();    //刷新数据
                    }
                }
                else
                {
                    MessageBox.Show("没有选中要处理的项", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                break;

            case "不合格":
                if (this.dgPrdctTest.SelectedItem != null)
                {
                    if (MessageBox.Show("确定要将该试验记录的红锈试验结果设为不合格吗?", "修改提示", MessageBoxButton.OKCancel, MessageBoxImage.Question)
                        == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                    PrdctTestBindEntity prdctTest = this.dgPrdctTest.SelectedItem as PrdctTestBindEntity;
                    if (dbPrdctTestUpd_Prop("ReTestResult", "不合格", prdctTest.Id.ToString()))
                    {
                        schedulingRefresh();    //刷新数据
                    }
                }
                else
                {
                    MessageBox.Show("没有选中要处理的项", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                break;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 从库中读取对应条件的数据
        /// </summary>
        private void dbGetPrdctTest(string cmdText)
        {
            if (string.IsNullOrEmpty(cmdText))
            {
                return;
            }
            try
            {
                rwLockLpt.AcquireWriterLock(CHECKINTERVAL);//申请写锁(超过设定时间退出等待)
                try
                {
                    this.listPrdctTest.Clear();//清空上次数据

                    DataTable dtPrdctTest = DatabaseUtils.GetDataTable(cmdText);
                    if (dtPrdctTest != null && dtPrdctTest.Rows.Count > 0)
                    {
                        int serNumber = 1;
                        foreach (DataRow item in dtPrdctTest.Rows)
                        {
                            PrdctTestBindEntity prdctTest = new PrdctTestBindEntity();
                            prdctTest.SerNumber    = serNumber++;
                            prdctTest.Id           = Convert.ToInt64(item["Id"]);
                            prdctTest.PrdctId      = Convert.ToInt64(item["ProductId"]);
                            prdctTest.PrdctNumber  = Convert.ToString(item["PrdctNumber"]);
                            prdctTest.TreatType    = Convert.ToString(item["TreatType"]);  //处理类型
                            prdctTest.WeDuration   = Convert.ToString(item["WeDuration"]); //白锈时长
                            prdctTest.ReDuration   = Convert.ToString(item["ReDuration"]);
                            prdctTest.StartTime    = Convert.ToString(item["StartTime"]);
                            prdctTest.WeLossTime   = Convert.ToString(item["WeLossTime"]);
                            prdctTest.ReLossTime   = Convert.ToString(item["ReLossTime"]);
                            prdctTest.WeEndTime    = Convert.ToString(item["WeEndTime"]);
                            prdctTest.ReEndTime    = Convert.ToString(item["ReEndTime"]);
                            prdctTest.WeTestResult = Convert.ToString(item["WeTestResult"]);
                            prdctTest.ReTestResult = Convert.ToString(item["ReTestResult"]);
                            prdctTest.Remark       = Convert.ToString(item["PrdctTestRemark"]);
                            this.listPrdctTest.Add(prdctTest);
                        }
                    }
                }
                finally
                {
                    rwLockLpt.ReleaseWriterLock();//释放写锁
                }
            }
            catch (Exception ex)
            {
                Logger.Error(MethodBase.GetCurrentMethod(), "加载产品数据异常:" + ex.Message);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新图片路径
 /// </summary>
 /// <param name="item"></param>
 /// <param name="imgPath"></param>
 private void updImagePath(PrdctTestBindEntity item, string imgPath)
 {
     if (item == null)
     {
         return;
     }
     if (item.ImagePath != imgPath)
     {
         //申请升级到写操作
         LockCookie lc = rwLockLpt.UpgradeToWriterLock(CHECKINTERVAL);
         try
         {
             item.ImagePath = imgPath;
         }
         finally
         {
             rwLockLpt.DowngradeFromWriterLock(ref lc);//回到调用UpgradeToWriterLock前的状态
         }
     }
 }
Ejemplo n.º 6
0
        //右键菜单功能
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (!(sender is MenuItem))
            {
                return;
            }
            MenuItem mi = (MenuItem)sender;

            switch (mi.Header.ToString())
            {
            case "删除":
                if (this.dgPrdctTest.SelectedItem != null)
                {
                    if (MessageBox.Show("确定要删除选中的试验数据吗?", "删除提示", MessageBoxButton.OKCancel, MessageBoxImage.Question)
                        == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                    PrdctTestBindEntity prdctTest = this.dgPrdctTest.SelectedItem as PrdctTestBindEntity;
                    if (dbPrdctTestDelete(prdctTest.Id.ToString()))
                    {
                        schedulingRefresh();    //刷新数据
                    }
                }
                else
                {
                    MessageBox.Show("没有选中要删除的项", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                break;

            case "修改":
                if (this.dgPrdctTest.SelectedItem != null)
                {
                    PrdctTestBindEntity prdctTestSel = this.dgPrdctTest.SelectedItem as PrdctTestBindEntity;
                    MdlProductTest      mptTemp      = new MdlProductTest();
                    mptTemp.EditFlag                 = 2;
                    mptTemp.Id                       = prdctTestSel.Id;
                    mptTemp.PrdctDataIns             = new MdlProductData();
                    mptTemp.PrdctDataIns.Id          = prdctTestSel.PrdctId;
                    mptTemp.PrdctDataIns.PrdctNumber = prdctTestSel.PrdctNumber;
                    mptTemp.PrdctDataIns.TreatType   = prdctTestSel.TreatType;
                    mptTemp.PrdctDataIns.WeDuration  = prdctTestSel.WeDuration;
                    mptTemp.PrdctDataIns.ReDuration  = prdctTestSel.ReDuration;
                    mptTemp.PrdctId                  = prdctTestSel.PrdctId;
                    mptTemp.StartTime                = prdctTestSel.StartTime;
                    mptTemp.WeLossTime               = prdctTestSel.WeLossTime;
                    mptTemp.ReLossTime               = prdctTestSel.ReLossTime;
                    mptTemp.Remark                   = prdctTestSel.Remark;
                    TestItemEdit tiEdit = new TestItemEdit(mptTemp);
                    tiEdit.Refurbish += new TestItemEdit.DisplayUpdate(edit_Refurbish);    //关联事件
                    bool?result = tiEdit.ShowDialog();
                    if (result != null && result.Value)
                    {
                        System.Windows.MessageBox.Show("修改成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBox.Show("没有选中要修改的项", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                break;
            }
        }