﻿<?xml version="1.0" encoding="utf-8"?>
<inherited BaseReport="..\Base.frx" ScriptLanguage="CSharp" DoublePass="true" ReportInfo.Created="05/15/2013 14:45:40" ReportInfo.Modified="08/03/2015 09:11:48" ReportInfo.CreatorVersion="1.6.57.0">
  <ScriptText>using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;

namespace FastReport
{
  public class ReportScript
  {

    private void Form1_Shown(object sender, EventArgs e)
    {
      cboSelection.Text = &quot;All&quot;;
      cboGroupBy.Text = &quot;All&quot;;
      cboOrderBy.Text = &quot;Description&quot;;
    }
    
    
    private void btnOk_Click(object sender, EventArgs e)
    {
      //Report.SetParameterValue(&quot;OrderBy&quot;, cboOrderBy.Text); DOES NOT WORK ?????
      
      TableDataSource tProducts = Report.GetDataSource(&quot;products&quot;) as TableDataSource;
      
      string selColumn = String.Empty;
      string orderBy1 = String.Empty;
      if (cboGroupBy.Text == &quot;All&quot;)
      {
        selColumn = &quot;ProductID AS Selection, &quot;;
        txtGroupBy.Text = String.Empty;         
      }
      else if (cboGroupBy.Text == &quot;Location&quot;)
      {
        selColumn = &quot;Location AS Selection, &quot;;
        GroupByHeader.StartNewPage = true;
        GroupByFooter.StartNewPage = true;
        orderBy1 = &quot;Selection, &quot;;
      }
      else if (cboGroupBy.Text == &quot;Sub-Location&quot;)
      {
        selColumn = &quot;SubLocation AS Selection, &quot;;
        GroupByHeader.StartNewPage = true;
        GroupByFooter.StartNewPage = true;
        orderBy1 = &quot;Selection, &quot;;
      }
      else if (cboGroupBy.Text == &quot;Category&quot;)
      {
        selColumn = &quot;Category AS Selection, &quot;;
        GroupByHeader.StartNewPage = true;
        GroupByFooter.StartNewPage = true;
        orderBy1 = &quot;Selection, &quot;;
      }
      else if (cboGroupBy.Text == &quot;Sub-Category&quot;)
      {
        selColumn = &quot;SubCategory AS Selection, &quot;;
        GroupByHeader.StartNewPage = true;
        GroupByFooter.StartNewPage = true;
        orderBy1 = &quot;Selection, &quot;;
      }
       
      string orderBy2 = String.Empty;
      if (cboOrderBy.Text == &quot;Item code&quot;)
        orderBy2 = &quot;ProductCode&quot;;      
      else if (cboOrderBy.Text == &quot;Description&quot;)      
        orderBy2 = &quot;Description&quot;;      
      else if (cboOrderBy.Text == &quot;Qty Available&quot;)
        orderBy2 = &quot;QtyAvailable&quot;;
      
      
      string selection = String.Empty;
      string excludeZeroQtys = String.Empty;
      if (chkExcludeZeroQtys.Checked) 
        excludeZeroQtys = &quot; AND QtyAvailable &lt;&gt; 0&quot;;
      
      if (cboSelection.Text == &quot;All&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: All&quot;;
        selection = &quot;ID &gt; 0&quot; + excludeZeroQtys;
      }
      else if (cboSelection.Text == &quot;Location =&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: Location = &quot; + cboLocation.Text;
        selection = &quot;Location = '&quot; + cboLocation.Text + &quot;'&quot; + excludeZeroQtys;
      }
      else if (cboSelection.Text == &quot;Sub-Location =&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: Sub-Location = &quot; + cboSubLocation.Text;
        selection = &quot;SubLocation = '&quot; + cboSubLocation.Text + &quot;'&quot; + excludeZeroQtys; 
      }
      else if (cboSelection.Text == &quot;Category =&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: Category = &quot; + cboCategory.Text;
        selection = &quot;Category = '&quot; + cboCategory.Text + &quot;'&quot; + excludeZeroQtys;
      }
      else if (cboSelection.Text == &quot;Sub-Category =&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: Sub-Category = &quot; + cboSubCategory.Text;
        selection = &quot;SubCategory = '&quot; + cboSubCategory.Text + &quot;'&quot; + excludeZeroQtys; 
      }
      else if (cboSelection.Text == &quot;Products Only&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: Products Only&quot;;
        selection = &quot;IsProduct = 1&quot; + excludeZeroQtys; 
      }
      else if (cboSelection.Text == &quot;Services Only&quot;)
      {
        txtSelectionFeedback.Text = &quot;Selection: Services Only&quot;;
        selection = &quot;IsProduct = 0&quot; + excludeZeroQtys; 
      }
      
      tProducts.SelectCommand = &quot;SELECT &quot; + selColumn + &quot; ProductCode, Description, CostPrice, SellingPrice, QtyAvailable &quot; +
        &quot;FROM products WHERE CompanyID = @CompanyID AND &quot; + selection + 
        &quot; ORDER BY &quot; + orderBy1 + orderBy2; 

      //MessageBox.Show(tProducts.SelectCommand);
      
      
    }
   
    
    
