/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(CountryLanguageVo conditionInVo) { CntryLang_dgv.DataSource = null; try { CountryLanguageVo outVo = (CountryLanguageVo)base.InvokeCbm(new GetCountryLanguageMasterMntCbm(), conditionInVo, false); CntryLang_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.CountryLangListVo, null); if (bindingSource1 != null && bindingSource1.Count > 0) { CntryLang_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); // "country language" logger.Info(messageData); popUpMessage.Information(messageData, Text); } CntryLang_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 arg) { CountryLanguageVo inVo = (CountryLanguageVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete from m_country_language"); sqlQuery.Append(" Where "); sqlQuery.Append(" country = :country "); sqlQuery.Append(" and "); sqlQuery.Append(" language = :language ;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("country", inVo.Country); sqlParameter.AddParameterString("language ", inVo.Language); CountryLanguageVo outVo = new CountryLanguageVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// selects user record for updation and show user form /// </summary> private void BindUpdateUserData() { int selectedrowindex = CntryLang_dgv.SelectedCells[0].RowIndex; CountryLanguageVo cntVo = (CountryLanguageVo)CntryLang_dgv.Rows[selectedrowindex].DataBoundItem; AddCountryLanguageForm newAddForm = new AddCountryLanguageForm(CommonConstants.MODE_UPDATE, cntVo); newAddForm.ShowDialog(this); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (newAddForm.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } }
/// <summary> /// event to delete the selected record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Delete_btn_Click(object sender, EventArgs e) { int selectedrowindex = CntryLang_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = CntryLang_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colCountry"].Value.ToString()); logger.Info(messageData); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { CountryLanguageVo inVo = new CountryLanguageVo { Country = selectedRow.Cells["colCountry"].Value.ToString(), Language = selectedRow.Cells["colLanguage"].Value.ToString(), RegistrationDateTime = Convert.ToDateTime(DateTime.Now.ToString(UserData.GetUserData().DateTimeFormat)), RegistrationUserCode = UserData.GetUserData().UserCode, }; try { inVo.Country = selectedRow.Cells["colCountry"].Value.ToString(); CountryLanguageVo tableCount = CheckCountryRelation(inVo); if (tableCount.AffectedCount > 0) { messageData = new MessageData("mmce00007", Properties.Resources.mmce00007, User.ToString()); popUpMessage.Information(messageData, Text); return; } CountryLanguageVo outVo = (CountryLanguageVo)base.InvokeCbm(new DeleteCountryLanguageMasterMntCbm(), inVo, false); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (outVo.AffectedCount == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } else if (dialogResult == DialogResult.Cancel) { //do something else } }
/// <summary> /// For setting selected user record into respective controls(textbox and combobox) for update operation /// passing selected user data as parameter /// </summary> /// <param name="dgvUser"></param> private void LoadUserData(CountryLanguageVo dgvUser) { if (dgvUser != null) { this.Country_txt.Text = dgvUser.Country; this.Language_txt.Text = dgvUser.Language; } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { CountryLanguageVo inVo = (CountryLanguageVo)arg; CountryLanguageVo outVo = new CountryLanguageVo(); StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select * from m_country_language "); sqlQuery.Append(" where 1=1 "); if (inVo.Country != null) { sqlQuery.Append(" and country = :country "); } if (inVo.Language != null) { sqlQuery.Append(" and language = :language "); } sqlQuery.Append(" order by country"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.Country != null) { sqlParameter.AddParameterString("country", inVo.Country); } if (inVo.Language != null) { sqlParameter.AddParameterString("language", inVo.Language); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { CountryLanguageVo currOutVo = new CountryLanguageVo { Country = dataReader["country"].ToString(), Language = dataReader["language"].ToString(), LocaleId = Convert.ToInt32(dataReader["locale_id"]) }; outVo.CountryLangListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }
/// <summary> /// constructor /// </summary> /// <param name="pmode"></param> /// <param name="userItem"></param> public AddCountryLanguageForm(string pmode, CountryLanguageVo userItem = null) { InitializeComponent(); mode = pmode; updateData = userItem; if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
/// <summary> /// checks duplicate Country /// </summary> /// <param name="cntryVo"></param> /// <returns></returns> private CountryLanguageVo DuplicateCheck(CountryLanguageVo cntryVo) { CountryLanguageVo outVo = new CountryLanguageVo(); try { outVo = (CountryLanguageVo)base.InvokeCbm(new CheckCountryLanguageMasterMntCbm(), cntryVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
/// <summary> /// To idenctify the relation ship with tables /// </summary> private CountryLanguageVo CheckCountryRelation(CountryLanguageVo inVo) { CountryLanguageVo outVo = new CountryLanguageVo(); try { outVo = (CountryLanguageVo)base.InvokeCbm(new CheckCountryLanguagCheckRelationCbm(), inVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private CountryLanguageVo FormConditionVo() { CountryLanguageVo inVo = new CountryLanguageVo(); if (Country_cmb.SelectedIndex > -1) { inVo.Country = Country_cmb.SelectedValue.ToString(); } if (Language_cmb.SelectedIndex > -1) { inVo.Language = Language_cmb.SelectedValue.ToString(); } return(inVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { CountryLanguageVo inVo = (CountryLanguageVo)arg; CountryLanguageVo outVo = new CountryLanguageVo(); StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("select Count(cl.country) as CntCount from m_country_language as cl "); sqlQuery.Append("inner join m_mes_user as muser on cl.locale_id = muser.locale_id "); sqlQuery.Append(" where 1=1 "); if (inVo.Country != null) { sqlQuery.Append(" and UPPER(cl.country) = UPPER(:country)"); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.Country != null) { sqlParameter.AddParameterString("country", inVo.Country); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); outVo.AffectedCount = 0; while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["CntCount"]); } dataReader.Close(); return(outVo); }
/// <summary> /// form country and factory data for combo /// </summary> private void FormDatatableFromVo() { cntryLangDatatable = new DataTable(); cntryLangDatatable.Columns.Add("LocaleId"); cntryLangDatatable.Columns.Add("countrycode"); factoryDatatable = new DataTable(); factoryDatatable.Columns.Add("code"); factoryDatatable.Columns.Add("Name"); try { FactoryVo factoryOutVo = (FactoryVo)InvokeCbm(new GetFactoryMasterMntCbm(), new FactoryVo(), false); foreach (FactoryVo fac in factoryOutVo.FactoryListVo) { factoryDatatable.Rows.Add(fac.FactoryCode, fac.FactoryName); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } try { CountryLanguageVo countryLangOutVo = (CountryLanguageVo)InvokeCbm(new GetCountryLanguageMasterMntCbm(), new CountryLanguageVo(), false); foreach (CountryLanguageVo cntry in countryLangOutVo.CountryLangListVo) { cntryLangDatatable.Rows.Add(cntry.LocaleId, cntry.Language + "-" + cntry.Country); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { CountryLanguageVo inVo = (CountryLanguageVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_country_language"); sqlQuery.Append(" ( "); sqlQuery.Append(" country, "); sqlQuery.Append(" language, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :country ,"); sqlQuery.Append(" :language ,"); sqlQuery.Append(" :registrationusercode ,"); sqlQuery.Append(" now() "); sqlQuery.Append(" ); "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("country", inVo.Country); sqlParameter.AddParameterString("language ", inVo.Language); sqlParameter.AddParameterString("registrationusercode ", inVo.RegistrationUserCode); //sqlParameter.AddParameterDateTime("registrationdatetime ", inVo.RegistrationDateTime); CountryLanguageVo outVo = new CountryLanguageVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// loads country and language data table /// </summary> private void FormDatatableFromVo() { cntryLangDatatable = new DataTable(); cntryLangDatatable.Columns.Add("countrycode"); cntryLangDatatable.Columns.Add("langcode"); CountryLanguageVo inVo = FormConditionVo(); try { CountryLanguageVo countryLangOutVo = (CountryLanguageVo)base.InvokeCbm(new GetCountryLanguageMasterMntCbm(), inVo, false); foreach (CountryLanguageVo cntry in countryLangOutVo.CountryLangListVo) { cntryLangDatatable.Rows.Add(cntry.Country, cntry.Language); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
/// <summary> /// update the record to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { if (CheckMandatory()) { bool inputOK = CheckCountryAndLanguage(); if (!inputOK) { return; } CountryLanguageVo inVo = new CountryLanguageVo(); inVo.Country = Country_txt.Text; inVo.Language = Language_txt.Text; //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; if (string.Equals(mode, CommonConstants.MODE_ADD)) { CountryLanguageVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, Country_lbl.Text + " : " + Country_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { CountryLanguageVo outVo = (CountryLanguageVo)base.InvokeCbm(new AddCountryLanguageMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { CountryLanguageVo outVo = (CountryLanguageVo)base.InvokeCbm(new UpdateCountryLanguageMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }