public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { AccountCodeVo inVo = (AccountCodeVo)vo; StringBuilder sql = new StringBuilder(); sql.Append("insert into m_account_code(account_code_cd, account_code_name, registration_user_cd, registration_date_time, factory_cd) "); sql.Append("values(:account_code_cd,:account_code_name, :registration_user_cd,now(),:factory_cd)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("account_code_cd", inVo.AccountCodeCode); sqlParameter.AddParameterString("account_code_name", inVo.AccountCodeName); sqlParameter.AddParameterDateTime("registration_user_cd", inVo.RegistrationDateTime); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode); //execute SQL AccountCodeVo outVo = new AccountCodeVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void BindUpdateCavityData() { int selectedrowindex = AccountDetails_dgv.SelectedCells[0].RowIndex; AccountCodeVo vo = (AccountCodeVo)AccountDetails_dgv.Rows[selectedrowindex].DataBoundItem; Form.Account_WhForm.AccountCodeForm.AddAccountCodeForm addform = new Form.Account_WhForm.AccountCodeForm.AddAccountCodeForm(); addform.vo = vo; addform.ShowDialog(); if (addform.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(); } else if (addform.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(); } }
private void GridBind() { AccountDetails_dgv.DataSource = null; try { AccountCodeVo vo = new AccountCodeVo { AccountCodeCode = AccountCode_txt.Text, AccountCodeName = AccountName_txt.Text }; ValueObjectList <AccountCodeVo> volist = (ValueObjectList <AccountCodeVo>)DefaultCbmInvoker.Invoke(new GetAccountCodeCbm(), vo); if (volist.GetList() != null && volist.GetList().Count > 0) { AccountDetails_dgv.AutoGenerateColumns = false; BindingSource bindingsource = new BindingSource(volist.GetList(), null); AccountDetails_dgv.DataSource = bindingsource; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); } AccountDetails_dgv.ClearSelection(); Update_btn.Enabled = false; Delete_btn.Enabled = false; } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { AccountCodeVo inVo = (AccountCodeVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <AccountCodeVo> voList = new ValueObjectList <AccountCodeVo>(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("select account_code_id, account_code_cd, account_code_name, registration_user_cd,registration_date_time,factory_cd from m_account_code"); sql.Append(" Where 1=1 "); if (!String.IsNullOrEmpty(inVo.FactoryCode)) { sql.Append(" and factory_cd = :factory_cd "); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); } if (inVo.AccountCodeId > 0) { sql.Append(" and account_code_id = :account_code_id "); sqlParameter.AddParameterInteger("account_code_id", inVo.AccountCodeId); } if (!string.IsNullOrEmpty(inVo.AccountCodeCode)) { sql.Append(" and account_code_cd = :account_code_cd "); sqlParameter.AddParameterString("account_code_cd", inVo.AccountCodeCode); } if (!string.IsNullOrEmpty(inVo.AccountCodeName)) { sql.Append(" and account_code_name = :account_code_name "); sqlParameter.AddParameterString("account_code_name", inVo.AccountCodeName); } //create command //DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { AccountCodeVo outVo = new AccountCodeVo { AccountCodeId = int.Parse(dataReader["account_code_id"].ToString()), AccountCodeCode = dataReader["account_code_cd"].ToString(), AccountCodeName = dataReader["account_code_name"].ToString(), RegistrationUserCode = dataReader["registration_user_cd"].ToString(), RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()), FactoryCode = dataReader["factory_cd"].ToString() }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { try { //VARIABLE AccountCodeVo inVo = (AccountCodeVo)vo; StringBuilder query = new StringBuilder(); ValueObjectList <AccountCodeVo> listVo = new ValueObjectList <AccountCodeVo>(); //CREATE SQL ADAPTER AND PARAMETER LIST DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, query.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); //QUERY STRING query.Append("Select * from m_account_code where 1=1 "); if (inVo.account_code_id > 0 || inVo != null) { query.Append("and account_code_id='").Append(inVo.account_code_id).Append("' "); } if (string.IsNullOrEmpty(inVo.account_code_cd)) { query.Append("and account_code_cd='").Append(inVo.account_code_cd).Append("' "); } query.Append("order by account_code_id"); //GET SQL ADAPTER sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, query.ToString()); //EXECUTE READER FROM COMMAND IDataReader datareader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (datareader.Read()) { AccountCodeVo outVo = new AccountCodeVo { account_code_id = (int)datareader["account_code_id"], account_code_cd = datareader["account_code_cd"].ToString(), account_code_name = datareader["account_code_name"].ToString(), registration_user_cd = datareader["registration_user_cd"].ToString(), registration_date_time = (DateTime)datareader["registration_date_time"], factory_cd = datareader["factory_cd"].ToString() }; listVo.add(outVo); } //CLEAR AND CLOSE CONNECTION query.Clear(); datareader.Close(); base.CloseConnection(trxContext); return(listVo); } catch { throw new NotImplementedException(); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { AccountCodeVo inVo = (AccountCodeVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("delete from m_account_code Where 1=1 "); if (!String.IsNullOrEmpty(inVo.FactoryCode)) { sql.Append(" and factory_cd = :factory_cd "); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); } if (inVo.AccountCodeId > 0) { sql.Append(" and account_code_id = :account_code_id "); sqlParameter.AddParameterInteger("account_code_id", inVo.AccountCodeId); } if (!string.IsNullOrEmpty(inVo.AccountCodeCode)) { sql.Append(" and account_code_cd = :account_code_cd "); sqlParameter.AddParameterString("account_code_cd", inVo.AccountCodeCode); } if (!string.IsNullOrEmpty(inVo.AccountCodeName)) { sql.Append(" and account_code_name = :account_code_name "); sqlParameter.AddParameterString("account_code_name", inVo.AccountCodeName); } //create command sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL AccountCodeVo outVo = new AccountCodeVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void Delete_btn_Click(object sender, EventArgs e) { if (AccountDetails_dgv.SelectedRows.Count > 0) { int selectedrowindex = AccountDetails_dgv.SelectedCells[0].RowIndex; AccountCodeVo vo = (AccountCodeVo)AccountDetails_dgv.Rows[selectedrowindex].DataBoundItem; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, vo.AccountCodeCode); logger.Info(messageData); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { try { AccountCodeVo outVo = (AccountCodeVo)DefaultCbmInvoker.Invoke(new DeleteAccountCodeCbm(), vo); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(); } else if (outVo.AffectedCount == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(); } } catch (Com.Nidec.Mes.Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } } }
private bool checkdate() { if (AccountCode_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AccountCode_lbl.Text); popUpMessage.Warning(messageData, Text); AccountCode_txt.Focus(); return(false); } if (AccountName_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AccountName_lbl.Text); popUpMessage.Warning(messageData, Text); AccountName_txt.Focus(); return(false); } AccountCode_txt.Text = AccountCode_txt.Text.Trim(); AccountName_txt.Text = AccountName_txt.Text.Trim(); AccountCodeVo outVo = new AccountCodeVo(), inVo = new AccountCodeVo { AccountCodeId = vo.AccountCodeId, AccountCodeCode = AccountCode_txt.Text }; try { outVo = (AccountCodeVo)DefaultCbmInvoker.Invoke(new CheckAccountCodeCbm(), inVo); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmcc00006", Properties.Resources.mmcc00006, AccountCode_lbl.Text); popUpMessage.Warning(messageData, Text); AccountCode_txt.Focus(); return(false); } } catch (Com.Nidec.Mes.Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return(false); } return(true); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { AccountCodeVo inVo = (AccountCodeVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("Select Count(*) as AccountCount "); sql.Append(" from m_account_code"); sql.Append(" Where 1=1 "); if (!String.IsNullOrEmpty(inVo.FactoryCode)) { sql.Append(" and factory_cd = :factory_cd "); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); } if (!string.IsNullOrEmpty(inVo.AccountCodeCode)) { sql.Append(" and UPPER(account_code_cd) = UPPER(:account_code_cd) "); sqlParameter.AddParameterString("account_code_cd", inVo.AccountCodeCode); } if (inVo.AccountCodeId > 0) { sql.Append(" and account_code_id != :account_code_id "); ///????? sqlParameter.AddParameterInteger("account_code_id", inVo.AccountCodeId); } sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); AccountCodeVo outVo = new AccountCodeVo(); while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["AccountCount"].ToString()); } dataReader.Close(); return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { AccountCodeVo inVo = (AccountCodeVo)vo; ValueObjectList <AccountCodeVo> voList = new ValueObjectList <AccountCodeVo>(); StringBuilder sql = new StringBuilder(); //CREATE SQL ADAPTER AND PARAMETER LIST DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("select account_code_id, account_code_cd, account_code_name from m_account_code where 1=1 "); if (!string.IsNullOrEmpty(inVo.account_code_cd)) { sql.Append("and account_code_cd='").Append(inVo.account_code_cd).Append("' "); } if (!string.IsNullOrEmpty(inVo.account_code_name)) { sql.Append("and account_code_name='").Append(inVo.account_code_name).Append("' "); } sql.Append("order by account_code_id"); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); sql.Clear(); //EXECUTE READER FROM COMMAND IDataReader datareader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (datareader.Read()) { AccountCodeVo outVo = new AccountCodeVo { account_code_id = (int)datareader["account_code_id"], account_code_cd = datareader["account_code_cd"].ToString(), account_code_name = datareader["account_code_name"].ToString() }; voList.add(outVo); } datareader.Close(); base.CloseConnection(trxContext); return(voList); }
private void Ok_btn_Click(object sender, EventArgs e) { if (checkdate()) { AccountCodeVo outvo = new AccountCodeVo(); AccountCodeVo invo = new AccountCodeVo { AccountCodeId = vo.AccountCodeId, AccountCodeCode = AccountCode_txt.Text, AccountCodeName = AccountName_txt.Text, FactoryCode = UserData.GetUserData().FactoryCode, RegistrationUserCode = UserData.GetUserData().UserCode }; try { if (invo.AccountCodeId > 0) { outvo = (AccountCodeVo)DefaultCbmInvoker.Invoke(new UpdateAccountCodeCbm(), invo); } else { outvo = (AccountCodeVo)DefaultCbmInvoker.Invoke(new AddAccountCodeCbm(), invo); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.DialogResult = DialogResult.OK; this.Close(); } } }