public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessStockLocationVo inVo = (ProcessStockLocationVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete from m_process_stocklocation"); sqlQuery.Append(" where factory_cd = :faccd "); sqlQuery.Append(" AND process_id = :processid"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); sqlParameter.AddParameterInteger("processid", inVo.ProcessId); UpdateResultVo outVo = new UpdateResultVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void Process_lst_SelectedIndexChanged(object sender, EventArgs e) { if (isProcessListLoading) { return; } if (Process_lst.SelectedIndex < 0) { return; } if (StockLocation_chlst.Items.Count == 0) { LoadStockLocationListBox(); } ProcessStockLocationVo inVo = new ProcessStockLocationVo(); inVo.ProcessId = Convert.ToInt32(Process_lst.SelectedValue.ToString()); // ValueObjectList<ProcessStockLocationVo> checkVo = (ProcessStockLocationVo)base.InvokeCbm(new GetProcessStockLocationMasterMntCbm(), new ProcessStockLocationVo(), false); StockLocation_chlst.ClearSelected(); ValueObjectList <ProcessStockLocationVo> outVo = null; try { outVo = (ValueObjectList <ProcessStockLocationVo>)base.InvokeCbm(new GetProcessStockLocationMasterMntCbm(), inVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } for (int i = 0; i < StockLocation_chlst.Items.Count; i++) { var stocklocation = (StockLocationVo)StockLocation_chlst.Items[i]; if (outVo == null || outVo.GetList() == null || outVo.GetList().Count == 0) { StockLocation_chlst.SetItemChecked(i, false); } else { StockLocation_chlst.SetItemChecked(i, outVo.GetList().Exists(x => x.StockLocationId == stocklocation.StockLocationId)); } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessStockLocationVo inVo = (ProcessStockLocationVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select "); sqlQuery.Append(" psl.process_id, psl.stock_location_id,sl.stock_location_name "); sqlQuery.Append(" from m_process_stocklocation psl "); sqlQuery.Append(" left join m_process p on p.process_id = psl.process_id "); sqlQuery.Append(" left join m_stock_location sl on sl.stock_location_id = psl.stock_location_id "); sqlQuery.Append(" where psl.factory_cd = :faccd "); if (inVo.ProcessId > 0) { sqlQuery.Append(" and psl.process_id = :processid "); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); sqlParameter.AddParameterInteger("processid", inVo.ProcessId); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); ValueObjectList <ProcessStockLocationVo> outVo = null; while (dataReader.Read()) { ProcessStockLocationVo currOutVo = new ProcessStockLocationVo(); currOutVo.ProcessId = ConvertDBNull <int>(dataReader, "process_id"); currOutVo.StockLocationId = ConvertDBNull <int>(dataReader, "stock_location_id"); currOutVo.StockLocationName = ConvertDBNull <string>(dataReader, "stock_location_name"); if (outVo == null) { outVo = new ValueObjectList <ProcessStockLocationVo>(); } outVo.add(currOutVo); } dataReader.Close(); return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ProcessStockLocationVo inVo = (ProcessStockLocationVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_process_stocklocation "); sqlQuery.Append(" ( "); sqlQuery.Append(" process_id, "); sqlQuery.Append(" stock_location_id, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :processid ,"); sqlQuery.Append(" :stocklocationid ,"); sqlQuery.Append(" :registrationusercode ,"); sqlQuery.Append(" :registrationdatetime ,"); sqlQuery.Append(" :factorycode "); sqlQuery.Append(" ); "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("processid", inVo.ProcessId); sqlParameter.AddParameterInteger("stocklocationid", inVo.StockLocationId); sqlParameter.AddParameterString("registrationusercode", UserData.GetUserData().UserCode); sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime); sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode); UpdateResultVo outVo = new UpdateResultVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// inserts/updates process on ok click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { if (CheckMandatory()) { ProcessStockLocationVo inVo = new ProcessStockLocationVo(); inVo.ProcessId = Convert.ToInt32(Process_lst.SelectedValue); ValueObjectList <ProcessStockLocationVo> outDeleteCheckVo = null; try { outDeleteCheckVo = (ValueObjectList <ProcessStockLocationVo>)base.InvokeCbm(new GetProcessStockLocationMasterMntCbm(), inVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outDeleteCheckVo != null && outDeleteCheckVo.GetList() != null && outDeleteCheckVo.GetList().Count > 0) { UpdateResultVo outDeleteVo = null; try { outDeleteVo = (UpdateResultVo)base.InvokeCbm(new DeleteProcessStockLocationMasterMntCbm(), inVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } IntDelSuccess = outDeleteVo.AffectedCount; } foreach (var item in StockLocation_chlst.CheckedItems) { var stocklocation = (StockLocationVo)item; inVo.StockLocationId = stocklocation.StockLocationId; UpdateResultVo outVo = null; try { outVo = (UpdateResultVo)base.InvokeCbm(new AddProcessStockLocationMasterMntCbm(), inVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } IntSuccess = outVo.AffectedCount; } if ((IntSuccess > 0) || (IntDelSuccess > 0)) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); } } }