public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { FactoryProductionDaysVo inVo = (FactoryProductionDaysVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append(" UPDATE "); sqlQuery.Append(" m_factory_production_days "); sqlQuery.Append(" SET "); sqlQuery.Append(" year = :iyear, "); sqlQuery.Append(" month = :imonth, "); sqlQuery.Append(" days = :idays "); sqlQuery.Append(" WHERE "); sqlQuery.Append(" factory_cd = :factorycode "); sqlQuery.Append(" AND "); sqlQuery.Append(" factory_production_days_id = :factoryproductiondaysid "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("iyear", inVo.iYear); sqlParameter.AddParameterInteger("imonth", inVo.iMonth); sqlParameter.AddParameterInteger("idays", inVo.iDays); sqlParameter.AddParameterString("factorycode", inVo.FactoryCode); sqlParameter.AddParameterInteger("factoryproductiondaysid", inVo.FactoryProductionDaysId); FactoryProductionDaysVo outVo = new FactoryProductionDaysVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(FactoryProductionDaysVo conditionInVo) { FactoryProductionDays_dgv.DataSource = null; FactoryProductionDaysVo outVo = null; try { outVo = (FactoryProductionDaysVo)DefaultCbmInvoker.Invoke(new GetFactoryProductionDaysMasterMntCbm(), conditionInVo); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } FactoryProductionDays_dgv.AutoGenerateColumns = false; BindingSource factoryProductionDaysBindingSource = new BindingSource(outVo.FactoryProductionDaysListVo, null); if (factoryProductionDaysBindingSource.Count == 0) { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006); logger.Info(messageData); popUpMessage.Information(messageData, Text); return; } FactoryProductionDays_dgv.DataSource = factoryProductionDaysBindingSource; FactoryProductionDays_dgv.ClearSelection(); }
/// <summary> /// selects user record for updation and show factory form /// </summary> private void BindUpdateFactoryProductionDaysData() { int selectedrowindex = FactoryProductionDays_dgv.SelectedCells[0].RowIndex; FactoryProductionDaysVo selectedFactoryProductionDays = (FactoryProductionDaysVo)FactoryProductionDays_dgv.Rows[selectedrowindex].DataBoundItem; AddFactoryProductionDaysMasterForm addFactoryProductionDaysMasterForm = new AddFactoryProductionDaysMasterForm(CommonConstants.MODE_UPDATE, selectedFactoryProductionDays); addFactoryProductionDaysMasterForm.ShowDialog(this); if (addFactoryProductionDaysMasterForm.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (addFactoryProductionDaysMasterForm.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } }
private void LoadCustomerLinesData(FactoryProductionDaysVo dgvCustomerLine) { if (dgvCustomerLine != null) { Customer_cmb.Text = dgvCustomerLine.BuildingName; //Need to change Vo and name } }
/// <summary> /// For setting selected factory record into respective controls(textbox and combobox) for update operation /// passing selected factory data as parameter /// </summary> /// <param name="dgvFactory"></param> private void LoadFactoryProductionDaysData(FactoryProductionDaysVo dgvFactoryProductionDays) { if (dgvFactoryProductionDays != null) { Building_cmb.Text = dgvFactoryProductionDays.BuildingName; Year_txt.Text = Convert.ToString(dgvFactoryProductionDays.iYear); Month_cmb.SelectedIndex = Convert.ToInt32(dgvFactoryProductionDays.iMonth) - 1; Date_txt.Text = Convert.ToString(dgvFactoryProductionDays.iDays); factoryProductionDaysId = dgvFactoryProductionDays.FactoryProductionDaysId; } }
/// <summary> /// constructor /// </summary> /// <param name="pmode"></param> /// <param name="factoryItem"></param> public AddFactoryProductionDaysMasterForm(string pmode, FactoryProductionDaysVo factoryProductionDaysItem = null) { InitializeComponent(); mode = pmode; updateData = factoryProductionDaysItem; if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
public AddCustomerLineForm(string pmode, FactoryProductionDaysVo customerLineItem = null) { InitializeComponent(); mode = pmode; updateData = customerLineItem; // Need to change Vo if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Ok_btn_Click(object sender, EventArgs e) { var sch = StringCheckHelper.GetInstance(); FactoryProductionDaysVo inVo = new FactoryProductionDaysVo(); if (CheckMandatory()) { inVo.iYear = Convert.ToInt32(Year_txt.Text); inVo.iMonth = Convert.ToInt32(Month_cmb.SelectedItem.ToString()); inVo.iDays = Convert.ToInt32(Date_txt.Text); inVo.FactoryProductionDaysId = factoryProductionDaysId; inVo.BuildingId = Convert.ToInt32(Building_cmb.SelectedValue); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; inVo.FactoryCode = UserData.GetUserData().FactoryCode; try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { FactoryProductionDaysVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00009", Properties.Resources.mmce00009, " " + Year_lbl.Text + " or " + MonthDate_lbl.Text.Substring(0, 5)); logger.Info(messageData); popUpMessage.Warning(messageData, Text); return; } FactoryProductionDaysVo outVo = (FactoryProductionDaysVo)base.InvokeCbm(new AddFactoryProductionDaysMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { FactoryProductionDaysVo outVo = (FactoryProductionDaysVo)base.InvokeCbm(new UpdateFactoryProductionDaysMasterMntCbm(), 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(); } } }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private FactoryProductionDaysVo FormConditionVo() { FactoryProductionDaysVo inVo = new FactoryProductionDaysVo(); if (Building_cmb.SelectedIndex > -1) { inVo.BuildingId = Convert.ToInt32(Building_cmb.SelectedValue); } if (!string.IsNullOrEmpty(Year_txt.Text)) { inVo.iYear = Convert.ToInt32(Year_txt.Text); } return(inVo); }
/// <summary> /// event to delete the selected record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Delete_btn_Click(object sender, EventArgs e) { int selectedrowindex = FactoryProductionDays_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = FactoryProductionDays_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colBuildingName"].Value.ToString() + " : " + selectedRow.Cells["coliYear"].Value.ToString() + " / " + selectedRow.Cells["coliMonth"].Value.ToString() + " / " + selectedRow.Cells["coliDays"].Value.ToString()); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { FactoryProductionDaysVo inVo = new FactoryProductionDaysVo { FactoryProductionDaysId = Convert.ToInt32(selectedRow.Cells["colFactoryProductionId"].Value.ToString()) }; try { FactoryProductionDaysVo outVo = (FactoryProductionDaysVo)base.InvokeCbm(new DeleteFactoryProductionDaysMasterMntCbm(), 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 FactoryCode /// </summary> /// <param name="factVo"></param> /// <returns></returns> private FactoryProductionDaysVo DuplicateCheck(FactoryProductionDaysVo factoryProductionDaysVo) { FactoryProductionDaysVo outVo = new FactoryProductionDaysVo(); try { outVo = (FactoryProductionDaysVo)base.InvokeCbm(new CheckFactoryProductionDaysMasterMntCbm(), factoryProductionDaysVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { FactoryProductionDaysVo inVo = (FactoryProductionDaysVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append(" INSERT "); sqlQuery.Append(" INTO m_factory_production_days "); sqlQuery.Append(" ( "); sqlQuery.Append(" year, "); sqlQuery.Append(" month, "); sqlQuery.Append(" days, "); sqlQuery.Append(" building_id, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append(" VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :iyear, "); sqlQuery.Append(" :imonth, "); sqlQuery.Append(" :idays, "); sqlQuery.Append(" :buildingid, "); sqlQuery.Append(" :registrationusercd, "); sqlQuery.Append(" now(), "); sqlQuery.Append(" :factorycode "); sqlQuery.Append(" ); "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("iyear", inVo.iYear); sqlParameter.AddParameterInteger("imonth", inVo.iMonth); sqlParameter.AddParameterInteger("idays", inVo.iDays); sqlParameter.AddParameterInteger("buildingid", inVo.BuildingId); sqlParameter.AddParameterString("registrationusercd", inVo.RegistrationUserCode); sqlParameter.AddParameterString("factorycode", inVo.FactoryCode); FactoryProductionDaysVo outVo = new FactoryProductionDaysVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { FactoryProductionDaysVo inVo = (FactoryProductionDaysVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append(" SELECT "); sqlQuery.Append(" Count(*) AS FactoryProductionDaysCount "); sqlQuery.Append(" FROM "); sqlQuery.Append(" m_factory_production_days "); sqlQuery.Append(" WHERE 1 = 1 "); sqlQuery.Append(" AND UPPER(factory_cd) = UPPER(:factorycode) "); sqlQuery.Append(" AND building_id = :buildingid "); sqlQuery.Append(" AND year = :iyear "); sqlQuery.Append(" AND month = :imonth "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("factorycode", inVo.FactoryCode); sqlParameter.AddParameterInteger("buildingid", inVo.BuildingId); sqlParameter.AddParameterInteger("iyear", inVo.iYear); sqlParameter.AddParameterInteger("imonth", inVo.iMonth); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); FactoryProductionDaysVo outVo = new FactoryProductionDaysVo(); while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["FactoryProductionDaysCount"]); } dataReader.Close(); return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { FactoryProductionDaysVo inVo = (FactoryProductionDaysVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append(" DELETE from"); sqlQuery.Append(" m_factory_production_days "); sqlQuery.Append(" WHERE "); sqlQuery.Append(" factory_production_days_id = :factoryproductiondaysid; "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("factoryproductiondaysid", inVo.FactoryProductionDaysId); FactoryProductionDaysVo outVo = new FactoryProductionDaysVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { FactoryProductionDaysVo inVo = (FactoryProductionDaysVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append(" SELECT "); sqlQuery.Append(" fpd.factory_production_days_id, "); sqlQuery.Append(" fpd.year, "); sqlQuery.Append(" fpd.month, "); sqlQuery.Append(" fpd.days, "); sqlQuery.Append(" fpd.building_id, "); sqlQuery.Append(" bl.building_name "); sqlQuery.Append(" FROM "); sqlQuery.Append(" m_factory_production_days fpd "); sqlQuery.Append(" INNER JOIN m_building bl ON bl.building_id = fpd.building_id "); sqlQuery.Append(" WHERE "); sqlQuery.Append(" fpd.factory_cd = :factorycode "); if (inVo.iYear > 0) { sqlQuery.Append(" AND fpd.year = :iyear "); } if (inVo.BuildingId > 0) { sqlQuery.Append(" AND fpd.building_id = :buildingid "); } sqlQuery.Append(" ORDER BY bl.building_name, fpd.year, fpd.month, fpd.factory_production_days_id "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (!string.IsNullOrEmpty(inVo.FactoryCode)) { sqlParameter.AddParameterString("factorycode", inVo.FactoryCode); } else { sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode); } if (inVo.iYear > 0) { sqlParameter.AddParameterInteger("iyear", inVo.iYear); } if (inVo.BuildingId > 0) { sqlParameter.AddParameterInteger("buildingid", inVo.BuildingId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); FactoryProductionDaysVo outVo = new FactoryProductionDaysVo(); while (dataReader.Read()) { FactoryProductionDaysVo currOutVo = new FactoryProductionDaysVo(); currOutVo.FactoryProductionDaysId = ConvertDBNull <int>(dataReader, "factory_production_days_id"); currOutVo.iYear = ConvertDBNull <int>(dataReader, "year"); currOutVo.iMonth = ConvertDBNull <int>(dataReader, "month"); currOutVo.iDays = ConvertDBNull <int>(dataReader, "days"); currOutVo.BuildingId = ConvertDBNull <int>(dataReader, "building_id"); currOutVo.BuildingName = ConvertDBNull <string>(dataReader, "building_name"); outVo.FactoryProductionDaysListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }