Пример #1
0
        public static bool SaveItemOfProduct(QualitySnItem item, bool autoQualityStatus)
        {
            try
            {
                QualityDal dal = new QualityDal();
                if (autoQualityStatus)
                {
                    switch (item.UnitType)
                    {
                    case "N":
                        double result = Convert.ToDouble(item.CurrentValue);
                        item.CurrentResult = (result > item.MinValue && result < item.MaxValue) ? 1 : 0;
                        break;

                    case "B":
                        item.CurrentResult = item.CurrentValue.ToUpper().Equals("TRUE") ? 1 : 0;
                        break;

                    default:
                        item.CurrentResult = 1;
                        break;
                    }
                }
                //List<QualitySnItem> testItem = dal.FindBySql<QualitySnItem>("where ItemCode=@0 and ProcessCode=@1 and BatchNo=@2 ", item.ItemCode, item.ProcessCode, item.BatchNo);
                //if(testItem.Count>0)
                //{
                //    item.RMES_ID = testItem[0].RMES_ID;
                //    dal.Update(item);
                //}
                //else
                dal.Insert(item);
            }
            catch (Exception ex)
            {
                Rmes.Public.ErrorHandle.EH.LASTMSG = ex.Message;
                return(false);
            }
            return(true);
        }
Пример #2
0
        private void ShowQualityList()
        {
            //根据当前站点LoginInfo.StationInfo.RMES_ID找到rel_station_location对应工位code_location
            List <LocationEntity>    Location     = new List <LocationEntity>();
            List <WorkProcessEntity> process_plan = new List <WorkProcessEntity>(); //站点对应的所有工序集合
            List <DetectItemEntity>  detect_item  = new List <DetectItemEntity>();  //工序对应的检验条目集合

            Location = LocationFactory.GetByStationCode(LoginInfo.StationInfo.RMES_ID);
            if (Location == null)
            {
                return;
            }
            else
            {
                if (_product == null)
                {
                    return;
                }

                //根据站点对应的工位从bom表中取出每个工位对应的工序以及质量检验标准
                for (int i = 0; i < Location.Count; i++)
                {
                    //每个工位对应的工序集合
                    List <WorkProcessEntity> Q = PlanStandardBOMFactory.GetByLocationCode(LoginInfo.StationInfo.COMPANY_CODE, _product.PLAN_CODE, LoginInfo.StationInfo.PLINE_CODE, Location[i].LOCATION_CODE);
                    process_plan.AddRange(Q);
                }
            }

            //根据工序process_plan从bom导出的data_detect_item中获取检测项目
            if (process_plan == null)
            {
                return;
            }
            else
            {
                //存每个工序对应的质检项目data_detect_item
                for (int i = 0; i < process_plan.Count; i++)
                {
                    List <DetectItemEntity> Q = DetectItemFactory.GetByPlanProcessCode(LoginInfo.StationInfo.COMPANY_CODE, _product.PLAN_CODE, process_plan[i].PROCESS_CODE);
                    detect_item.AddRange(Q);
                }
            }
            //每个工序的检测项目detect_item
            GridQuality.DataSource = detect_item;
            //关联data_sn_quality  取工序最新状态
            for (int i = 0; i < detect_item.Count; i++)
            {
                QualitySnItem S = QualityFactory.GetProductInfoByBatchProcessPlan(_product.SN, detect_item[i].LTXA1, _product.PLAN_CODE);
                if (S == null)
                {
                }
                else
                {
                    if (S.CurrentResult != "")
                    {
                        GridQuality.Rows[i].Cells["coldx"].Value = S.CurrentResult;
                    }
                    if (S.CurrentValue != "")
                    {
                        GridQuality.Rows[i].Cells["colCurrentValue"].Value = S.CurrentValue;
                    }
                    GridQuality.Rows[i].DefaultCellStyle.BackColor = Color.Green;
                }
                //if (!string.IsNullOrWhiteSpace(detect_item[i].QUALITAT as string))
                //{
                //    GridQuality.Rows[i].Cells["coldx"].Value = detect_item[i].QUALITAT;
                //}
            }
            for (int j = 0; j < GridQuality.Rows.Count; j++)
            {
                GridQuality.Rows[j].Height = 30;
                //根据值改变grid每行属性
                //if (!string.IsNullOrWhiteSpace(GridQuality.Rows[j].Cells["colRmesId"].Value as string))
                //{
                //    GridQuality.Rows[j].ReadOnly = true;
                //    GridQuality.Rows[j].DefaultCellStyle.BackColor = Color.LightGray;
                //}
            }
        }
Пример #3
0
        private void GridQuality_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            if (GridQuality.Rows[e.RowIndex].ReadOnly == true)
            {
                return;
            }
            //string fileName = "";
            string rmesid = "";

            if (e.ColumnIndex == 5)
            {
                if (GridQuality.Rows[e.RowIndex].Cells["colUnitType"].Value.ToString() == "F")
                {
                    OpenFileDialog MyFileDialog = new OpenFileDialog();                                                   //创建打开对话框对象
                    MyFileDialog.ShowDialog();                                                                            //显示打开对话框
                    if (MyFileDialog.FileName.Trim() != "")                                                               //判断是否选择了文件
                    {
                        FileStream   FStream     = new FileStream(MyFileDialog.FileName, FileMode.Open, FileAccess.Read); //创建FileStream对象
                        string       fileName    = MyFileDialog.FileName;
                        string       fileNamesub = MyFileDialog.SafeFileName;
                        BinaryReader BReader     = new BinaryReader(FStream);              //创建BinaryReader读取对象
                        byte[]       bytes       = BReader.ReadBytes((int)FStream.Length); //读取二进制
                        GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value = fileNamesub;
                        //quality.CurrentValue = fileName;
                        FileBlobEntity BE = new FileBlobEntity()
                        {
                            FILE_BLOB  = bytes,
                            FILE_NAME  = fileNamesub,
                            USER_ID    = LoginInfo.UserInfo.USER_CODE,
                            CREAT_TIME = DateTime.Now
                        };
                        PetaPoco.Database db = DB.GetInstance();
                        rmesid = db.Insert("QMS_FILE_BLOB", "RMES_ID", BE).ToString();

                        //FileStream fs = new FileStream(@fileName, FileMode.CreateNew, FileAccess.Write, FileShare.Read);
                        //StreamWriter sw = new StreamWriter(fs);
                        //sw.Write(bytes);
                        FStream.Close();//关闭数据流
                    }
                }
                //else
                //{
                //    if (!string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value.ToString()))
                //       = GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value.ToString();
                //}
            }
            if (e.ColumnIndex == 0)
            {
                QualitySnItem quality = new QualitySnItem();
                if (GridQuality.Rows[e.RowIndex].Cells["colUnitType"].Value.ToString() == "F")
                {
                    quality.URL = rmesid;
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value as string))
                    {
                        return;
                    }
                    quality.URL = "";
                }
                if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value as string))
                {
                    return;
                }
                quality.CurrentValue = GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value.ToString();

                if (GridQuality.Rows[e.RowIndex].Cells["colCurrentResult"].Value == null)
                {
                }
                quality.CurrentResult = Convert.ToInt32((GridQuality.Rows[e.RowIndex].Cells["colCurrentResult"] as DataGridViewComboBoxCell).Value);

                quality.ProcessCode = GridQuality.Rows[e.RowIndex].Cells["colProcessCode"].Value.ToString();
                //quality.BatchNo = GridQuality.Rows[e.RowIndex].Cells["colBatchNo"].Value.ToString();
                quality.BatchNo = SN;
                //quality.RMES_ID = GridQuality.Rows[e.RowIndex].Cells["colRmesId"].Value.ToString();
                quality.ItemCode        = GridQuality.Rows[e.RowIndex].Cells["colItemCode"].Value.ToString();
                quality.ItemName        = GridQuality.Rows[e.RowIndex].Cells["colItemName"].Value.ToString();
                quality.ItemDescription = GridQuality.Rows[e.RowIndex].Cells["colItemDescription"].Value.ToString();
                quality.MaxValue        = Convert.ToInt32(GridQuality.Rows[e.RowIndex].Cells["colMaxValue"].Value);
                quality.MinValue        = Convert.ToInt32(GridQuality.Rows[e.RowIndex].Cells["colMinValue"].Value);
                if (quality.Ordering == null)
                {
                    quality.Ordering = "";
                }
                else
                {
                    quality.Ordering = GridQuality.Rows[e.RowIndex].Cells["colOrdering"].Value.ToString();
                }
                if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colUnitName"].Value as string))
                {
                    quality.UnitName = "";
                }
                else
                {
                    quality.UnitName = GridQuality.Rows[e.RowIndex].Cells["colUnitName"].Value.ToString();
                }
                quality.UnitType = GridQuality.Rows[e.RowIndex].Cells["colUnitType"].Value.ToString();


                //QualityType type = QualityFactory.GetByTypeName(GridQuality.Rows[e.RowIndex].Cells["colType"].Value.ToString());
                if (GridQuality.Rows[e.RowIndex].Cells["colType"].Value == null)
                {
                }
                else
                {
                    quality.FAULT_TYPE = (GridQuality.Rows[e.RowIndex].Cells["colType"] as DataGridViewComboBoxCell).Value.ToString();
                }

                if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colEquipment"].Value as string))
                {
                    return;
                }
                quality.TEST_EQUIPMENT = GridQuality.Rows[e.RowIndex].Cells["colEquipment"].Value.ToString();
                if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["Remark"].Value as string))
                {
                    quality.TEMP = "";
                }
                else
                {
                    quality.TEMP = GridQuality.Rows[e.RowIndex].Cells["Remark"].Value.ToString();
                }
                quality.WORK_TIME = System.DateTime.Now;
                quality.USER_ID   = LoginInfo.UserInfo.USER_ID;

                if (quality.UnitType == "N" && quality.UnitType == "B")
                {
                    QualityFactory.SaveItemOfProduct(quality, true);
                }
                else
                {
                    QualityFactory.SaveItemOfProduct(quality, false);
                }
                GridQuality.DataSource = new List <QualitySnItem>();
                ShowQualityList();
            }
        }
Пример #4
0
        private void GridQuality_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            if (GridQuality.Rows[e.RowIndex].ReadOnly == true)
            {
                return;
            }
            //string fileName = "";
            if (e.ColumnIndex == 5)
            {
                //colUnitType检测类型
                //if (GridQuality.Rows[e.RowIndex].Cells["colUnitType"].Value.ToString() == "F")
                //{
                //    OpenFileDialog MyFileDialog = new OpenFileDialog();//创建打开对话框对象
                //    MyFileDialog.ShowDialog();//显示打开对话框
                //    if (MyFileDialog.FileName.Trim() != "")//判断是否选择了文件
                //    {
                //        FileStream FStream = new FileStream(MyFileDialog.FileName, FileMode.Open, FileAccess.Read);//创建FileStream对象
                //        string fileName = MyFileDialog.FileName;
                //       // BinaryReader BReader = new BinaryReader(FStream);//创建BinaryReader读取对象
                //        //byte[] bytes = BReader.ReadBytes((int)FStream.Length);//读取二进制图片
                //        GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value = fileName;
                //        //quality.CurrentValue = fileName;
                //        FStream.Close();//关闭数据流
                //    }
                //}
                //else
                //{
                //    if (!string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value.ToString()))
                //       = GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value.ToString();
                //}
            }
            if (e.ColumnIndex == 0) //工序完成录入
            {
                //是否区分该工序是定性还是定量 如果不区分 则全部录入
                QualitySnItem quality = new QualitySnItem();

                if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value as string) && string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["coldx"].Value as string))
                {
                    MessageBox.Show("至少输入一种检测结果:定性或定量");
                    return;
                }

                quality.BatchNo     = _product.SN;                                                                                                                                                                             //批次号 SN
                quality.ProcessCode = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colProcessCode"].Value as string) ?"":GridQuality.Rows[e.RowIndex].Cells["colProcessCode"].Value.ToString();               //工序号
                quality.ItemCode    = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["coljytxdm"].Value as string)?"":GridQuality.Rows[e.RowIndex].Cells["coljytxdm"].Value.ToString();                          //检测项代码

                quality.ItemName        = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colItemDescription"].Value as string) ? "": GridQuality.Rows[e.RowIndex].Cells["colItemDescription"].Value.ToString(); //检测项名称
                quality.ItemDescription = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colcheckrequire"].Value as string) ?"":GridQuality.Rows[e.RowIndex].Cells["colcheckrequire"].Value.ToString();         //检测要求
                if (GridQuality.Rows[e.RowIndex].Cells["colMaxValue"].Value == null)
                {
                    quality.MaxValue = -1;
                }
                else
                {
                    quality.MaxValue = Convert.ToDouble(GridQuality.Rows[e.RowIndex].Cells["colMaxValue"].Value);//最大值
                }
                if (GridQuality.Rows[e.RowIndex].Cells["colMinValue"].Value == null)
                {
                    quality.MinValue = -1;
                }
                else
                {
                    quality.MinValue = Convert.ToDouble(GridQuality.Rows[e.RowIndex].Cells["colMinValue"].Value);//最小值
                }
                //判断定量输入值是否在范围内
                if (!string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value as string))
                {
                    double inputvalue = Convert.ToDouble(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value);
                    if (inputvalue > quality.MaxValue || inputvalue < quality.MinValue)
                    {
                        MessageBox.Show("定量输入值不在预定范围内,请修改");
                        return;
                    }
                }
                quality.StandardValue = 0;//标准值

                //if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value as string)) { }
                quality.CurrentValue = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value as string) ?"":GridQuality.Rows[e.RowIndex].Cells["colCurrentValue"].Value.ToString();//定量值

                //if (GridQuality.Rows[e.RowIndex].Cells["coldx"].Value == null) { }
                quality.CurrentResult = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["coldx"].Value as string) ? "" : GridQuality.Rows[e.RowIndex].Cells["coldx"].Value.ToString(); //定性值

                quality.UnitName   = "";                                                                                                                                                            //检测项单位
                quality.UnitType   = "";                                                                                                                                                            //检测项类型
                quality.Ordering   = "";                                                                                                                                                            //排序字符串
                quality.TIMESTAMP1 = "";                                                                                                                                                            //时间戳
                quality.WORK_TIME  = System.DateTime.Now;                                                                                                                                           //完工时间
                quality.USER_ID    = LoginInfo.UserInfo.USER_ID;                                                                                                                                    //操作员
                //if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colEquipment"].Value as string)) return;
                //quality.TEST_EQUIPMENT = GridQuality.Rows[e.RowIndex].Cells["colEquipment"].Value.ToString();//检测设备
                quality.TEST_EQUIPMENT = "";//检测设备
                quality.FAULT_TYPE     = "";
                //QualityType type = QualityFactory.GetByTypeName(GridQuality.Rows[e.RowIndex].Cells["colType"].Value.ToString());
                //if (GridQuality.Rows[e.RowIndex].Cells["colType"].Value == null) { }
                //else
                //    quality.FAULT_TYPE = (GridQuality.Rows[e.RowIndex].Cells["colType"] as DataGridViewComboBoxCell).Value.ToString();//质量原因

                if (string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["Remark"].Value as string))
                {
                    quality.TEMP = "";//
                }
                else
                {
                    quality.TEMP = GridQuality.Rows[e.RowIndex].Cells["Remark"].Value.ToString();                                                                                                                   //备注
                }
                quality.plan_code    = _product.PLAN_CODE;                                                                                                                                                          //计划号
                quality.item_code    = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["colmaterialname"].Value as string)?"": GridQuality.Rows[e.RowIndex].Cells["colmaterialname"].Value.ToString(); //检验物料编码
                quality.detect_seqno = string.IsNullOrWhiteSpace(GridQuality.Rows[e.RowIndex].Cells["coljytxxh"].Value as string)?"": GridQuality.Rows[e.RowIndex].Cells["coljytxxh"].Value.ToString();             //检验特性序号


                //if (quality.UnitType == "N" && quality.UnitType == "B")
                //    QualityFactory.SaveItemOfProduct(quality, true);
                //else QualityFactory.SaveItemOfProduct(quality, false);
                if (QualityFactory.SaveProductItem(quality))//插入成功显示绿色 不成功为红色
                {
                    GridQuality.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green;
                }
                else
                {
                    GridQuality.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
                }
                GridQuality.DataSource = new List <QualitySnItem>();
                ShowQualityList();
            }
        }