/// <summary> /// selects user record for updation and show user form /// </summary> private void BindUpdateUserData() { int selectedrowindex = EquipmentData_dgv.SelectedCells[0].RowIndex; EquipmentVo selectedData = (EquipmentVo)EquipmentData_dgv.Rows[selectedrowindex].DataBoundItem; AddEquipmentForm newAddForm = new AddEquipmentForm(CommonConstants.MODE_UPDATE, selectedData); 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> /// Fills all user records to gridview control /// </summary> private void GridBind(EquipmentVo conditionInVo) { EquipmentData_dgv.DataSource = null; try { EquipmentVo outVo = (EquipmentVo)base.InvokeCbm(new GetEquipmentMasterMntCbm(), conditionInVo, false); EquipmentData_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.EquipmentListVo, null); if (bindingSource1 != null && bindingSource1.Count > 0) { EquipmentData_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //"equipment" logger.Info(messageData); popUpMessage.Information(messageData, Text); } EquipmentData_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) { EquipmentVo inVo = (EquipmentVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Update m_equipment"); sqlQuery.Append(" Set "); sqlQuery.Append(" equipment_name = :equipmentname , "); sqlQuery.Append(" instration_dt = :instrationdt , "); sqlQuery.Append(" asset_no = :assetno , "); sqlQuery.Append(" manufacturer = :manufacturer , "); sqlQuery.Append(" model_name = :modelname , "); sqlQuery.Append(" model_cd = :modelcd "); sqlQuery.Append(" Where "); sqlQuery.Append(" equipment_id = :equipmentid "); sqlQuery.Append(" and factory_cd = :faccd ;"); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("equipmentid", inVo.EquipmentId); sqlParameter.AddParameterString("equipmentname", inVo.EquipmentName); sqlParameter.AddParameterDateTime("instrationdt", inVo.InstrationDate); sqlParameter.AddParameterString("assetno", inVo.AssetNo); sqlParameter.AddParameterString("manufacturer", inVo.Manufacturer); sqlParameter.AddParameterString("modelname", inVo.ModelName); sqlParameter.AddParameterString("modelcd", inVo.ModelCode); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); EquipmentVo outVo = new EquipmentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { EquipmentVo inVo = (EquipmentVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_equipment"); sqlQuery.Append(" ( "); sqlQuery.Append(" equipment_cd, "); sqlQuery.Append(" equipment_name, "); sqlQuery.Append(" instration_dt, "); sqlQuery.Append(" asset_no, "); sqlQuery.Append(" manufacturer, "); sqlQuery.Append(" model_name, "); sqlQuery.Append(" model_cd, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :equipmentcd ,"); sqlQuery.Append(" :equipmentname ,"); sqlQuery.Append(" :instrationdt ,"); sqlQuery.Append(" :assetno ,"); sqlQuery.Append(" :manufacturer ,"); sqlQuery.Append(" :modelname ,"); sqlQuery.Append(" :modelcd ,"); sqlQuery.Append(" :registrationusercd ,"); sqlQuery.Append(" now(),"); sqlQuery.Append(" :factorycd "); sqlQuery.Append(" ); "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("equipmentcd", inVo.EquipmentCode); sqlParameter.AddParameterString("equipmentname", inVo.EquipmentName); sqlParameter.AddParameterDateTime("instrationdt", inVo.InstrationDate); sqlParameter.AddParameterString("assetno", inVo.AssetNo); sqlParameter.AddParameterString("manufacturer", inVo.Manufacturer); sqlParameter.AddParameterString("modelname", inVo.ModelName); sqlParameter.AddParameterString("modelcd", inVo.ModelCode); sqlParameter.AddParameterString("registrationusercd", inVo.RegistrationUserCode); //sqlParameter.AddParameterDateTime("registrationdt", inVo.RegistrationDateTime); sqlParameter.AddParameterString("factorycd", inVo.FactoryCode); EquipmentVo outVo = new EquipmentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// constructor /// </summary> /// <param name="pmode"></param> /// <param name="dataItem"></param> public AddEquipmentForm(string pmode, EquipmentVo dataItem = null) { InitializeComponent(); mode = pmode; updateData = dataItem; if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
/// <summary> /// checks duplicate Equipment Code /// </summary> /// <param name="eqpVo"></param> /// <returns></returns> private EquipmentVo DuplicateCheck(EquipmentVo eqpVo) { EquipmentVo outVo = new EquipmentVo(); try { outVo = (EquipmentVo)base.InvokeCbm(new CheckEquipmentMasterMntCbm(), eqpVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { EquipmentVo inVo = (EquipmentVo)arg; EquipmentVo outVo = new EquipmentVo(); StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("select eq.equipment_cd, cmf.casting_machine_furnace_id as CastFurnaceId, "); sqlQuery.Append(" cm.casting_machine_id as CastingMachineId from m_equipment eq "); sqlQuery.Append(" left outer join m_casting_machine_furnace cmf on cmf.equipment_id = eq.equipment_id "); sqlQuery.Append(" left outer join m_casting_machine cm on cm.equipment_id = eq.equipment_id "); sqlQuery.Append(" where eq.factory_cd = :faccd "); if (inVo.EquipmentCode != null) { sqlQuery.Append(" and UPPER(equipment_cd) = UPPER(:equipmentcode) "); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.EquipmentCode != null) { sqlParameter.AddParameterString("equipmentcode", inVo.EquipmentCode); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); outVo.AffectedCount = 0; while (dataReader.Read()) { outVo.CastingMachineFurnaceId = Convert.ToInt32("0" + dataReader["CastFurnaceId"]); outVo.CastingMachineId = Convert.ToInt32("0" + dataReader["CastingMachineId"]); } dataReader.Close(); return(outVo); }
/// <summary> /// Loads equipment details to datatable /// </summary> private void FormDatatableFromVo() { equipmentDatatable = new DataTable(); equipmentDatatable.Columns.Add("Id"); equipmentDatatable.Columns.Add("Name"); try { EquipmentVo equipmentOutVo = (EquipmentVo)base.InvokeCbm(new GetEquipmentMasterMntCbm(), new EquipmentVo(), false); foreach (EquipmentVo fac in equipmentOutVo.EquipmentListVo) { equipmentDatatable.Rows.Add(fac.EquipmentId, fac.EquipmentName); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } //CastingMachineFurnaceDatatable castingMachineFurnaceDatatable = new DataTable(); castingMachineFurnaceDatatable.Columns.Add("Id"); castingMachineFurnaceDatatable.Columns.Add("Name"); try { CastingMachineFurnaceVo castingMachineFurnaceOutVo = (CastingMachineFurnaceVo)base.InvokeCbm(new GetCastingMachineFurnaceMasterMntCbm(), new CastingMachineFurnaceVo(), false); foreach (CastingMachineFurnaceVo castfur in castingMachineFurnaceOutVo.CastingMachineFurnaceListVo) { castingMachineFurnaceDatatable.Rows.Add(castfur.CastingMachineFurnaceId, castfur.CastingMachineFurnaceName); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
/// <summary> /// For setting selected user record into respective controls(textbox and combobox) for update operation /// passing selected user data as parameter /// </summary> /// <param name="dgvData"></param> private void LoadUserData(EquipmentVo dgvData) { if (dgvData != null) { EquipmentCode_txt.Text = dgvData.EquipmentCode; EquipmentName_txt.Text = dgvData.EquipmentName; InstrationDate_dtp.Value = dgvData.InstrationDate; AssetNo_txt.Text = dgvData.AssetNo; Manufacturer_txt.Text = dgvData.Manufacturer; ModelCode_txt.Text = dgvData.ModelCode; ModelName_txt.Text = dgvData.ModelName; } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { EquipmentVo inVo = (EquipmentVo)arg; EquipmentVo outVo = new EquipmentVo(); StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select Count(*) as EqpCount from m_equipment "); sqlQuery.Append(" where factory_cd = :faccd "); if (inVo.EquipmentCode != null) { sqlQuery.Append(" and UPPER(equipment_cd) = UPPER(:equipmentcode) "); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.EquipmentCode != null) { sqlParameter.AddParameterString("equipmentcode", inVo.EquipmentCode); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); outVo.AffectedCount = 0; while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["EqpCount"]); } dataReader.Close(); return(outVo); }
/// <summary> /// Loads data table for equipment /// </summary> private void FormDatatableFromVo() { equipmentDatatable = new DataTable(); equipmentDatatable.Columns.Add("Id"); equipmentDatatable.Columns.Add("Name"); try { EquipmentVo equipmentOutVo = (EquipmentVo)base.InvokeCbm(new GetEquipmentMasterMntCbm(), new EquipmentVo(), false); foreach (EquipmentVo fac in equipmentOutVo.EquipmentListVo) { equipmentDatatable.Rows.Add(fac.EquipmentId, fac.EquipmentName); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private EquipmentVo FormConditionVo() { EquipmentVo inVo = new EquipmentVo(); if (EquipmentCode_txt.Text != string.Empty) { inVo.EquipmentCode = EquipmentCode_txt.Text; } if (EquipmentName_txt.Text != string.Empty) { inVo.EquipmentName = EquipmentName_txt.Text; } if (InstrationDate_dtp.Text != " ") { inVo.InstrationDate = Convert.ToDateTime(InstrationDate_dtp.Text); } if (AssertNo_txt.Text != string.Empty) { inVo.AssetNo = AssertNo_txt.Text; } if (Manufacturer_txt.Text != string.Empty) { inVo.Manufacturer = Manufacturer_txt.Text; } if (ModelCode_txt.Text != string.Empty) { inVo.ModelCode = ModelCode_txt.Text; } if (ModelName_txt.Text != string.Empty) { inVo.ModelName = ModelName_txt.Text; } return(inVo); }
private void MachineAndEquipmentMaster_Load(object sender, EventArgs e) { try { equipvo = (EquipmentVo)DefaultCbmInvoker.Invoke(getEquipmentMasterMntCbm, new EquipmentVo()); machinelist = (MachineVo)DefaultCbmInvoker.Invoke(getMachineMasterMntCbm, new MachineVo()); machinename_cmb.DisplayMember = "MachineName"; machinename_cmb.DataSource = machinelist.MachineListVo; machinename_cmb.SelectedIndex = -1; foreach (EquipmentVo vo in equipvo.EquipmentListVo) { machinequip.Add(new MachineEquipment { evo = vo, Selected = false, MachineEquipmentId = 0 }); } BindingSource bds = new BindingSource(machinequip, null); Equipment_dgv.DataSource = bds; } catch { } //gfg }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { EquipmentVo inVo = (EquipmentVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete From m_equipment"); sqlQuery.Append(" Where "); sqlQuery.Append(" equipment_id = :equipmentid ;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("equipmentid", inVo.EquipmentId); EquipmentVo outVo = new EquipmentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <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 = EquipmentData_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = EquipmentData_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colEquipmentCode"].Value.ToString()); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { EquipmentVo inVo = new EquipmentVo(); inVo.EquipmentId = Convert.ToInt32(selectedRow.Cells["colEquipmentId"].Value); //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd/ HH:mm:ss"); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; inVo.EquipmentCode = selectedRow.Cells["colEquipmentCode"].Value.ToString(); try { EquipmentVo outVo = CheckEquipmentRelation(inVo); if (outVo != null) { StringBuilder message = new StringBuilder(); if (outVo.CastingMachineFurnaceId > 0) { message.Append(EquipmentRelationTables.CastingMachineFurnace); } if (outVo.CastingMachineId > 0) { if (message.Length > 0) { message.Append(" And "); } message.Append(EquipmentRelationTables.CastingMachine); } if (message.Length > 0) { messageData = new MessageData("mmce00007", Properties.Resources.mmce00007, message.ToString()); popUpMessage.Information(messageData, Text); return; } } outVo = (EquipmentVo)base.InvokeCbm(new DeleteEquipmentMasterMntCbm(), inVo, false); if (outVo.AffectedCount > 0) { this.messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null); logger.Info(this.messageData); popUpMessage.Information(this.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 } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { EquipmentVo inVo = (EquipmentVo)arg; EquipmentVo outVo = new EquipmentVo(); StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append("Select * from m_equipment "); sqlQuery.Append(" where 1 = 1 "); if (inVo.EquipmentCode != null) { sqlQuery.Append(" and equipment_cd like :equipmentcode "); } if (inVo.EquipmentName != null) { sqlQuery.Append(" and equipment_name like :equipmentname "); } if (inVo.InstrationDate != null && inVo.InstrationDate != DateTime.MinValue) { sqlQuery.Append(" and instration_dt = :instrationdt "); } if (inVo.AssetNo != null) { sqlQuery.Append(" and asset_no like :assetno "); } if (inVo.Manufacturer != null) { sqlQuery.Append(" and manufacturer like :manufacturer "); } if (inVo.ModelCode != null) { sqlQuery.Append(" and model_cd like :modelcd "); } if (inVo.ModelName != null) { sqlQuery.Append(" and model_name like :modelname "); } sqlQuery.Append(" order by equipment_cd "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.EquipmentCode != null) { sqlParameter.AddParameterString("equipmentcode", inVo.EquipmentCode + "%"); } if (inVo.EquipmentName != null) { sqlParameter.AddParameterString("equipmentname", inVo.EquipmentName + "%"); } if (inVo.InstrationDate != null) { sqlParameter.AddParameterDateTime("instrationdt", inVo.InstrationDate); } if (inVo.AssetNo != null) { sqlParameter.AddParameterString("assetno", inVo.AssetNo + "%"); } if (inVo.Manufacturer != null) { sqlParameter.AddParameterString("manufacturer", inVo.Manufacturer + "%"); } if (inVo.ModelCode != null) { sqlParameter.AddParameterString("modelcd", inVo.ModelCode + "%"); } if (inVo.ModelName != null) { sqlParameter.AddParameterString("modelname", inVo.ModelName + "%"); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { EquipmentVo currOutVo = new EquipmentVo { EquipmentId = Convert.ToInt32(dataReader["equipment_id"]), EquipmentCode = dataReader["equipment_cd"].ToString(), EquipmentName = dataReader["equipment_name"].ToString(), InstrationDate = Convert.ToDateTime(dataReader["instration_dt"]), //.ToString("yyyy-MM-dd"), AssetNo = dataReader["asset_no"].ToString(), Manufacturer = dataReader["manufacturer"].ToString(), ModelName = dataReader["model_name"].ToString(), ModelCode = dataReader["model_cd"].ToString() }; outVo.EquipmentListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { string manufacturer = string.Empty; string modelCode = string.Empty; string modelName = string.Empty; var sch = StringCheckHelper.GetInstance(); if (Manufacturer_txt.Text != null) { manufacturer = Manufacturer_txt.Text.Trim(); } if (ModelCode_txt.Text != null) { modelCode = ModelCode_txt.Text.Trim(); } if (ModelName_txt.Text != null) { modelName = ModelName_txt.Text.Trim(); } EquipmentVo inVo = new EquipmentVo(); if (CheckMandatory()) { if (string.IsNullOrEmpty(EquipmentCode_txt.Text) || string.IsNullOrEmpty(EquipmentName_txt.Text) || string.IsNullOrEmpty(AssetNo_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(EquipmentCode_txt.Text)) { EquipmentCode_txt.Focus(); } else if (string.IsNullOrEmpty(EquipmentName_txt.Text)) { EquipmentName_txt.Focus(); } else if (string.IsNullOrEmpty(AssetNo_txt.Text)) { AssetNo_txt.Focus(); } return; } inVo.EquipmentCode = EquipmentCode_txt.Text.Trim(); inVo.EquipmentName = EquipmentName_txt.Text.Trim(); inVo.InstrationDate = InstrationDate_dtp.Value; inVo.AssetNo = AssetNo_txt.Text.Trim(); inVo.Manufacturer = manufacturer; inVo.ModelCode = modelCode; inVo.ModelName = modelName; //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; inVo.FactoryCode = UserData.GetUserData().FactoryCode; if (string.Equals(mode, CommonConstants.MODE_ADD)) { EquipmentVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, EquipmentCode_lbl.Text + " : " + EquipmentCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); return; } } if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.EquipmentId = updateData.EquipmentId; } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { EquipmentVo outVo = (EquipmentVo)base.InvokeCbm(new AddEquipmentMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.EquipmentId = updateData.EquipmentId; EquipmentVo outVo = (EquipmentVo)base.InvokeCbm(new UpdateEquipmentMasterMntCbm(), 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(); } } }