private void LoadData(NZDateTime dtPeriod, string keyFilter) { try { //== Start to search data. InventoryOnhandController ctlInvent = new InventoryOnhandController(); //== 20091203 Add by Teerayt S. //NZString yearMonth = GetLatestYearMonthInInvOnhand(); NZString yearMonth = dtMonth.Value.Value.ToString("yyyyMM").ToNZString(); //== 20091203 End Add by Teerayt S. //List<InventorySummaryViewDTO> dtoView = ctlInvent.LoadInventorySummary(yearMonth); //m_dtAllData = DTOUtility.ConvertListToDataTable(dtoView); m_dtAllData = ctlInvent.LoadInventorySummary(yearMonth); FindDataFromMemory(keyFilter); CtrlUtil.SpreadUpdateColumnSorting(shtInventorySummary); } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }
private void ExportCost() { try { InventoryOnhandController ctlInvent = new InventoryOnhandController(); if (shtView.Rows.Count == 0) { return; } int row = shtView.Rows.Count; //int rowfilter= shtView.RowFilter.SheetView.Rows.Count; List <string> ItemCodes = new List <string>(); for (int i = 0; i < row; i++) { if (shtView.Cells[i, (int)eColView.ITEM_CODE].Value != null) { if (!ItemCodes.Contains(shtView.Cells[i, (int)eColView.ITEM_CODE].Value.ToString())) { ItemCodes.Add(shtView.Cells[i, (int)eColView.ITEM_CODE].Value.ToString()); } } } DataTable dtCostView = ctlInvent.GetCostView(ItemCodes); if (dtCostView == null) { return; } FarPoint.Win.Spread.FpSpread fpCost = new FarPoint.Win.Spread.FpSpread(); FarPoint.Win.Spread.SheetView shtCost = new FarPoint.Win.Spread.SheetView(); shtCost.DataSource = dtCostView; shtCost.Columns[0].CellType = CtrlUtil.CreateDateTimeCellType(); fpCost.Sheets.Add(shtCost); ExportDialog frmExport = new ExportDialog(fpCost); frmExport.DefaultExcel_Filename = Environment.CurrentDirectory + "\\Cost View.xls"; //frmExport.de frmExport.ShowDialog(this); } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }
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); } }