    private void cboSelection_SelectedIndexChanged(object sender, EventArgs e)
    {
      if (cboSelection.Text == &quot;Location =&quot;)
        cboLocation.Visible = true;
      else if (cboSelection.Text == &quot;Sub-Location =&quot;)
        cboSubLocation.Visible = true;
      else if (cboSelection.Text == &quot;Category =&quot;)
        cboCategory.Visible = true;
      else if (cboSelection.Text == &quot;Sub-Category =&quot;)
        cboSubCategory.Visible = true;
    }
    
    

    
    
  }
}
</ScriptText>
  <Dictionary>
    <MySqlDataConnection Name="Connection" ConnectionString="rijcmlqAxB5REKUT+dukMQH3sU+xfro0FofBDRUyaCSfcX7GxNGUjye309ffYebJwk+OhpeS4a7rwkxMHL/wX5pA4bBxw==">
      <TableDataSource Name="companies" DataType="System.Int32" Enabled="true" TableName="companies" SelectCommand="SELECT * FROM companies WHERE ID = @CompanyID">
        <Column Name="ID" DataType="System.UInt32"/>
        <Column Name="Name" DataType="System.String"/>
        <Column Name="Email" DataType="System.String"/>
        <Column Name="Address" DataType="System.String"/>
        <Column Name="RegNo" DataType="System.String"/>
        <Column Name="VATno" DataType="System.String"/>
        <Column Name="ContactNo" DataType="System.String"/>
        <Column Name="AltNo" DataType="System.String"/>
        <Column Name="FaxNo" DataType="System.String"/>
        <Column Name="CellNo" DataType="System.String"/>
        <Column Name="LogoPath" DataType="System.String"/>
        <Column Name="InvoiceStylePath" DataType="System.String"/>
        <Column Name="InvoiceSize" DataType="System.String"/>
        <Column Name="VATrate" DataType="System.String"/>
        <Column Name="BankingDetails" DataType="System.String"/>
        <CommandParameter Name="companyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
      <TableDataSource Name="Table" Alias="products" DataType="System.Int32" Enabled="true" SelectCommand="SELECT Location AS Selection, ProductCode, Description, CostPrice, SellingPrice, QtyAvailable &#13;&#10;FROM products WHERE CompanyID = @CompanyID AND Status = 'Active'&#13;&#10;&#13;&#10;">
        <Column Name="ProductCode" DataType="System.String"/>
        <Column Name="Description" DataType="System.String"/>
        <Column Name="QtyAvailable" DataType="System.Decimal"/>
        <Column Name="CostPrice" DataType="System.Decimal"/>
        <Column Name="SellingPrice" DataType="System.Decimal"/>
        <Column Name="Selection" DataType="System.String"/>
        <CommandParameter Name="CompanyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
      <TableDataSource Name="Table2" Alias="programs_config" DataType="System.Int32" Enabled="true" SelectCommand="SELECT QtyDecimalValue FROM programs_config WHERE CompanyID = @CompanyID">
        <Column Name="QtyDecimalValue" DataType="System.UInt32"/>
        <CommandParameter Name="CompanyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
      <TableDataSource Name="Table3" Alias="Categories" DataType="System.Int32" Enabled="true" SelectCommand="SELECT DISTINCT(Category) AS Category FROM products WHERE CompanyID = @CompanyID ORDER BY Category">
        <Column Name="Category" DataType="System.String"/>
        <CommandParameter Name="companyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
      <TableDataSource Name="Table4" Alias="SubCategories" DataType="System.Int32" Enabled="true" SelectCommand="SELECT DISTINCT(SubCategory) AS SubCategory FROM products WHERE CompanyID = @CompanyID ORDER BY SubCategory">
        <Column Name="SubCategory" DataType="System.String"/>
        <CommandParameter Name="companyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
      <TableDataSource Name="Table5" Alias="Locations" DataType="System.Int32" Enabled="true" SelectCommand="SELECT DISTINCT(Location) AS Location FROM products WHERE CompanyID = @CompanyID ORDER BY Location">
        <Column Name="Location" DataType="System.String"/>
        <CommandParameter Name="CompanyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
      <TableDataSource Name="Table6" Alias="SubLocations" DataType="System.Int32" Enabled="true" SelectCommand="SELECT DISTINCT(SubLocation) AS SubLocation FROM products WHERE CompanyID = @CompanyID ORDER BY SubLocation">
        <Column Name="SubLocation" DataType="System.String"/>
        <CommandParameter Name="CompanyID" DataType="254" Expression="[CompanyID]"/>
      </TableDataSource>
    </MySqlDataConnection>
    <Parameter Name="CompanyID" DataType="System.Int32"/>
    <Total Name="Total_Cost" Expression="[products.CostPrice]" Evaluator="Data1"/>
    <Total Name="Total_Selling" Expression="[products.SellingPrice]" Evaluator="Data1"/>
    <Total Name="Total_QtyAvailable" Expression="[products.QtyAvailable]" Evaluator="Data1"/>
    <Total Name="Count_Total_Items" TotalType="Count" Evaluator="Data1"/>
  </Dictionary>
  <inherited Name="Page1" RawPaperSize="9" FirstPageSource="15" OtherPagesSource="15" Columns.Count="2" Columns.Width="95" Columns.Positions="0,95">
    <inherited Name="PageHeader1">
      <inherited Name="_CompanyName"/>
      <ChildBand Name="Child1" ZOrder="-1" Top="41.8" Width="718.2" Height="132.3">
        <TextObject Name="Text31" Left="37.8" Width="359.1" Height="37.8" Text="Stock Take - List" Font="Segoe UI Light, 22pt" TextFill.Color="OliveDrab"/>
        <TextObject Name="txtSelectionFeedback" Left="37.8" Top="47.25" Width="670.95" Height="28.35" Text="All" HorzAlign="Right" Font="Segoe UI Light, 14pt" TextFill.Color="OliveDrab"/>
        <ShapeObject Name="shp2" Top="85.05" Width="718.2" Height="37.8" Border.Color="Gainsboro" Fill.Color="WhiteSmoke" Shape="RoundRectangle"/>
        <TextObject Name="txt1" Left="9.45" Top="94.5" Width="94.5" Height="18.9" Text="Item Code"/>
        <TextObject Name="txt2" Left="132.3" Top="94.5" Width="94.5" Height="18.9" Text="Description"/>
        <TextObject Name="txt3" Left="255.15" Top="94.5" Width="103.95" Height="18.9" Text="Qty Counted." HorzAlign="Right"/>
        <TextObject Name="txt4" Left="368.55" Top="94.5" Width="94.5" Height="18.9" Text="Item Code"/>
        <TextObject Name="txt5" Left="491.4" Top="94.5" Width="94.5" Height="18.9" Text="Description"/>
        <TextObject Name="txt6" Left="614.25" Top="94.5" Width="103.95" Height="18.9" Text="Qty Counted." HorzAlign="Right"/>
      </ChildBand>
    </inherited>
    <GroupHeaderBand Name="GroupByHeader" ZOrder="0" Top="178.1" Width="359.1" Height="37.8" CanGrow="true" CanShrink="true" RepeatOnEveryPage="true" Condition="[products.Selection]" SortOrder="None">
      <TextObject Name="txtGroupBy" Left="9.45" Width="340.2" Height="28.35" CanGrow="true" CanShrink="true" Text="[products.Selection]" Font="Segoe UI Light, 14pt" TextFill.Color="OliveDrab"/>
      <DataBand Name="Data1" Top="219.9" Width="359.1" Height="18.9" CanGrow="true" CanShrink="true" AfterDataEvent="Data1_AfterData" DataSource="Table">
        <TextObject Name="Text4" Left="9.45" Width="113.4" Height="18.9" Cursor="Hand" Hyperlink.Kind="DetailPage" CanGrow="true" CanShrink="true" ClickEvent="Text4_Click" Text="[products.ProductCode]" Font="Arial, 9pt" Trimming="EllipsisCharacter"/>
        <TextObject Name="Text5" Left="132.3" Width="170.1" Height="18.9" CanGrow="true" CanShrink="true" Text="[products.Description]" Font="Arial, 9pt"/>
        <TextObject Name="txtQty" Left="302.4" Width="56.7" Height="18.9" CanGrow="true" CanShrink="true" Text="______" HorzAlign="Right" WordWrap="false" Font="Arial, 9pt" Trimming="EllipsisCharacter"/>
      </DataBand>
      <GroupFooterBand Name="GroupByFooter" Top="242.8" Width="359.1" Height="28.35" CanGrow="true" CanShrink="true"/>
    </GroupHeaderBand>
    <ReportSummaryBand Name="ReportSummary1" ZOrder="-1" Top="275.15" Width="359.1" Height="47.25">
      <ShapeObject Name="Shape8" Top="9.45" Width="359.1" Height="37.8" Border.Color="Gainsboro" Fill.Color="WhiteSmoke" Shape="RoundRectangle"/>
      <TextObject Name="Text30" Left="189" Top="18.9" Width="94.5" Height="18.9" Text="[Count_Total_Items]"/>
      <TextObject Name="Text33" Top="18.9" Width="179.55" Height="18.9" Text="Total Items:" HorzAlign="Right" TextFill.Color="DimGray"/>
    </ReportSummaryBand>
    <PageFooterBand Name="PageFooter1" ZOrder="-1" Top="326.4" Width="718.2" Height="37.8">
      <TextObject Name="Text36" Left="9.45" Top="9.45" Width="132.3" Height="18.9" Text="[PageNofM]" Font="Arial, 9pt" TextFill.Color="DimGray"/>
      <TextObject Name="Text79" Left="434.7" Top="9.45" Width="94.5" Height="18.9" Text="Print Date:" HorzAlign="Right" TextFill.Color="DimGray"/>
      <TextObject Name="Text78" Left="538.65" Top="9.45" Width="160.65" Height="18.9" Text="[Date]" TextFill.Color="DimGray"/>
    </PageFooterBand>
  </inherited>
  <DialogPage Name="Form1" ZOrder="1" Width="642" Height="466" AcceptButton="btnOk" CancelButton="btnCancel" ShownEvent="Form1_Shown">
    <ButtonControl Name="btnOk" Left="446" Top="367" Height="40" Anchor="Bottom, Right" Font="Segoe UI Light, 11pt" TabIndex="0" Text="OK" ClickEvent="btnOk_Click" DialogResult="OK"/>
    <ButtonControl Name="btnCancel" Left="529" Top="367" Height="40" Anchor="Bottom, Right" Font="Segoe UI Light, 11pt" TabIndex="1" Text="Cancel" DialogResult="Cancel"/>
    <LabelControl Name="Label3" Left="24" Top="24" Width="194" Height="37" Font="Segoe UI Light, 20pt" ForeColor="OliveDrab" TabIndex="6" Text="Stock Take - List"/>
    <ComboBoxControl Name="cboOrderBy" Left="224" Top="240" Width="233" Height="28" Font="Segoe UI Light, 11pt" TabIndex="7" ClickEvent="" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="20" ItemsText="Item code&#13;&#10;Description&#13;&#10;Qty Available"/>
    <LabelControl Name="Label4" Left="68" Top="244" Width="116" Height="20" Font="Segoe UI Light, 11pt" TabIndex="5" Text="Order records by"/>
    <ComboBoxControl Name="cboSelection" Left="224" Top="100" Width="233" Height="28" Font="Segoe UI Light, 11pt" TabIndex="7" ClickEvent="" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="20" ItemsText="All&#13;&#10;Location =&#13;&#10;Sub-Location =&#13;&#10;Category =&#13;&#10;Sub-Category =&#13;&#10;Products Only&#13;&#10;Services Only" SelectedIndexChangedEvent="cboSelection_SelectedIndexChanged"/>
    <LabelControl Name="Label5" Left="68" Top="104" Width="65" Height="20" Font="Segoe UI Light, 11pt" TabIndex="5" Text="Selection"/>
    <ComboBoxControl Name="cboCategory" Left="224" Top="140" Width="233" Height="26" Visible="false" Font="Tahoma, 11pt" TabIndex="8" DataColumn="Categories.Category" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="18"/>
    <ComboBoxControl Name="cboSubCategory" Left="224" Top="140" Width="233" Height="26" Visible="false" Font="Tahoma, 11pt" TabIndex="8" DataColumn="SubCategories.SubCategory" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="18"/>
    <CheckBoxControl Name="chkExcludeZeroQtys" Left="212" Top="292" Width="321" Font="Segoe UI Light, 11pt" TabIndex="9" Text="Do not show items where the Qty Available = 0"/>
    <ComboBoxControl Name="cboGroupBy" Left="224" Top="188" Width="233" Height="28" Font="Segoe UI Light, 11pt" TabIndex="7" ClickEvent="" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="20" ItemsText="All&#13;&#10;Location&#13;&#10;Sub-Location&#13;&#10;Category&#13;&#10;Sub-Category"/>
    <LabelControl Name="Label6" Left="68" Top="192" Width="118" Height="20" Font="Segoe UI Light, 11pt" TabIndex="5" Text="Group records by"/>
    <ComboBoxControl Name="cboLocation" Left="224" Top="140" Width="233" Height="26" Visible="false" Font="Tahoma, 11pt" TabIndex="8" DataColumn="Locations.Location" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="18"/>
    <ComboBoxControl Name="cboSubLocation" Left="224" Top="140" Width="233" Height="26" Visible="false" Font="Tahoma, 11pt" TabIndex="8" DataColumn="SubLocations.SubLocation" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="18"/>
  </DialogPage>
</inherited>
