private void CallUngroupTrades() { try { Int32 tradeId = 0; int updateRowCounter = 0; GridView view = gridViewSummary; if (view.SelectedRowsCount > 0) { //Get the list ahead of time, since the foreach code changes the list's contents/order int[] selectedRows = view.GetSelectedRows(); List<DataRow> rows = new List<DataRow>(); foreach (int rowHandle in selectedRows) rows.Add(view.GetDataRow(rowHandle)); List<Int32> tradeIdList = new List<Int32>(); foreach (DataRow rowSummary in rows) { tradeId = Convert.ToInt32(rowSummary["TradeId"]); tradeIdList.Add(tradeId); updateRowCounter++; } if (updateRowCounter > 0) { TradeGroupDal tradeGroupDal = new TradeGroupDal(sqlConnectionStr); tradeGroupDal.Ungroup(tradeIdList); } } } catch (Exception ex) { throw new Exception("An error occurred while processing the selected row(s) for trade ungroup." + Environment.NewLine + "Error CNF-079 in " + FORM_NAME + ".CallUngroupTrades(): " + ex.Message); } }
private void CallGroupTrades(string AGroupCode) { try { string tradeId = ""; string groupXref = ""; int updateRowCounter = 0; GridView view = gridViewSummary; if (view.SelectedRowsCount > 0) { //Get the list ahead of time, since the foreach code changes the list's contents/order int[] selectedRows = view.GetSelectedRows(); List<DataRow> rows = new List<DataRow>(); foreach (int rowHandle in selectedRows) rows.Add(view.GetDataRow(rowHandle)); List<TradeGroupDto> tradeGroupList = new List<TradeGroupDto>(); TradeGroupDto tradeGroupDto = null; foreach (DataRow rowSummary in rows) { tradeId = rowSummary["TradeId"].ToString(); groupXref = rowSummary["GroupXref"].ToString(); tradeGroupDto = new TradeGroupDto(); tradeGroupDto.TradeId = Int32.Parse(tradeId); tradeGroupDto.Xref = AGroupCode; tradeGroupList.Add(tradeGroupDto); updateRowCounter++; } if (updateRowCounter > 0) { TradeGroupDal tradeGroupDal = new TradeGroupDal(sqlConnectionStr); tradeGroupDal.Group(tradeGroupList); } } } catch (Exception ex) { throw new Exception("An error occurred while processing the selected row(s) for trade group: " + AGroupCode + "." + Environment.NewLine + "Error CNF-077 in " + FORM_NAME + ".CallGroupTrades(): " + ex.Message); } }