private void fpView_CellDoubleClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e) { if (shtView.Rows.Count == 0) { return; } if (shtView.ActiveRowIndex < 0) { return; } int ActiveRow = shtView.ActiveRowIndex; NZString YearMonth = new NZString(null, shtView.Cells[ActiveRow, (int)eColView.YEAR_MONTH].Value); NZString LocationCD = new NZString(null, shtView.Cells[ActiveRow, (int)eColView.LOCATION].Value); NZString ItemCD = new NZString(null, shtView.Cells[ActiveRow, (int)eColView.ITEM_CODE].Value); NZString LotNo = new NZString(null, shtView.Cells[ActiveRow, (int)eColView.LOT_NO].Value); NZString PackNo = new NZString(null, shtView.Cells[ActiveRow, (int)eColView.PACK_NO].Value); NZInt QueryType = new NZInt(null, shtView.Cells[ActiveRow, (int)eColView.QUERY_TYPE].Value); NZDateTime BeginDate = new NZDateTime(null, dtPeriodBegin.Value); NZDateTime EndDate = new NZDateTime(null, dtPeriodEnd.Value); // Validate period date before show inventory movement InventoryOnhandInquiryValidator validator = new InventoryOnhandInquiryValidator(); try { if (chkToEndMonth.Checked) { validator.ValidatePeriodDateRange(BeginDate, EndDate); } } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); return; } INV020_InventoryMovementInquiry frmInventoryMovementInquiry = new INV020_InventoryMovementInquiry( YearMonth, LocationCD, ItemCD, LotNo, PackNo, BeginDate, EndDate, QueryType); frmInventoryMovementInquiry.ShowDialog(); }
private void LoadData(NZDateTime FromPeriod, NZDateTime ToPeriod, string keyFilter, bool validate) { try { if (validate) { if (chkToEndMonth.Checked) { // Validate period date before search data. InventoryOnhandInquiryValidator validator = new InventoryOnhandInquiryValidator(); try { validator.ValidatePeriodDateRange(FromPeriod, ToPeriod); } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); return; } } } //== Start to search data. InventoryOnhandController ctlInvent = new InventoryOnhandController(); bool GroupByItem = rdoGroupItem.Checked; int iToEndOfMonth = 1; if (chkToEndMonth.Checked) { iToEndOfMonth = 0; } else { iToEndOfMonth = 1; } //== 20091203 Add by Teerayt S. //NZString yearMonth = GetLatestYearMonthInInvOnhand(); //InventoryPeriodBIZ biz = new InventoryPeriodBIZ(); //InventoryPeriodDTO dtoPeriod = biz.LoadCurrentPeriod(); NZString yearMonth = dtPeriodBegin.Value.Value.ToString("yyyyMM").ToNZString(); //dtoPeriod.YEAR_MONTH; //== 20091203 End Add by Teerayt S. List <InventoryOnhandInquiryViewDTO> dtoView = ctlInvent.LoadInventoryOnhand(yearMonth, FromPeriod, ToPeriod, GroupByItem, iToEndOfMonth); m_dtAllData = DTOUtility.ConvertListToDataTable(dtoView); DataTable dtView = m_dtAllData.Clone(); if (keyFilter != string.Empty) { string filterString = string.Format(@" ( LOCATION LIKE '%{0}%' OR ITEM_CODE LIKE '%{0}%' OR CUSTOMER_CD LIKE '%{0}%' OR LOT_NO LIKE '%{0}%' OR PACK_NO LIKE '%{0}%' OR EXTERNAL_LOT_NO LIKE '%{0}%' OR SHORT_NAME LIKE '%{0}%' OR LAST_RECEIVE_DATE = #{0:dd/MM/yyyy}# )", keyFilter); if (!chkZeroQty.Checked) { filterString = filterString + " AND ONHAND_QTY <> 0 "; } //get only the rows you want DataRow[] results = m_dtAllData.Select(filterString, @"LOCATION,ITEM_CODE,LOT_NO,PACK_NO,EXTERNAL_LOT_NO"); //populate new destination table foreach (DataRow dr in results) { dtView.ImportRow(dr); } } else { if (!chkZeroQty.Checked) { string filterString = " ONHAND_QTY <> 0 "; //get only the rows you want DataRow[] results = m_dtAllData.Select(filterString, @"LOCATION,ITEM_CODE,LOT_NO,PACK_NO,EXTERNAL_LOT_NO"); //populate new destination table foreach (DataRow dr in results) { dtView.ImportRow(dr); } } else { foreach (DataRow dr in m_dtAllData.Rows) { dtView.ImportRow(dr); } } } fpView.DataSource = dtView; CtrlUtil.SpreadUpdateColumnSorting(shtView); } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }