private void ProcessWork_lst_SelectedIndexChanged(object sender, EventArgs e) { if (isProcessListLoading) { return; } if (ProcessWork_lst.SelectedIndex < 0) { return; } if (Line_chlst.Items.Count == 0) { LoadLineListBox(); } this.Cursor = Cursors.WaitCursor; ProcessWorkLineVo inVo = new ProcessWorkLineVo(); inVo.ProcessWorkId = Convert.ToInt32(ProcessWork_lst.SelectedValue.ToString()); ProcessWorkLineVo checkVo = (ProcessWorkLineVo)base.InvokeCbm(new GetProcessWorkLineMasterMntCbm(), new ProcessWorkLineVo(), false); Line_chlst.ClearSelected(); ProcessWorkLineVo outVo = (ProcessWorkLineVo)base.InvokeCbm(new GetProcessWorkLineMasterMntCbm(), inVo, false); for (int i = 0; i < Line_chlst.Items.Count; i++) { var Line = (LineVo)Line_chlst.Items[i]; Line_chlst.SetItemChecked(i, outVo.ProcessWorkLineListVo.Exists(x => x.LineId == Line.LineId)); } this.Cursor = Cursors.Default; }
/// <summary> /// Get Line Data. /// </summary> private void LoadLineListBox() { this.Cursor = Cursors.WaitCursor; Line_chlst.DataSource = null; UserLineBuildingVo inVo = new UserLineBuildingVo(); inVo.BuildingId = Convert.ToInt32(Building_lst.SelectedValue.ToString()); try { LineBuildingMasterVo = (ValueObjectList <UserLineBuildingVo>)base.InvokeCbm(new GetUserLineBuildingMasterMntCbm(), inVo, false); } catch (Framework.ApplicationException ex) { logger.Info(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); } if (LineBuildingMasterVo == null || LineBuildingMasterVo.GetList() == null || LineBuildingMasterVo.GetList().Count == 0) { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, Line_lbl.Text); logger.Info(messageData); popUpMessage.Information(messageData, Text); Update_btn.Enabled = false; this.Cursor = Cursors.Default; return; } List <UserLineBuildingVo> FilteruserlinebuildingVo = LineBuildingMasterVo.GetList().GroupBy(t => new { t.LineId }) .Select(g => new UserLineBuildingVo { LineId = g.First().LineId, LineBuildingId = g.First().LineBuildingId, BuildingId = g.First().BuildingId, BuildingCode = g.First().BuildingCode, BuildingName = g.First().BuildingName, LineCode = g.First().LineCode, LineName = g.First().LineCode + " " + g.First().LineName, }).ToList(); if (FilteruserlinebuildingVo.Count > 0) { Line_chlst.DataSource = FilteruserlinebuildingVo.OrderBy(o => o.LineCode).ToList(); Line_chlst.DisplayMember = "LineName"; Line_chlst.ValueMember = "LineId"; Update_btn.Enabled = true; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, Line_lbl.Text); logger.Info(messageData); popUpMessage.Information(messageData, Text); Update_btn.Enabled = false; } UserLineBuildingVo chekLineIdVo; Line_chlst.ClearSelected(); if (LineBuildingMasterVo != null || LineBuildingMasterVo.GetList() != null || LineBuildingMasterVo.GetList().Count > 0) { for (int i = 0; i < Line_chlst.Items.Count; i++) { UserLineBuildingVo currline = (UserLineBuildingVo)Line_chlst.Items[i]; chekLineIdVo = LineBuildingMasterVo.GetList().Where(t => t.LineId == currline.LineId && t.UserCode == User_cmb.SelectedValue.ToString()).FirstOrDefault(); if (chekLineIdVo == null) { continue; } if (chekLineIdVo.UserLineBuildingId > 0) { Line_chlst.SetItemChecked(i, true); } } } this.Cursor = Cursors.Default; }