public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ShelfVo inVo = (ShelfVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Update m_shelf"); sqlQuery.Append(" Set "); sqlQuery.Append(" shelf_name = :shelfname, "); sqlQuery.Append(" area_id = :areaid "); sqlQuery.Append(" Where "); sqlQuery.Append(" shelf_id = :shelfid ;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("shelfid", inVo.ShelfId); sqlParameter.AddParameterString("shelfname", inVo.ShelfName); sqlParameter.AddParameterInteger("areaid", inVo.AreaId); ShelfVo outVo = new ShelfVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(ShelfVo conditionInVo) { Shelf_dgv.DataSource = null; try { ShelfVo outVo = (ShelfVo)base.InvokeCbm(new GetShelfMasterMntCbm(), conditionInVo, false); Shelf_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.ShelfListVo, null); if (bindingSource1 != null && bindingSource1.Count > 0) { Shelf_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); } Shelf_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 BindUpdateShelfData() { int selectedrowindex = Shelf_dgv.SelectedCells[0].RowIndex; ShelfVo cavInVo = (ShelfVo)Shelf_dgv.Rows[selectedrowindex].DataBoundItem; AddShelfForm newAddForm = new AddShelfForm(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()); } }
/// <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(ShelfVo dgvMoldType) { if (dgvMoldType != null) { this.ShelfCode_txt.Text = dgvMoldType.ShelfCode; this.ShelfName_txt.Text = dgvMoldType.ShelfName; this.Area_cmb.SelectedValue = dgvMoldType.AreaId.ToString(); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ShelfVo inVo = (ShelfVo)arg; StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select Count(*) as shelfCount from m_shelf "); sqlQuery.Append(" where 1 = 1 "); if (inVo.ShelfCode != null) { sqlQuery.Append(" and UPPER(shelf_cd) = UPPER(:shelfcd) "); } //if (inVo.AreaId > 0) //{ // sqlQuery.Append(" and area_id = :areaid "); //} //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.ShelfCode != null) { sqlParameter.AddParameterString("shelfcd", inVo.ShelfCode); } //if (inVo.AreaId > 0) //{ // sqlParameter.AddParameterInteger("areaid", inVo.AreaId); //} //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); ShelfVo outVo = new ShelfVo { AffectedCount = 0 }; while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["shelfCount"]); } dataReader.Close(); return(outVo); }
/// <summary> /// Constructor for the form /// </summary> /// <param name="pmode"></param> /// <param name="userItem"></param> public AddShelfForm(string pmode, ShelfVo 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 = Shelf_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = Shelf_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colShelfCode"].Value.ToString()); logger.Info(messageData); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { ShelfVo inVo = new ShelfVo(); inVo.ShelfId = Convert.ToInt32(selectedRow.Cells["colShelfId"].Value); try { ShelfVo outVo = (ShelfVo)base.InvokeCbm(new DeleteShelfMasterMntCbm(), 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 ShelfVo DuplicateCheck(ShelfVo ShelfVo) { ShelfVo outVo = new ShelfVo(); try { outVo = (ShelfVo)base.InvokeCbm(new CheckShelfMasterMntCbm(), ShelfVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ShelfVo inVo = (ShelfVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_shelf"); sqlQuery.Append(" ( "); sqlQuery.Append(" shelf_cd, "); sqlQuery.Append(" shelf_name, "); sqlQuery.Append(" area_id, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :shelfcd ,"); sqlQuery.Append(" :shelfname ,"); sqlQuery.Append(" :areaid ,"); 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("shelfcd", inVo.ShelfCode); sqlParameter.AddParameterString("shelfname", inVo.ShelfName); sqlParameter.AddParameterInteger("areaid", inVo.AreaId); sqlParameter.AddParameterString("registrationusercode", trxContext.UserData.UserCode); sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime); sqlParameter.AddParameterString("factorycode", trxContext.UserData.FactoryCode); ShelfVo outVo = new ShelfVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private ShelfVo FormConditionVo() { ShelfVo inVo = new ShelfVo(); if (ShelfCode_txt.Text != string.Empty) { inVo.ShelfCode = ShelfCode_txt.Text; } if (ShelfName_txt.Text != string.Empty) { inVo.ShelfName = ShelfName_txt.Text; } if (Area_cmb.SelectedIndex > -1) { inVo.AreaId = Convert.ToInt32(Area_cmb.SelectedValue); } return(inVo); }
/// <summary> /// update the record to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { ShelfVo inVo = new ShelfVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(ShelfCode_txt.Text) || !sch.IsASCII(ShelfName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(ShelfCode_txt.Text)) { ShelfCode_txt.Focus(); } else { ShelfName_txt.Focus(); } return; } //if(ShelfCode_txt.Text.Trim().Length < 4) //{ // MessageData messageData = new MessageData("mmci00008", Properties.Resources.mmci00008, ShelfCode_lbl.Text); // popUpMessage.Warning(messageData, Text); // ShelfCode_txt.Focus(); // return; //} inVo.ShelfCode = ShelfCode_txt.Text.Trim(); inVo.ShelfName = ShelfName_txt.Text.Trim(); inVo.AreaId = Convert.ToInt32(Area_cmb.SelectedValue); if (string.Equals(mode, CommonConstants.MODE_ADD)) { ShelfVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, ShelfCode_lbl.Text + " : " + ShelfCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); ShelfCode_txt.Focus(); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { ShelfVo outVo = (ShelfVo)base.InvokeCbm(new AddShelfMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.ShelfId = updateData.ShelfId; ShelfVo outVo = (ShelfVo)base.InvokeCbm(new UpdateShelfMasterMntCbm(), 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(); } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ShelfVo inVo = (ShelfVo)arg; StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select ct.shelf_id, ct.shelf_cd, ct.shelf_name, md.area_id, md.area_name "); sqlQuery.Append(" from m_shelf ct "); sqlQuery.Append(" inner join m_area md on md.area_id = ct.area_id "); sqlQuery.Append(" where 1 = 1 "); if (inVo.ShelfCode != null) { sqlQuery.Append(" and ct.shelf_cd like :shelfcd "); } if (inVo.ShelfName != null) { sqlQuery.Append(" and ct.shelf_name like :shelfname "); } if (inVo.AreaId != 0) { sqlQuery.Append(" and md.area_id = :areaid "); } sqlQuery.Append(" order by ct.shelf_cd"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.ShelfCode != null) { sqlParameter.AddParameterString("shelfcd", inVo.ShelfCode + "%"); } if (inVo.ShelfName != null) { sqlParameter.AddParameterString("shelfname", inVo.ShelfName + "%"); } if (inVo.AreaId != 0) { sqlParameter.AddParameterInteger("areaid", inVo.AreaId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); ShelfVo outVo = new ShelfVo(); while (dataReader.Read()) { ShelfVo currOutVo = new ShelfVo { ShelfId = Convert.ToInt32(dataReader["shelf_id"]), ShelfCode = dataReader["shelf_cd"].ToString(), ShelfName = dataReader["shelf_name"].ToString(), AreaId = Convert.ToInt32(dataReader["area_id"]), AreaName = dataReader["area_name"].ToString() }; outVo.ShelfListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }