public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessDefectiveReasonVo inVo = (ProcessDefectiveReasonVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete From m_process_work_defective_reason"); sqlQuery.Append(" Where "); sqlQuery.Append(" defective_reason_id = :defrsnid "); sqlQuery.Append(" and factory_cd = :faccd "); if (inVo.ProcessWorkId > 0) { sqlQuery.Append(" and process_work_id = :prcwid"); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("defrsnid", inVo.DefectiveReasonId); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.ProcessWorkId > 0) { sqlParameter.AddParameterInteger("prcwid", inVo.ProcessWorkId); } ProcessDefectiveReasonVo outVo = new ProcessDefectiveReasonVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// updates process defective reason /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Update_btn_Click(object sender, EventArgs e) { int prcDefCount; int prcWrkId; int defRsnId; Cursor.Current = Cursors.WaitCursor; TreeNodeCollection nodes = ProcessDefectiveReasonDetails_tv.Nodes; ProcessDefectiveReasonVo prcDefCheckVo = new ProcessDefectiveReasonVo(); try { prcDefCheckVo = (ProcessDefectiveReasonVo)base.InvokeCbm(new GetProcessDefectiveReasonMasterMntCbm(), new ProcessDefectiveReasonVo(), false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); Logger.Error(exception.GetMessageData()); return; } foreach (TreeNode tn in nodes) { foreach (TreeNode child in tn.Nodes) { //Check process work defective reason is already added. prcWrkId = Convert.ToInt32(tn.Tag.ToString()); defRsnId = Convert.ToInt32(child.Tag.ToString()); prcDefCount = prcDefCheckVo.ProcessDefectiveReasonListVo.Where(t => t.ProcessWorkId == prcWrkId && t.DefectiveReasonId == defRsnId).Count(); if (child.Checked) { if (prcDefCount == 0) { AddProcessDefectReason(prcWrkId, defRsnId); } } else { if (prcDefCount == 1) { DeleteProcessDefect(prcWrkId, defRsnId); } } } } Cursor.Current = Cursors.Default; messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); Logger.Info(messageData); popUpMessage.Information(messageData, Text); }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DefectiveReasonVo deleteOutVo = (DefectiveReasonVo)deleteDefectiveReasonMasterMntCbm.Execute(trxContext, vo); if (deleteOutVo.AffectedCount > 0) { ProcessDefectiveReasonVo inVo = new ProcessDefectiveReasonVo(); inVo.DefectiveReasonId = ((DefectiveReasonVo)vo).DefectiveReasonId; ProcessDefectiveReasonVo deleteProcessDefectiveReasonOutVo = (ProcessDefectiveReasonVo)deleteProcessDefectiveReasonMasterMntCbm.Execute(trxContext, inVo); } return(deleteOutVo); }
/// <summary> /// binds grid /// </summary> /// <param name="defectiveReasonId"></param> private void BindGrid(int defectiveReasonId) { ProcessWorkVo outVo = null; try { outVo = (ProcessWorkVo)DefaultCbmInvoker.Invoke(new GetProcessWorkMasterMntCbm(), new ProcessWorkVo()); outVo.ProcessWorkListVo.ForEach(t => t.ProcessWorkName = string.Concat(t.ProcessWorkCode + " ", t.ProcessWorkName)); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } ProcessDefectiveReasonVo processDefectRsnOutVo = null; ProcessDefectiveReasonVo inVo = new ProcessDefectiveReasonVo(); inVo.DefectiveReasonId = defectiveReasonId; try { processDefectRsnOutVo = (ProcessDefectiveReasonVo)DefaultCbmInvoker.Invoke(new GetProcessDefectiveReasonMasterMntCbm(), inVo); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outVo != null && defectiveReasonId > 0) { foreach (ProcessWorkVo item in outVo.ProcessWorkListVo) { item.IsExists = processDefectRsnOutVo.ProcessDefectiveReasonListVo.Exists(t => t.ProcessWorkId == item.ProcessWorkId) ? "True" : "False"; } } BindingSource bindingSource = new BindingSource(outVo.ProcessWorkListVo, null); ProcessWork_dgv.AutoGenerateColumns = false; ProcessWork_dgv.DataSource = bindingSource; }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessDefectiveReasonVo inVo = (ProcessDefectiveReasonVo)arg; ProcessDefectiveReasonVo outVo = new ProcessDefectiveReasonVo(); StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_process_work_defective_reason"); sqlQuery.Append(" ( "); sqlQuery.Append(" defective_reason_id, "); sqlQuery.Append(" process_work_id, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :defrid ,"); sqlQuery.Append(" :processworkid ,"); sqlQuery.Append(" :registrationusercd ,"); sqlQuery.Append(" :registrationdatetime ,"); sqlQuery.Append(" :factrycode "); sqlQuery.Append(" ); "); foreach (ProcessDefectiveReasonVo curVo in inVo.ProcessDefectiveReasonListVo) { //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("processworkid", curVo.ProcessWorkId); sqlParameter.AddParameterInteger("defrid", inVo.DefectiveReasonId); sqlParameter.AddParameterString("registrationusercd", UserData.GetUserData().UserCode); sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime); sqlParameter.AddParameterString("factrycode", UserData.GetUserData().FactoryCode); outVo.AffectedCount += sqlCommandAdapter.ExecuteNonQuery(sqlParameter); } return(outVo); }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { List <ValueObject> inList = ((ValueObjectList <ValueObject>)vo).GetList(); DefectiveReasonVo defectiveReasonVoInVo = (DefectiveReasonVo)inList.FirstOrDefault(); ProcessDefectiveReasonVo processDefectiveReasonInVo = (ProcessDefectiveReasonVo)inList.Skip(1).FirstOrDefault(); DefectiveReasonVo defectiveReasonVoOutVo = (DefectiveReasonVo)addDefectiveReasonMasterMntCbm.Execute(trxContext, defectiveReasonVoInVo); if (defectiveReasonVoOutVo != null && defectiveReasonVoOutVo.DefectiveReasonId > 0) { processDefectiveReasonInVo.DefectiveReasonId = defectiveReasonVoOutVo.DefectiveReasonId; ProcessDefectiveReasonVo processDefectiveReasonoutVo = (ProcessDefectiveReasonVo)addProcessDefectiveReasonMasterMntNewCbm.Execute(trxContext, processDefectiveReasonInVo); } return(defectiveReasonVoOutVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessDefectiveReasonVo inVo = (ProcessDefectiveReasonVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_process_work_defective_reason"); sqlQuery.Append(" ( "); sqlQuery.Append(" defective_reason_id, "); sqlQuery.Append(" process_work_id, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :defrid ,"); sqlQuery.Append(" :prcwid ,"); sqlQuery.Append(" :regusrid ,"); sqlQuery.Append(" now() ,"); sqlQuery.Append(" :factorycode "); sqlQuery.Append(" ); "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("defrid", inVo.DefectiveReasonId); sqlParameter.AddParameterInteger("prcwid", inVo.ProcessWorkId); sqlParameter.AddParameterString("regusrid", inVo.RegistrationUserCode); //sqlParameter.AddParameterDateTime("regdt", inVo.RegistrationDateTime); sqlParameter.AddParameterString("factorycode", inVo.FactoryCode); ProcessDefectiveReasonVo outVo = new ProcessDefectiveReasonVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Deletes process defect /// </summary> /// <param name="prWId"></param> /// <param name="defRsnId"></param> private void DeleteProcessDefect(int prWId, int defRsnId) { ProcessDefectiveReasonVo delInVo = new ProcessDefectiveReasonVo { ProcessWorkId = prWId, DefectiveReasonId = defRsnId }; ProcessDefectiveReasonVo delOutVo = new ProcessDefectiveReasonVo(); try { delOutVo = (ProcessDefectiveReasonVo)base.InvokeCbm(new DeleteProcessDefectiveReasonMasterMntCbm(), delInVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); Logger.Error(exception.GetMessageData()); return; } }
/// <summary> /// Adds new proess defect /// </summary> /// <param name="processId"></param> /// <param name="defectRsnId"></param> private void AddProcessDefectReason(int processId, int defectRsnId) { ProcessDefectiveReasonVo prWDefInVo = new ProcessDefectiveReasonVo { ProcessWorkId = processId, DefectiveReasonId = defectRsnId, //RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), RegistrationUserCode = UserData.GetUserData().UserCode, FactoryCode = UserData.GetUserData().FactoryCode }; try { ProcessDefectiveReasonVo outVo = (ProcessDefectiveReasonVo)base.InvokeCbm(new AddProcessDefectiveReasonMasterMntCbm(), prWDefInVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); Logger.Error(exception.GetMessageData()); return; } }
private ProcessDefectiveReasonVo GetSelectedProcessWork() { BindingSource bsProcessWork = (BindingSource)ProcessWork_dgv.DataSource; ProcessDefectiveReasonVo processDefectiveRsnInVo = new ProcessDefectiveReasonVo(); if (bsProcessWork != null && bsProcessWork.List.Count > 0) { foreach (ProcessWorkVo processWorkVo in bsProcessWork.List) { if (processWorkVo.IsExists == "True") { ProcessDefectiveReasonVo addVo = new ProcessDefectiveReasonVo { ProcessWorkId = processWorkVo.ProcessWorkId }; processDefectiveRsnInVo.ProcessDefectiveReasonListVo.Add(addVo); } } } return(processDefectiveRsnInVo); }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { List <ValueObject> inList = ((ValueObjectList <ValueObject>)vo).GetList(); DefectiveReasonVo defectiveReasonVoInVo = (DefectiveReasonVo)inList.FirstOrDefault(); ProcessDefectiveReasonVo processDefectiveReasonVoInVo = (ProcessDefectiveReasonVo)inList.Skip(1).FirstOrDefault(); DefectiveReasonVo defectiveReasonVoOutVo = (DefectiveReasonVo)updateDefectiveReasonMasterMntCbm.Execute(trxContext, defectiveReasonVoInVo); if (defectiveReasonVoOutVo.AffectedCount > 0) { processDefectiveReasonVoInVo.DefectiveReasonId = defectiveReasonVoInVo.DefectiveReasonId; ProcessDefectiveReasonVo deleteInVo = new ProcessDefectiveReasonVo(); deleteInVo.DefectiveReasonId = defectiveReasonVoInVo.DefectiveReasonId; ProcessDefectiveReasonVo deleteOutVo = (ProcessDefectiveReasonVo)deleteProcessDefectiveReasonMasterMntCbm.Execute(trxContext, deleteInVo); ProcessDefectiveReasonVo ProcessDefectiveReasonoutVo = (ProcessDefectiveReasonVo)addProcessDefectiveReasonMasterMntNewCbm.Execute(trxContext, processDefectiveReasonVoInVo); } return(defectiveReasonVoOutVo); }
/// <summary> /// save excel data to DB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddExcel_btn_Click(object sender, EventArgs e) { if (DefectiveReason_dgv.RowCount > 0 && DefectiveReason_dgv.Columns["colRemarks"].Visible == true) { bool isRemarksNG = false; foreach (DataGridViewRow row in DefectiveReason_dgv.Rows) { if (DefectiveReason_dgv["colRemarks", row.Index].Value != null && !string.IsNullOrWhiteSpace(DefectiveReason_dgv["colRemarks", row.Index].Value.ToString())) { row.Cells["colRemarks"].Style.ForeColor = Color.Red; isRemarksNG = true; } } if (isRemarksNG) { messageData = new MessageData("mmci00015", Properties.Resources.mmci00015, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); return; } string previousReasonCode = string.Empty; int uploadedCount = 0; int insertedCount = 0; DefectiveReasonVo defectiveReasonInVo = new DefectiveReasonVo(); ProcessDefectiveReasonVo processDefectiveReasonInVo = new ProcessDefectiveReasonVo(); if (processWorkList.Count == 0) { GetProcessWork(); } this.StartProgress(Properties.Resources.mmci00009); foreach (DataRow row in excelUploadDt.Rows) { if (!string.IsNullOrEmpty(row["DefectiveReasonCode"].ToString()) && previousReasonCode != row["DefectiveReasonCode"].ToString()) { defectiveReasonInVo = new DefectiveReasonVo(); processDefectiveReasonInVo = new ProcessDefectiveReasonVo(); defectiveReasonInVo.DefectiveReasonCode = row["DefectiveReasonCode"].ToString(); defectiveReasonInVo.DefectiveReasonName = row["DefectiveReasonName"].ToString(); defectiveReasonInVo.DefectiveCategoryId = 0; defectiveReasonInVo.DisplayOrder = Convert.ToInt32(row["DisplayOrder"].ToString()); uploadedCount += 1; DataRow[] processWorkCodeList = excelUploadDt.Select("DefectiveReasonCode = '" + defectiveReasonInVo.DefectiveReasonCode + "'"); foreach (DataRow item in processWorkCodeList) { ProcessDefectiveReasonVo addVo = new ProcessDefectiveReasonVo(); ProcessWorkVo processWorkVo = processWorkList.Where(t => t.ProcessWorkCode == item["ProcessWorkCode"].ToString()).FirstOrDefault(); if (processWorkVo != null && processWorkVo.ProcessWorkId > 0) { addVo.ProcessWorkId = processWorkList.Where(t => t.ProcessWorkCode == item["ProcessWorkCode"].ToString()).FirstOrDefault().ProcessWorkId; processDefectiveReasonInVo.ProcessDefectiveReasonListVo.Add(addVo); } } ValueObjectList <ValueObject> inVoList = new ValueObjectList <ValueObject>(); inVoList.add(defectiveReasonInVo); inVoList.add(processDefectiveReasonInVo); DefectiveReasonVo outVo = null; try { outVo = (DefectiveReasonVo)base.InvokeCbm(new AddDefectiveReasonMasterMntNewCbm(), inVoList, false); } catch (Framework.ApplicationException exception) { this.CompleteProgress(); popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outVo != null && outVo.AffectedCount > 0) { insertedCount += outVo.AffectedCount; } } previousReasonCode = row["DefectiveReasonCode"].ToString(); } this.CompleteProgress(); if (insertedCount > 0 && uploadedCount > 0 && insertedCount == uploadedCount) { messageData = new MessageData("mmci00010", Properties.Resources.mmci00010, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } } else { messageData = new MessageData("mmci00016", Properties.Resources.mmci00016, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); } }
/// <summary> /// upload excel and insert to DB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ExcelUpload_btn_Click(object sender, EventArgs e) { OpenFileDialog openDialog_dlg = new OpenFileDialog(); openDialog_dlg.Filter = "Excel Files(*.xls) |*.xls"; if (openDialog_dlg.ShowDialog() == DialogResult.OK) { this.StartProgress(Properties.Resources.mmci00009); try { excelUploadDt = new ExcelUpload().ReadExcel(openDialog_dlg.FileName, Properties.Settings.Default.EXCEL_SHEET_DEFECTIVE_REASON); } catch (Framework.ApplicationException exception) { this.CompleteProgress(); popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } DefectiveReasonVo defectiveReasonInVo = new DefectiveReasonVo(); ProcessDefectiveReasonVo processDefectiveReasonInVo = new ProcessDefectiveReasonVo(); int displayOrder = 0; DefectiveReason_dgv.DataSource = null; excelUploadDt.Columns.Add("Remarks"); var sch = StringCheckHelper.GetInstance(); bool inputDataNG = false; foreach (DataRow row in excelUploadDt.Rows) { if (row["DefectiveReasonCode"] == null || string.IsNullOrWhiteSpace(row["DefectiveReasonCode"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmce00011, DefectiveReasonCode_lbl.Text); inputDataNG = true; continue; } if (!sch.IsASCII(row["DefectiveReasonCode"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmci00017, DefectiveReasonCode_lbl.Text); inputDataNG = true; continue; } var duplicates = excelUploadDt.AsEnumerable().GroupBy(r => r["DefectiveReasonCode"]).Where(gr => gr.Count() > 1).ToList(); if (duplicates.Any() && duplicates.Select(dupl => dupl.Key).ToList().FirstOrDefault().ToString() == row["DefectiveReasonCode"].ToString()) { row["Remarks"] = string.Format(Properties.Resources.mmce00009, DefectiveReasonCode_lbl.Text + " : " + row["DefectiveReasonCode"].ToString()); inputDataNG = true; continue; } if (row["DefectiveReasonName"] == null || string.IsNullOrWhiteSpace(row["DefectiveReasonName"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmce00011, DefectiveReasonName_lbl.Text); inputDataNG = true; continue; } if (row["DisplayOrder"] == null || string.IsNullOrWhiteSpace(row["DisplayOrder"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmce00011, colDisplayOrder.HeaderText); inputDataNG = true; continue; } if (!int.TryParse(row["DisplayOrder"].ToString(), out displayOrder) || displayOrder <= 0) { row["Remarks"] = string.Format(Properties.Resources.mmci00018, colDisplayOrder.HeaderText); inputDataNG = true; continue; } var duplicateDisplayOrder = excelUploadDt.AsEnumerable().GroupBy(r => r["DisplayOrder"]).Where(gr => gr.Count() > 1).ToList(); if (duplicateDisplayOrder.Any() && duplicateDisplayOrder.Select(dupl => dupl.Key).ToList().FirstOrDefault().ToString() == row["DisplayOrder"].ToString()) { row["Remarks"] = string.Format(Properties.Resources.mmce00009, colDisplayOrder.HeaderText + " : " + row["DisplayOrder"].ToString()); inputDataNG = true; continue; } defectiveReasonInVo = new DefectiveReasonVo(); processDefectiveReasonInVo = new ProcessDefectiveReasonVo(); defectiveReasonInVo.DefectiveReasonCode = row["DefectiveReasonCode"].ToString(); defectiveReasonInVo.DefectiveReasonName = row["DefectiveReasonName"].ToString(); defectiveReasonInVo.DefectiveCategoryId = 0; defectiveReasonInVo.DisplayOrder = Convert.ToInt32(row["DisplayOrder"].ToString()); if (!ValidateProcessWorkCodeInExcel(excelUploadDt, defectiveReasonInVo.DefectiveReasonCode)) { row["Remarks"] = string.Format(Properties.Resources.mmci00019); inputDataNG = true; continue; } DefectiveReasonVo checkVo = DuplicateCheck(defectiveReasonInVo); if (checkVo != null && checkVo.AffectedCount > 0) { row["Remarks"] = string.Format(Properties.Resources.mmce00012, DefectiveReasonCode_lbl.Text + " : " + defectiveReasonInVo.DefectiveReasonCode); inputDataNG = true; continue; } DefectiveReasonVo checkDisplayVo = DuplicateDisplayCheck(defectiveReasonInVo); if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0) { row["Remarks"] = string.Format(Properties.Resources.mmce00012, colDisplayOrder.HeaderText + " : " + defectiveReasonInVo.DisplayOrder.ToString()); inputDataNG = true; continue; } } DefectiveReason_dgv.AutoGenerateColumns = false; isExcelUpload = true; DefectiveReason_dgv.Columns["colRemarks"].Visible = true; DefectiveReason_dgv.DataSource = excelUploadDt; if (inputDataNG) { AddExcel_btn.Enabled = false; } else { AddExcel_btn.Enabled = true; } this.CompleteProgress(); } }
/// <summary> /// Binds tree view /// </summary> /// <param name="prcWrkList"></param> private void PopulateTreeView(List <ProcessWorkVo> prcWrkList) { DefectiveReasonVo defOutVo = new DefectiveReasonVo(); try { defOutVo = (DefectiveReasonVo)base.InvokeCbm(new GetDefectiveReasonMasterMntCbm(), defInVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); Logger.Error(exception.GetMessageData()); return; } ProcessDefectiveReasonDetails_tv.Nodes.Clear(); TreeNode[] headerNode = new TreeNode[prcWrkList.Count]; int i = 0; foreach (ProcessWorkVo prcW in prcWrkList) { TreeNode child = new TreeNode { Text = prcW.ProcessWorkCode + " " + prcW.ProcessWorkName, Tag = prcW.ProcessWorkId }; headerNode[i] = child; int childNodes = defOutVo.DefectiveReasonListVo.Count; TreeNode[] rootNodes = new TreeNode[childNodes]; int node = 0; ProcessDefectiveReasonVo prcDefRsnOutVo = new ProcessDefectiveReasonVo(); try { prcDefRsnOutVo = (ProcessDefectiveReasonVo)base.InvokeCbm(new GetProcessDefectiveReasonMasterMntCbm(), new ProcessDefectiveReasonVo(), false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); Logger.Error(exception.GetMessageData()); return; } foreach (DefectiveReasonVo dfrVo in defOutVo.DefectiveReasonListVo) { TreeNode rootChild = new TreeNode { Text = dfrVo.DefectiveReasonName, Tag = dfrVo.DefectiveReasonId }; List <ProcessDefectiveReasonVo> prcDefRsnList = prcDefRsnOutVo.ProcessDefectiveReasonListVo.Where(t => t.ProcessWorkId == Convert.ToInt32(child.Tag)).ToList(); foreach (ProcessDefectiveReasonVo prDfRsnVo in prcDefRsnList) { if (prDfRsnVo.DefectiveReasonId == Convert.ToInt32(rootChild.Tag)) { rootChild.Checked = true; } } rootNodes[node] = rootChild; headerNode[i].Nodes.Add(rootNodes[node]); node += 1; } ProcessDefectiveReasonDetails_tv.Nodes.Add(headerNode[i]); i += 1; } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessDefectiveReasonVo inVo = (ProcessDefectiveReasonVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select"); sqlQuery.Append(" pwdr.process_work_defective_reason_id,"); sqlQuery.Append(" pwdr.defective_reason_id,"); sqlQuery.Append(" pwdr.process_work_id,"); sqlQuery.Append(" df.defective_reason_name,"); sqlQuery.Append(" pw.process_work_name"); sqlQuery.Append(" from m_process_work_defective_reason pwdr"); sqlQuery.Append(" inner join m_process_work pw on pwdr.process_work_id = pw.process_work_id"); sqlQuery.Append(" inner join m_defective_reason df on pwdr.defective_reason_id = df.defective_reason_id"); sqlQuery.Append(" where pwdr.factory_cd = :faccd "); if (inVo.DefectiveReasonId > 0) { sqlQuery.Append(" and pwdr.defective_reason_id = :dfrid"); } if (inVo.ProcessWorkId > 0) { sqlQuery.Append(" and pwdr.process_work_id = :pwid"); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.DefectiveReasonId > 0) { sqlParameter.AddParameterInteger("dfrid", inVo.DefectiveReasonId); } if (inVo.ProcessWorkId > 0) { sqlParameter.AddParameterInteger("pwid", inVo.ProcessWorkId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); ProcessDefectiveReasonVo outVo = new ProcessDefectiveReasonVo(); while (dataReader.Read()) { ProcessDefectiveReasonVo currOutVo = new ProcessDefectiveReasonVo { ProcessWorkDefectiveReasonId = Convert.ToInt32(dataReader["process_work_defective_reason_id"]), DefectiveReasonId = Convert.ToInt32(dataReader["defective_reason_id"]), ProcessWorkId = Convert.ToInt32(dataReader["process_work_id"]), ProcessWorkName = dataReader["process_work_name"].ToString(), DefectiveReasonName = dataReader["defective_reason_name"].ToString() }; outVo.ProcessDefectiveReasonListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }