protected void Button1_Click(object sender, EventArgs e) { System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); GRN_BL objGrn = new GRN_BL(); rptWBServiceProvider rpt = new rptWBServiceProvider(); Guid warehouseId = new Guid(cboWarehouse.SelectedValue); int wbServiceProviderId = cboWBServiceProvider.SelectedIndex == 0 ? -2 : int.Parse(cboWBServiceProvider.SelectedValue); DateTime startDate = string.IsNullOrEmpty(txtStartDate.Text) ? DateTime.Parse("1/1/2010") : DateTime.Parse(txtStartDate.Text); DateTime endDate = string.IsNullOrEmpty(txtEndDate.Text) ? DateTime.Now : DateTime.Parse(txtEndDate.Text); int serviceType = int.Parse(cboServiceType.SelectedValue); DataTable dt = objGrn.GetWBServiceProviderReport(warehouseId, wbServiceProviderId, startDate, endDate, serviceType); decimal sumNumberOfBags, sumNetWeight; int rowsCount = dt.Rows.Count; string NoOfRegords = ""; if (rowsCount == 0) { Messages1.SetMessage("No record found with specified criteria.", WarehouseApplication.Messages.MessageType.Warning); WebViewer1.ClearCachedReport(); return; } else { sumNumberOfBags = decimal.Parse(dt.Compute("Sum(NumberOfBags)", "").ToString()); sumNetWeight = decimal.Parse(dt.Compute("Sum(NetWeight)", "").ToString()); NoOfRegords = rowsCount == 1 ? "1 record found." : rowsCount + " records found."; Messages1.SetMessage(NoOfRegords, WarehouseApplication.Messages.MessageType.Success); rpt.SumNumberOfBags = sumNumberOfBags; rpt.SumNetWeight = sumNetWeight; } rpt.Warehouse = cboWarehouse.SelectedItem.Text; rpt.WBServiceProvider = cboWBServiceProvider.SelectedIndex == 0 ? "All" : cboWBServiceProvider.SelectedItem.Text; rpt.DateFrom = string.IsNullOrEmpty(txtStartDate.Text) ? "No Limit" : txtStartDate.Text; rpt.DateTo = string.IsNullOrEmpty(txtEndDate.Text) ? "Present Date" : txtEndDate.Text; rpt.DataSource = dt; rpt.Run(); if (this.xlsExport1 == null) { this.xlsExport1 = new DataDynamics.ActiveReports.Export.Xls.XlsExport(); } // this.xlsExport1.MinColumnWidth = (float)(0.5); this.xlsExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition", "inline; filename=MyExport.xls"); Response.BinaryWrite(m_stream.ToArray()); Response.End(); }
protected void btnGenerate_Click(object sender, EventArgs e) { try { Messages1.ClearMessage(); GRN_BL objGrn = new GRN_BL(); rptWBServiceProvider rpt = new rptWBServiceProvider(); Guid warehouseId = new Guid(cboWarehouse.SelectedValue); int wbServiceProviderId = cboWBServiceProvider.SelectedIndex == 0 ? -2 : int.Parse(cboWBServiceProvider.SelectedValue); DateTime startDate = string.IsNullOrEmpty(txtStartDate.Text) ? DateTime.Parse("1/1/2010") : DateTime.Parse(txtStartDate.Text); DateTime endDate = string.IsNullOrEmpty(txtEndDate.Text) ? DateTime.Now : DateTime.Parse(txtEndDate.Text); int serviceType = int.Parse(cboServiceType.SelectedValue); DataTable dt = objGrn.GetWBServiceProviderReport(warehouseId, wbServiceProviderId, startDate, endDate, serviceType); decimal sumNumberOfBags, sumNetWeight; int rowsCount = dt.Rows.Count; string NoOfRegords = ""; if (rowsCount == 0) { Messages1.SetMessage("No record found with specified criteria.", WarehouseApplication.Messages.MessageType.Warning); WebViewer1.ClearCachedReport(); return; } else { sumNumberOfBags = decimal.Parse(dt.Compute("Sum(NumberOfBags)", "").ToString()); sumNetWeight = decimal.Parse(dt.Compute("Sum(NetWeight)", "").ToString()); NoOfRegords = rowsCount == 1 ? "1 record found." : rowsCount + " records found."; Messages1.SetMessage(NoOfRegords, WarehouseApplication.Messages.MessageType.Success); rpt.SumNumberOfBags = sumNumberOfBags; rpt.SumNetWeight = sumNetWeight; } rpt.Warehouse = cboWarehouse.SelectedItem.Text; rpt.WBServiceProvider = cboWBServiceProvider.SelectedIndex == 0 ? "All" : cboWBServiceProvider.SelectedItem.Text; rpt.DateFrom = string.IsNullOrEmpty(txtStartDate.Text) ? "No Limit" : txtStartDate.Text; rpt.DateTo = string.IsNullOrEmpty(txtEndDate.Text) ? "Present Date" : txtEndDate.Text; rpt.DataSource = dt; WebViewer1.Report = rpt; } catch (Exception ex) { Messages1.SetMessage(ex.Message, WarehouseApplication.Messages.MessageType.Error); } }
protected void btnGenerate_Click(object sender, EventArgs e) { try { GRN_BL objGrn = new GRN_BL(); rptStockBalance rpt = new rptStockBalance(); Guid warehouse = new Guid(cboWarehouse.SelectedValue); Guid shed = new Guid(cboShed.SelectedValue); Guid LIC = new Guid(cboLIC.SelectedValue); DateTime startDate = string.IsNullOrEmpty(txtStartDate.Text) ? DateTime.Parse("1/1/2010") : DateTime.Parse(txtStartDate.Text); DateTime endDate = string.IsNullOrEmpty(txtEndDate.Text) ? DateTime.Now : DateTime.Parse(txtEndDate.Text); TimeSpan span = endDate.Subtract(startDate); if (span.Days > 31) { Messages1.SetMessage("Date interval should not exceed one Month", WarehouseApplication.Messages.MessageType.Warning); return; } DataTable dt = objGrn.GetStockBalanceReport(warehouse, shed, LIC, startDate, endDate); DataTable dtb = objGrn.GetStockBalanceReportGIN(warehouse, shed, LIC, startDate, endDate); if (dt.Rows.Count == 0 && dtb.Rows.Count == 0) { Messages1.SetMessage("No record found with specified criteria.", WarehouseApplication.Messages.MessageType.Warning); WebViewer1.ClearCachedReport(); return; } string record = ((dt.Rows.Count + dtb.Rows.Count) == 1) ? "record found with specified criteria." : "records found with specified criteria."; if (dt.Rows.Count != 0 && dtb.Rows.Count != 0) { Messages1.SetMessage(dt.Rows.Count + " Unloading and " + dtb.Rows.Count + " Loading " + record, WarehouseApplication.Messages.MessageType.Success); } else if (dt.Rows.Count != 0 && dtb.Rows.Count == 0) { Messages1.SetMessage(dt.Rows.Count + " Unloading " + record, WarehouseApplication.Messages.MessageType.Success); } else { Messages1.SetMessage(dtb.Rows.Count + " Loading " + record, WarehouseApplication.Messages.MessageType.Success); } rpt.dtbl = dtb; rpt.SumNumberOfBags = dt.Compute("Sum(GRNNumberOfBags)", ""); rpt.SumNumberOfRebagging = dt.Compute("Sum(RebagingQuantity)", ""); rpt.SumNumberOfNetWeight = dt.Compute("Sum(NetWeight)", ""); rpt.BagSum = dtb.Compute("Sum(NoOfBags)", ""); rpt.RebaggingSum = dtb.Compute("Sum(NoOfRebags)", ""); rpt.NetWeightSum = dtb.Compute("Sum(NetWeight)", ""); rpt.AdjustmentBagSum = dtb.Compute("Sum(BagAdjustment)", ""); rpt.AdjustmentWeightSum = dtb.Compute("Sum(WeightAdjustment)", ""); rpt.Warehouse = cboWarehouse.SelectedItem.Text; rpt.Shed = cboShed.SelectedItem.Text; rpt.LIC = cboLIC.SelectedItem.Text; rpt.DateFrom = string.IsNullOrEmpty(txtStartDate.Text) ? "No Limit" : txtStartDate.Text; rpt.DateTo = string.IsNullOrEmpty(txtEndDate.Text) ? "No Limit" : txtEndDate.Text; rpt.DataSource = dt; WebViewer1.Report = rpt; } catch { Messages1.SetMessage("Unable to get data, please try again.", WarehouseApplication.Messages.MessageType.Error); } }