/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(LineItemCycleTimeVo conditionInVo) { StartProgress(Properties.Resources.mmci00009); LineItem_dgv.DataSource = null; ValueObjectList <LineItemCycleTimeVo> outVo = null; try { outVo = (ValueObjectList <LineItemCycleTimeVo>)base.InvokeCbm(getLineItemCycleTimeMasterCbm, conditionInVo, false); } catch (Framework.ApplicationException exception) { CompleteProgress(); popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } CompleteProgress(); LineItem_dgv.AutoGenerateColumns = false; if (outVo == null || outVo.GetList() == null || outVo.GetList().Count == 0) { SapItem_cmb.DataSource = null; SapItem_cmb.SelectedIndex = -1; SapItem_cmb.Text = string.Empty; return; } LineItem_dgv.DataSource = outVo.GetList(); if (SapItem_cmb.SelectedIndex > -1) { // do nothing } else { SapItem_cmb.DataSource = null; SapItem_cmb.DisplayMember = "SapItemCode"; SapItem_cmb.ValueMember = "SapItemCode"; SapItem_cmb.DataSource = outVo.GetList(); SapItem_cmb.SelectedIndex = -1; } LineItem_dgv.ClearSelection(); }
/// <summary> /// binds datasource /// </summary> /// <param name="outVo"></param> private void BindDataSource(List <LineItemCycleTimeVo> outVo) { LineItem_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo, null); if (bindingSource1 != null && bindingSource1.Count > 0) { LineItem_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //"Department" logger.Info(messageData); popUpMessage.Information(messageData, Text); } LineItem_dgv.ClearSelection(); }
/// <summary> /// Item code search click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ItemSearch_btn_Click(object sender, EventArgs e) { ItemCodeSearchForm frm = new ItemCodeSearchForm(); frm.ShowDialog(); if (frm.sapItemSearchVo != null && frm.sapItemSearchVo.GetList() != null && frm.sapItemSearchVo.GetList().Count > 0) { ValueObjectList <SapItemSearchVo> sapItemSearchVo = frm.sapItemSearchVo; sapItemSearchVo.GetList().ForEach(v => v.SapItemName = v.SapItemCode + " - " + v.SapItemName); ValueObjectList <LineItemCycleTimeVo> sapItemVo = new ValueObjectList <LineItemCycleTimeVo>(); foreach (SapItemSearchVo itmVo in sapItemSearchVo.GetList()) { LineItemCycleTimeVo sapItmVo = new LineItemCycleTimeVo(); sapItmVo.SapItemCode = itmVo.SapItemCode; sapItemVo.add(sapItmVo); } ValueObjectList <LineItemCycleTimeVo> grdCycleVo = new ValueObjectList <LineItemCycleTimeVo>(); ValueObjectList <LineItemCycleTimeVo> itmCycleVo = new ValueObjectList <LineItemCycleTimeVo>(); if ((List <LineItemCycleTimeVo>)LineItem_dgv.DataSource != null) { itmCycleVo.SetNewList((List <LineItemCycleTimeVo>)LineItem_dgv.DataSource); } if (itmCycleVo != null && itmCycleVo.GetList() != null && itmCycleVo.GetList().Count > 0) { List <string> sapitemlist = itmCycleVo.GetList().Select(v => v.SapItemCode).ToList(); List <LineItemCycleTimeVo> selectedItem = sapItemVo.GetList().Where(x => !sapitemlist.Contains(x.SapItemCode)).ToList(); itmCycleVo.GetList().AddRange(selectedItem); } else { itmCycleVo.GetList().AddRange(sapItemVo.GetList()); } grdCycleVo.SetNewList(itmCycleVo.GetList().Where(x => !String.IsNullOrWhiteSpace(x.SapItemCode)) .Select(x => new LineItemCycleTimeVo { SapItemCode = x.SapItemCode, StdCycleTimeNull = x.StdCycleTimeNull }) .GroupBy(x => x.SapItemCode).Select(x => x.FirstOrDefault()).Distinct().ToList()); LineItem_dgv.AutoGenerateColumns = false; LineItem_dgv.DataSource = null; LineItem_dgv.DataSource = grdCycleVo.GetList(); LineItem_dgv.ClearSelection(); ValueObjectList <LineItemCycleTimeVo> cmbCycleVo = new ValueObjectList <LineItemCycleTimeVo>(); if ((List <LineItemCycleTimeVo>)LineItem_dgv.DataSource != null) { cmbCycleVo.SetNewList((List <LineItemCycleTimeVo>)LineItem_dgv.DataSource); if ((List <LineItemCycleTimeVo>)SapItem_cmb.DataSource != null) { cmbCycleVo.GetList().AddRange((List <LineItemCycleTimeVo>)SapItem_cmb.DataSource); } } SapItem_cmb.DataSource = null; SapItem_cmb.DisplayMember = "SapItemCode"; SapItem_cmb.ValueMember = "SapItemCode"; SapItem_cmb.DataSource = cmbCycleVo.GetList().Where(x => !String.IsNullOrWhiteSpace(x.SapItemCode)) .Select(x => new LineItemCycleTimeVo { SapItemCode = x.SapItemCode, StdCycleTimeNull = x.StdCycleTimeNull }) .GroupBy(x => x.SapItemCode).Select(x => x.FirstOrDefault()).Distinct().ToList(); SapItem_cmb.SelectedIndex = -1; } }