/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(AreaVo conditionInVo) { Area_dgv.DataSource = null; try { AreaVo outVo = (AreaVo)base.InvokeCbm(new GetAreaMasterMntCbm(), conditionInVo, false); Area_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.AreaListVo, null); if (bindingSource1 != null && bindingSource1.Count > 0) { Area_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); } Area_dgv.ClearSelection(); Update_btn.Enabled = false; Delete_btn.Enabled = false; } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
/// <summary> /// selects user record for updation and show user form /// </summary> private void BindUpdateAreaData() { int selectedrowindex = Area_dgv.SelectedCells[0].RowIndex; AreaVo cavInVo = (AreaVo)Area_dgv.Rows[selectedrowindex].DataBoundItem; AddAreaForm newAddForm = new AddAreaForm(CommonConstants.MODE_UPDATE, cavInVo); 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()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { AreaVo inVo = (AreaVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Update m_area"); sqlQuery.Append(" Set "); sqlQuery.Append(" area_name = :areaname, "); sqlQuery.Append(" location_id = :locationid "); sqlQuery.Append(" Where "); sqlQuery.Append(" area_id = :areaid ;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("areaid", inVo.AreaId); sqlParameter.AddParameterString("areaname", inVo.AreaName); sqlParameter.AddParameterInteger("locationid", inVo.LocationId); AreaVo outVo = new AreaVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// For setting selected user record into respective controls(textbox and combobox) for update operation /// passing selected user data as parameter /// </summary> /// <param name="dgvMoldType"></param> private void LoadUserData(AreaVo dgvMoldType) { if (dgvMoldType != null) { this.AreaCode_txt.Text = dgvMoldType.AreaCode; this.AreaName_txt.Text = dgvMoldType.AreaName; this.Location_cmb.SelectedValue = dgvMoldType.LocationId.ToString(); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { AreaVo inVo = (AreaVo)arg; StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select Count(*) as areaCount from m_area "); sqlQuery.Append(" where 1 = 1 "); if (inVo.AreaCode != null) { sqlQuery.Append(" and UPPER(area_cd) = UPPER(:areacd) "); } //if (inVo.locationId > 0) //{ // sqlQuery.Append(" and location_id = :locationid "); //} //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.AreaCode != null) { sqlParameter.AddParameterString("areacd", inVo.AreaCode); } //if (inVo.locationId > 0) //{ // sqlParameter.AddParameterInteger("locationid", inVo.LocationId); //} //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); AreaVo outVo = new AreaVo { AffectedCount = 0 }; while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["areaCount"]); } dataReader.Close(); return(outVo); }
/// <summary> /// Constructor for the form /// </summary> /// <param name="pmode"></param> /// <param name="userItem"></param> public AddAreaForm(string pmode, AreaVo userItem = null) { InitializeComponent(); mode = pmode; updateData = userItem; if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
/// <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 = Area_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = Area_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colAreaCode"].Value.ToString()); logger.Info(messageData); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { AreaVo inVo = new AreaVo(); inVo.AreaId = Convert.ToInt32(selectedRow.Cells["colAreaId"].Value); try { AreaVo outVo = (AreaVo)base.InvokeCbm(new DeleteAreaMasterMntCbm(), 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> /// checks duplicate mold Code /// </summary> /// <returns></returns> private AreaVo DuplicateCheck(AreaVo AreaVo) { AreaVo outVo = new AreaVo(); try { outVo = (AreaVo)base.InvokeCbm(new CheckAreaMasterMntCbm(), AreaVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { AreaVo inVo = (AreaVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_area"); sqlQuery.Append(" ( "); sqlQuery.Append(" area_cd, "); sqlQuery.Append(" area_name, "); sqlQuery.Append(" 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(" :areacd ,"); sqlQuery.Append(" :areaname ,"); sqlQuery.Append(" :locationid ,"); 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.AddParameterString("areacd", inVo.AreaCode); sqlParameter.AddParameterString("areaname", inVo.AreaName); sqlParameter.AddParameterInteger("locationid", inVo.LocationId); sqlParameter.AddParameterString("registrationusercode", trxContext.UserData.UserCode); sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime); sqlParameter.AddParameterString("factorycode", trxContext.UserData.FactoryCode); AreaVo outVo = new AreaVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private AreaVo FormConditionVo() { AreaVo inVo = new AreaVo(); if (AreaCode_txt.Text != string.Empty) { inVo.AreaCode = AreaCode_txt.Text; } if (AreaName_txt.Text != string.Empty) { inVo.AreaName = AreaName_txt.Text; } if (Location_cmb.SelectedIndex > -1) { inVo.LocationId = Convert.ToInt32(Location_cmb.SelectedValue); } return(inVo); }
/// <summary> /// form country and factory data for combo /// </summary> private void FormDatatableFromVo() { areaDatatable = new DataTable(); areaDatatable.Columns.Add("id"); areaDatatable.Columns.Add("name"); try { AreaVo areaOutVo = (AreaVo)base.InvokeCbm(new GetAreaMasterMntCbm(), new AreaVo(), false); foreach (AreaVo area in areaOutVo.AreaListVo) { areaDatatable.Rows.Add(area.AreaId, area.AreaName); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { AreaVo inVo = (AreaVo)arg; StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select ct.area_id, ct.area_cd, ct.area_name, md.location_id, md.location_name "); sqlQuery.Append(" from m_area ct "); sqlQuery.Append(" inner join m_location md on md.location_id = ct.location_id "); sqlQuery.Append(" where 1 = 1 "); if (inVo.AreaCode != null) { sqlQuery.Append(" and ct.area_cd like :areacd "); } if (inVo.AreaName != null) { sqlQuery.Append(" and ct.area_name like :areaname "); } if (inVo.LocationId != 0) { sqlQuery.Append(" and md.location_id = :locationid "); } sqlQuery.Append(" order by ct.area_cd"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.AreaCode != null) { sqlParameter.AddParameterString("areacd", inVo.AreaCode + "%"); } if (inVo.AreaName != null) { sqlParameter.AddParameterString("areaname", inVo.AreaName + "%"); } if (inVo.LocationId != 0) { sqlParameter.AddParameterInteger("locationid", inVo.LocationId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); AreaVo outVo = new AreaVo(); while (dataReader.Read()) { AreaVo currOutVo = new AreaVo { AreaId = Convert.ToInt32(dataReader["area_id"]), AreaCode = dataReader["area_cd"].ToString(), AreaName = dataReader["area_name"].ToString(), LocationId = Convert.ToInt32(dataReader["location_id"]), LocationName = dataReader["location_name"].ToString() }; outVo.AreaListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }
/// <summary> /// update the record to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { AreaVo inVo = new AreaVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(AreaCode_txt.Text) || !sch.IsASCII(AreaName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(AreaCode_txt.Text)) { AreaCode_txt.Focus(); } else { AreaName_txt.Focus(); } return; } //if(AreaCode_txt.Text.Trim().Length < 4) //{ // MessageData messageData = new MessageData("mmci00008", Properties.Resources.mmci00008, AreaCode_lbl.Text); // popUpMessage.Warning(messageData, Text); // AreaCode_txt.Focus(); // return; //} inVo.AreaCode = AreaCode_txt.Text.Trim(); inVo.AreaName = AreaName_txt.Text.Trim(); inVo.LocationId = Convert.ToInt32(Location_cmb.SelectedValue); if (string.Equals(mode, CommonConstants.MODE_ADD)) { AreaVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, AreaCode_lbl.Text + " : " + AreaCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); AreaCode_txt.Focus(); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { AreaVo outVo = (AreaVo)base.InvokeCbm(new AddAreaMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.AreaId = updateData.AreaId; AreaVo outVo = (AreaVo)base.InvokeCbm(new UpdateAreaMasterMntCbm(), 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(); } } }