/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(ItemProcessWorkVo conditionInVo) { ItemProcessWork_dgv.DataSource = null; try { ItemProcessWorkVo outVo = (ItemProcessWorkVo)base.InvokeCbm(new GetItemProcessWorkMasterMntCbm(), conditionInVo, false); ItemProcessWork_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.ItemProcessWorkListVo, null); DataGridViewComboBoxColumn ComboColumn = (DataGridViewComboBoxColumn)(ItemProcessWork_dgv.Columns["colComment"]); ComboColumn.DataSource = processFlowRuleDatatable; ComboColumn.DisplayMember = "Comment"; ComboColumn.Selected = false; if (bindingSource1.Count > 0) { ItemProcessWork_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //item process work logger.Info(messageData); popUpMessage.Information(messageData, Text); } ItemProcessWork_dgv.ClearSelection(); ProcessWorkVo processWOutVo = (ProcessWorkVo)base.InvokeCbm(new GetProcessWorkMasterMntCbm(), new ProcessWorkVo(), false); outVo.ItemProcessWorkListVo.ForEach(t => t.OptionalProcessFlag = t.OptionalProcessFlag.Equals("1") ? "True" : "False"); outVo.ItemProcessWorkListVo.ForEach(t => t.SkipPreventionFlag = t.SkipPreventionFlag.Equals("1") ? "True" : "False"); List <ProcessWorkVo> exceptionList = outVo.ItemProcessWorkListVo.Select(e => new ProcessWorkVo { ProcessWorkId = e.ProcessWorkId } ).ToList(); List <ProcessWorkVo> procesWorkList = processWOutVo.ProcessWorkListVo.Where(p => !exceptionList.Any(p2 => p2.ProcessWorkId == p.ProcessWorkId)).ToList(); ProcessWork_dgv.AutoGenerateColumns = false; BindingSource bindingSource2 = new BindingSource(procesWorkList, null); ProcessWork_dgv.DataSource = bindingSource2; ProcessWork_dgv.ClearSelection(); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ItemProcessWorkVo inVo = (ItemProcessWorkVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Update m_item_process_work"); sqlQuery.Append(" Set "); sqlQuery.Append(" item_id = :itemid, "); sqlQuery.Append(" is_optional_process = :optionalflg, "); sqlQuery.Append(" skip_prevention_flg = :skippreventionflg, "); sqlQuery.Append(" work_order = :workorder, "); sqlQuery.Append(" process_flow_rule_id = :processflowruleid "); sqlQuery.Append(" Where "); sqlQuery.Append(" item_process_work_id = :itemprocessworkid"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("itemid", inVo.ItemId); sqlParameter.AddParameterString("optionalflg", inVo.OptionalProcessFlag); sqlParameter.AddParameterInteger("skippreventionflg", inVo.SkipPreventionFlag); sqlParameter.AddParameterInteger("workorder", inVo.WorkOrder); sqlParameter.AddParameterInteger("processflowruleid", inVo.ProcessFlowRuleId); sqlParameter.AddParameterInteger("itemprocessworkid", inVo.ItemProcessWorkId); ItemProcessWorkVo outVo = new ItemProcessWorkVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// moves grid contects up / down /// </summary> /// <param name="operationType"></param> private void MoveGridContentsDown() { BindingSource bs = new BindingSource(); bs = (BindingSource)ItemProcessWork_dgv.DataSource; int selectedIndex = ItemProcessWork_dgv.SelectedRows[0].Index; ItemProcessWorkVo itemPWVo = (ItemProcessWorkVo)ItemProcessWork_dgv.SelectedRows[0].DataBoundItem; int selectedrowindex = ItemProcessWork_dgv.SelectedCells[0].RowIndex; ItemProcessWorkVo nextItemPWVo = null; if (ItemProcessWork_dgv.Rows.Count > selectedrowindex) { nextItemPWVo = (ItemProcessWorkVo)ItemProcessWork_dgv.Rows[selectedrowindex + 1].DataBoundItem; } if (nextItemPWVo != null && (nextItemPWVo.ProcessWorkId == itemPWVo.ProcessWorkId && nextItemPWVo.ProcessWorkSeq > itemPWVo.ProcessWorkSeq)) { messageData = new MessageData("mmce00015", Properties.Resources.mmce00015); popUpMessage.ApplicationError(messageData, Text); return; } ((List <ItemProcessWorkVo>)(bs.DataSource)).Remove(itemPWVo); ((List <ItemProcessWorkVo>)(bs.DataSource)).Insert(selectedIndex + 1, itemPWVo); ItemProcessWork_dgv.DataSource = null; ItemProcessWork_dgv.DataSource = bs; ItemProcessWork_dgv.Rows[selectedIndex + 1].Selected = true; }
/// <summary> /// moves grid contects up / down /// </summary> /// <param name="operationType"></param> private void MoveGridContentsUpDown(string operationType) { BindingSource bs = new BindingSource(); bs = (BindingSource)ItemProcessWork_dgv.DataSource; int selectedIndex = ItemProcessWork_dgv.SelectedRows[0].Index; ItemProcessWorkVo itemPWVo = (ItemProcessWorkVo)ItemProcessWork_dgv.SelectedRows[0].DataBoundItem; ((List <ItemProcessWorkVo>)(bs.DataSource)).Remove(itemPWVo); if (operationType.Equals(UP)) { ((List <ItemProcessWorkVo>)(bs.DataSource)).Insert(selectedIndex - 1, itemPWVo); } else { ((List <ItemProcessWorkVo>)(bs.DataSource)).Insert(selectedIndex + 1, itemPWVo); } ItemProcessWork_dgv.DataSource = null; ItemProcessWork_dgv.DataSource = bs; if (operationType.Equals(UP)) { ItemProcessWork_dgv.Rows[selectedIndex - 1].Selected = true; } else { ItemProcessWork_dgv.Rows[selectedIndex + 1].Selected = true; } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ItemProcessWorkVo inVo = (ItemProcessWorkVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete from m_item_process_work"); sqlQuery.Append(" Where "); sqlQuery.Append(" item_id = :itemid "); //sqlQuery.Append(" and "); //sqlQuery.Append(" process_flow_rule_id = :workflowid "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("itemid", inVo.ItemId); //sqlParameter.AddParameterInteger("workflowid", inVo.ProcessFlowRuleId); ItemProcessWorkVo outVo = new ItemProcessWorkVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// event to open the updatescreen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Update_btn_Click(object sender, EventArgs e) { try { ItemProcessWorkVo outVo; if (CheckMandatory()) { this.Cursor = Cursors.WaitCursor; ItemProcessWorkVo deleteVo = new ItemProcessWorkVo { ItemId = Convert.ToInt32(ItemCd_cmb.SelectedValue.ToString()), //ProcessFlowRuleId = Convert.ToInt32(ProcessFlowRule_cmb.SelectedValue.ToString()) }; outVo = (ItemProcessWorkVo)base.InvokeCbm(new DeleteItemProcessWorkMasterMntCbm(), deleteVo, false); if (ItemProcessWork_dgv.RowCount > 0) { foreach (DataGridViewRow row in ItemProcessWork_dgv.Rows) { outVo = new ItemProcessWorkVo(); ItemProcessWorkVo itemprocessWorkInVo = new ItemProcessWorkVo { ItemProcessWorkId = Convert.ToInt32(row.Cells["colItemProcessWorkId"].Value), //ItemId = Convert.ToInt32(ItemCd_cmb.SelectedValue.ToString()), ItemId = Convert.ToInt32(row.Cells["colItemId"].Value.ToString()), ProcessWorkId = Convert.ToInt32(row.Cells["colProcessWorkId"].Value.ToString()), OptionalProcessFlag = row.Cells["colIsOptionalProcess"].Value != null && row.Cells["colIsOptionalProcess"].Value.ToString() == "True" ? "1" : "0", SkipPreventionFlag = row.Cells["colIsSkip"].Value != null && row.Cells["colIsSkip"].Value.ToString() == "True" ? "1" : "0", WorkOrder = row.Index + 1, //ProcessFlowRuleId = Convert.ToInt32(row.Cells["colProcessFlowRuleId"].Value), ProcessFlowRuleId = row.Cells["colComment"].Value != null && row.Cells["colComment"].Value.ToString() != "" ? Convert.ToInt32(processFlowRuleDatatable.Select("Comment = '" + row.Cells["colComment"].Value.ToString() + "'")[0][0].ToString()) : Convert.ToInt32(null), RegistrationUserCode = UserData.GetUserData().UserCode, FactoryCode = UserData.GetUserData().FactoryCode }; outVo = (ItemProcessWorkVo)base.InvokeCbm(new AddItemProcessWorkMasterMntCbm(), itemprocessWorkInVo, false); } } messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); this.Cursor = Cursors.Default; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ItemProcessWorkVo inVo = (ItemProcessWorkVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_item_process_work"); sqlQuery.Append(" ( "); sqlQuery.Append(" item_id, "); sqlQuery.Append(" process_work_id, "); sqlQuery.Append(" process_work_sequence, "); sqlQuery.Append(" is_optional_process, "); sqlQuery.Append(" skip_prevention_flg, "); sqlQuery.Append(" work_order, "); sqlQuery.Append(" process_flow_rule_id, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :itemid ,"); sqlQuery.Append(" :processworkid ,"); sqlQuery.Append(" :processworkseq ,"); sqlQuery.Append(" :optionalflg ,"); sqlQuery.Append(" :skippreventionflg ,"); sqlQuery.Append(" :workorder ,"); sqlQuery.Append(" :processflowruleid ,"); sqlQuery.Append(" :registrationusercode ,"); sqlQuery.Append(" :registrationdatetime ,"); sqlQuery.Append(" :factorycd "); sqlQuery.Append(" ); "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("itemid", inVo.ItemId); sqlParameter.AddParameterInteger("processworkid", inVo.ProcessWorkId); sqlParameter.AddParameterInteger("processworkseq", inVo.ProcessWorkSeq); sqlParameter.AddParameterString("optionalflg", inVo.OptionalProcessFlag); sqlParameter.AddParameterString("skippreventionflg", inVo.SkipPreventionFlag); sqlParameter.AddParameterInteger("workorder", inVo.WorkOrder); sqlParameter.AddParameterInteger("processflowruleid", inVo.ProcessFlowRuleId); sqlParameter.AddParameterString("registrationusercode", UserData.GetUserData().UserCode); sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime); sqlParameter.AddParameterString("factorycd", UserData.GetUserData().FactoryCode); ItemProcessWorkVo outVo = new ItemProcessWorkVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private ItemProcessWorkVo FormConditionVo() { ItemProcessWorkVo inVo = new ItemProcessWorkVo(); if (ItemCd_cmb.SelectedIndex > -1) { inVo.ItemId = Convert.ToInt32(ItemCd_cmb.SelectedValue); } //if (ProcessFlowRule_cmb.SelectedIndex > -1) //{ // inVo.ProcessFlowRuleId = Convert.ToInt32(ProcessFlowRule_cmb.SelectedValue); //} return(inVo); }
/// <summary> /// Add item to gridview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddProcessWork_btn_Click(object sender, EventArgs e) { if (this.ProcessWork_dgv.SelectedRows.Count > 0) { if (ItemCd_cmb.Text == string.Empty || ItemCd_cmb.SelectedIndex < 0) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, ItemCd_lbl.Text); popUpMessage.Warning(messageData, Text); ItemCd_cmb.Focus(); return; } BindingSource bs; bs = (BindingSource)ItemProcessWork_dgv.DataSource; ItemProcessWorkVo itemprcvo = new ItemProcessWorkVo { ItemProcessWorkId = 0, ProcessWorkId = Convert.ToInt32(ProcessWork_dgv.SelectedRows[0].Cells["colProcWorkId"].Value), ProcessWorkName = ProcessWork_dgv.SelectedRows[0].Cells["colProcessWork"].Value.ToString(), OptionalProcessFlag = "false", SkipPreventionFlag = "false", //Comment = ProcessFlowRule_cmb.Text, //ProcessFlowRuleId = Convert.ToInt32(ProcessFlowRule_cmb.SelectedValue), ItemId = Convert.ToInt32(ItemCd_cmb.SelectedValue.ToString()) }; if (bs != null) { ((List <ItemProcessWorkVo>)(bs.DataSource)).Add(itemprcvo); } else { List <ItemProcessWorkVo> ItemProcessWorkList = new List <ItemProcessWorkVo>(); ItemProcessWorkList.Add(itemprcvo); bs = new BindingSource(ItemProcessWorkList, null); } ItemProcessWork_dgv.DataSource = null; ItemProcessWork_dgv.DataSource = bs; ProcessWork_dgv.Rows.RemoveAt(ProcessWork_dgv.SelectedRows[0].Index); } }
/// <summary> /// Add item to gridview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddProcessWork_btn_Click(object sender, EventArgs e) { if (this.ProcessWork_dgv.SelectedRows.Count == 0) { return; } if (ItemCd_cmb.Text == string.Empty || ItemCd_cmb.SelectedIndex < 0) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, ItemCd_lbl.Text); popUpMessage.Warning(messageData, Text); ItemCd_cmb.Focus(); return; } BindingSource bs; bs = (BindingSource)ItemProcessWork_dgv.DataSource; int processworkseq = 0; if (bs != null) { List <ItemProcessWorkVo> binddata = (List <ItemProcessWorkVo>)bs.DataSource; ItemProcessWorkVo getitemprocess = binddata.Where(x => x.ProcessWorkId == Convert.ToInt32(ProcessWork_dgv.SelectedRows[0].Cells["colProcWorkId"].Value)).LastOrDefault(); if (getitemprocess != null) { processworkseq = getitemprocess.ProcessWorkSeq + 1; } } ItemProcessWorkVo itemprcvo = new ItemProcessWorkVo(); itemprcvo.ItemProcessWorkId = 0; itemprcvo.ProcessWorkId = Convert.ToInt32(ProcessWork_dgv.SelectedRows[0].Cells["colProcWorkId"].Value); itemprcvo.ProcessWorkName = ProcessWork_dgv.SelectedRows[0].Cells["colProcessWork"].Value.ToString(); itemprcvo.ProcessWorkSeq = processworkseq; itemprcvo.OptionalProcessFlag = "false"; itemprcvo.SkipPreventionFlag = "false"; //itemprcvo.Comment = ProcessFlowRule_cmb.Text; //itemprcvo.ProcessFlowRuleId = Convert.ToInt32(ProcessFlowRule_cmb.SelectedValue); itemprcvo.ItemId = Convert.ToInt32(ItemCd_cmb.SelectedValue.ToString()); if (bs != null) { ((List <ItemProcessWorkVo>)(bs.DataSource)).Add(itemprcvo); } else { List <ItemProcessWorkVo> ItemProcessWorkList = new List <ItemProcessWorkVo>(); ItemProcessWorkList.Add(itemprcvo); bs = new BindingSource(ItemProcessWorkList, null); } ItemProcessWork_dgv.DataSource = null; ItemProcessWork_dgv.DataSource = bs; //ProcessWork_dgv.Rows.RemoveAt(ProcessWork_dgv.SelectedRows[0].Index); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { ItemProcessWorkVo inVo = (ItemProcessWorkVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select ipw.item_process_work_id, ipw.item_id, ipw.process_work_id,ipw.process_work_sequence, "); sqlQuery.Append(" ipw.is_optional_process, ipw.skip_prevention_flg, "); sqlQuery.Append(" ipw.process_flow_rule_id,"); sqlQuery.Append(" li.item_name,"); sqlQuery.Append(" pw.process_work_name, pw.process_work_cd,"); sqlQuery.Append(" pfr.comment, ipw.work_order"); sqlQuery.Append(" from m_item_process_work ipw "); sqlQuery.Append(" inner join m_local_item li on ipw.item_id = li.item_id "); sqlQuery.Append(" inner join m_process_work pw on ipw.process_work_id = pw.process_work_id "); //sqlQuery.Append(" inner join m_process_flow_rule pfr on ipw.process_flow_rule_id = pfr.process_flow_rule_id"); sqlQuery.Append(" left outer join m_process_flow_rule pfr on ipw.process_flow_rule_id = pfr.process_flow_rule_id"); sqlQuery.Append(" where ipw.factory_cd = :faccd "); if (inVo.ItemId > 0) { sqlQuery.Append(" and ipw.item_id = :itemid "); } if (!string.IsNullOrEmpty(inVo.ItemCd)) { sqlQuery.Append(" and li.item_cd like :itemcd "); } if (!string.IsNullOrEmpty(inVo.ItemName)) { sqlQuery.Append(" and li.item_name like :itemname "); } if (inVo.ProcessFlowRuleId > 0) { sqlQuery.Append(" and ipw.process_flow_rule_id =:procflowruleid "); } sqlQuery.Append(" order by ipw.work_order"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.ItemId > 0) { sqlParameter.AddParameterInteger("itemid", inVo.ItemId); } if (!string.IsNullOrEmpty(inVo.ItemCd)) { sqlParameter.AddParameterString("itemcd", inVo.ItemCd); } if (!string.IsNullOrEmpty(inVo.ItemName)) { sqlParameter.AddParameterString("itemname", inVo.ItemName + "%"); } if (inVo.ProcessFlowRuleId > 0) { sqlParameter.AddParameterInteger("procflowruleid", inVo.ProcessFlowRuleId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); ItemProcessWorkVo outVo = new ItemProcessWorkVo(); while (dataReader.Read()) { ItemProcessWorkVo currOutVo = new ItemProcessWorkVo { ItemProcessWorkId = ConvertDBNull <int>(dataReader, "item_process_work_id"), ItemId = ConvertDBNull <int>(dataReader, "item_id"), ProcessWorkId = ConvertDBNull <int>(dataReader, "process_work_id"), ProcessWorkSeq = ConvertDBNull <int>(dataReader, "process_work_sequence"), ProcessFlowRuleId = ConvertDBNull <int>(dataReader, "process_flow_rule_id"), ProcessWorkCode = ConvertDBNull <string>(dataReader, "process_work_cd"), ProcessWorkName = ConvertDBNull <string>(dataReader, "process_work_name"), OptionalProcessFlag = ConvertDBNull <string>(dataReader, "is_optional_process"), SkipPreventionFlag = ConvertDBNull <string>(dataReader, "skip_prevention_flg"), Comment = ConvertDBNull <string>(dataReader, "comment"), WorkOrder = ConvertDBNull <int>(dataReader, "work_order") }; outVo.ItemProcessWorkListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }