/// <summary> /// 更新 /// </summary> /// <param name="model">料盤物件</param> /// <returns></returns> public ResponseModel UpdateData(DataTray model) { ResponseModel ResponseModel = new ResponseModel(); CheckDataExist(model.TrayNo.ToString(), ResponseModel); if (ResponseModel.TrayEnum.Equals(TrayEnum.Error1)) { int response = dataTrayRepository.UpdateData(model); if (response.Equals(0)) { ResponseModel.ResponseMsg = StatusEnum.Error4.GetEnumDescription(); } else { ResponseModel.Status = StatusEnum.Ok; ResponseModel.ResponseMsg = StatusEnum.Ok.GetEnumDescription(); } } else { ResponseModel.ResponseMsg = TrayEnum.Error2.GetEnumDescription(); } return(ResponseModel); }
/// <summary> /// 選取GridView的資料 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_CellClick_1(object sender, DataGridViewCellEventArgs e) { dataGridView2.ColumnCount = 2; dataGridView2.Columns[0].Name = "項目"; dataGridView2.Columns[1].Name = "參數"; dataGridView2.Rows.Clear(); if (e.RowIndex > -1) { int trayNo = Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value); dataTray = dataTrayList.Where(x => x.TrayNo == trayNo).FirstOrDefault(); noResult = dataTray.TrayNo.ToString(); nameResult = dataTray.TrayName; List <string[]> list = new List <string[]> { new string[] { "TrayNo", dataTray.TrayNo.ToString() }, new string[] { "TrayName", dataTray.TrayName }, new string[] { "DivideNoX", dataTray.DivideNoX.ToString() }, new string[] { "DivideNoY", dataTray.DivideNoY.ToString() }, new string[] { "DividePitchX", dataTray.DividePitchX }, new string[] { "DividePitchY", dataTray.DividePitchY }, new string[] { "PieceCenterX", dataTray.PieceCenterX }, new string[] { "PieceCenterY", dataTray.PieceCenterY }, new string[] { "TrayThickness", dataTray.TrayThickness }, new string[] { "TrayCenter", dataTray.TrayCenter }, new string[] { "TrayLength", dataTray.TrayLength }, new string[] { "TrayOffsetX", dataTray.TrayOffsetX }, new string[] { "TrayOffsetY", dataTray.TrayOffsetY } }; foreach (string[] rowArray in list) { dataGridView2.Rows.Add(rowArray); } dataGridView2.ClearSelection(); } }
/// <summary> /// 查詢是否有資料,有資料:Enum代碼:1(Error1)、無資料:Enum代碼:2(Error2) /// </summary> /// <param name="trayNo">料盤編號</param> /// <param name="responseModel">資料回傳物件</param> private void CheckDataExist(string trayNo, ResponseModel responseModel) { DataTray dataTray = dataTrayRepository.GetConditionData(trayNo); if (dataTray != null) { responseModel.TrayEnum = TrayEnum.Error1; } }
/// <summary> /// 取得料盤查詢條件資料 /// 傳入條件: 料盤編號 /// </summary> /// <param name="trayNo">料盤編號</param> /// <returns></returns> public ResponseModel GetConditionData(string trayNo) { DataTray dataTray = dataTrayRepository.GetConditionData(trayNo); return(new ResponseModel { Status = StatusEnum.Ok, DataTray = dataTray }); }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripbtnAdd_Click(object sender, EventArgs e) { try { AddRecChangeMethod("料盤新增"); // 先判斷筆數是否已達到最大限制,若要增加請更新config設定檔 ResponseModel ResponseModel = trayService.GetAllData(); int trayCounts = Convert.ToInt32(ConfigurationManager.AppSettings["Traylimit"]); if (ResponseModel.DataTrayList.Count > trayCounts) { MessageBox.Show(TrayEnum.Error3.GetEnumDescription()); return; } // 驗證 if (!CheckValueEmpty()) { return; } // 資料準備 DataTray dataTray = new DataTray { EditUser = GlobalParameter.UserName, TrayNo = trayNoMax + 1, TrayName = txtTrayName.Text, DivideNoX = Convert.ToInt32(txtDivideNoX.Text), DivideNoY = Convert.ToInt32(txtDivideNoY.Text), DividePitchX = txtDividePitchX.Text, DividePitchY = txtDividePitchY.Text, PieceCenterX = txtPieceCenterX.Text, PieceCenterY = txtPieceCenterY.Text, TrayOffsetX = txtTrayOffsetX.Text, TrayOffsetY = txtTrayOffsetY.Text, TrayCenter = txtTrayCenter.Text, TrayLength = txtTrayLength.Text, TrayThickness = txtThickness.Text }; // 呼叫料盤服務 ResponseModel = trayService.AddData(dataTray); if (ResponseModel.Status == StatusEnum.Ok) { GetDefaultTrayNo(); } MessageBox.Show(ResponseModel.ResponseMsg); } catch (Exception ex) { logger.Error(ex, "Exception錯誤"); MessageBox.Show(ex.Message); } }
/// <summary> /// 新增 /// </summary> /// <param name="model">料盤物件</param> /// <returns></returns> public ResponseModel AddData(DataTray model) { ResponseModel ResponseModel = new ResponseModel(); int response = dataTrayRepository.AddData(model); if (response.Equals(0)) { ResponseModel.ResponseMsg = StatusEnum.Error3.GetEnumDescription(); } else { ResponseModel.Status = StatusEnum.Ok; ResponseModel.ResponseMsg = StatusEnum.Ok.GetEnumDescription(); } return(ResponseModel); }
/// <summary> /// 料號料盤查詢 /// </summary> private void SeatchPratNoAndTray() { try { IPartNoJoinLaserService partNoJoinLaserService = new PartNoJoinLaserService(); ResponseModel ResponseModel = partNoJoinLaserService.GetLikeConditionMain(cbBoxPartNo.Text); cbBoxPartNo.DataSource = ResponseModel.PartNoJoinLaserList.Select(x => x.PartNo).ToList(); partNoJoinLaser = ResponseModel.PartNoJoinLaserList.Where(x => x.PartNo == cbBoxPartNo.Text).ToList(); if (partNoJoinLaser.Count > 0) { IDataTrayService dataTrayService = new DataTrayService(); ResponseModel responseModel = dataTrayService.GetConditionData(partNoJoinLaser[0].TrayNo.ToString()); dataTray = responseModel.DataTray; } if (partNoJoinLaser.Count > 0 && dataTray != null) { lblFNO.Text = partNoJoinLaser[0].FnoNo; lblXoffset.Text = partNoJoinLaser[0].Xoffset; lblYoffset.Text = partNoJoinLaser[0].Yoffset; lblPower.Text = partNoJoinLaser[0].Power; lblSpeed.Text = partNoJoinLaser[0].Speed; toolStripbtnSet.Enabled = true; } else { lblFNO.Text = lblPower.Text = txtPower.Text = string.Empty; lblSpeed.Text = txtSpeed.Text = string.Empty; lblXoffset.Text = lblYoffset.Text = "0.000"; txtXOffset.Text = txtYOffset.Text = "0.000"; toolStripbtnSet.Enabled = false; // 清除combobox資料 cbBoxPartNo.DataSource = null; cbBoxPartNo.Text = string.Empty; MessageBox.Show("查無此料號。"); } toolStripbtnPoint.Enabled = false; } catch (Exception ex) { logger.Error(ex, "Error"); MessageBox.Show(ex.Message); } }
/// <summary> /// 更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripbtnUpdate_Click(object sender, EventArgs e) { try { AddRecChangeMethod("料盤更新"); // 驗證 if (!CheckValueEmpty()) { return; } // 資料準備 DataTray dataTray = new DataTray { EditUser = GlobalParameter.UserName, TrayNo = Convert.ToInt32(lblTrayNo.Text), TrayName = txtTrayName.Text, DivideNoX = Convert.ToInt32(txtDivideNoX.Text), DivideNoY = Convert.ToInt32(txtDivideNoY.Text), DividePitchX = txtDividePitchX.Text, DividePitchY = txtDividePitchY.Text, PieceCenterX = txtPieceCenterX.Text, PieceCenterY = txtPieceCenterY.Text, TrayOffsetX = txtTrayOffsetX.Text, TrayOffsetY = txtTrayOffsetY.Text, TrayCenter = txtTrayCenter.Text, TrayLength = txtTrayLength.Text, TrayThickness = txtThickness.Text }; ResponseModel ResponseModel = trayService.UpdateData(dataTray); if (ResponseModel.Status == StatusEnum.Ok) { GetDefaultTrayNo(); } MessageBox.Show(ResponseModel.ResponseMsg); } catch (Exception ex) { logger.Error(ex, "Exception錯誤"); MessageBox.Show(ex.Message); } }