﻿<?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/18/2015 15:07:33" 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 btnOk_Click(object sender, EventArgs e)
    {
      Report.SetParameterValue(&quot;FromDate&quot;, dtpFromDate.Value.ToString(&quot;yyyy-MM-dd&quot;));
      Report.SetParameterValue(&quot;ToDate&quot;, dtpToDate.Value.ToString(&quot;yyyy-MM-dd&quot;));
      //Report.SetParameterValue(&quot;OrderBy&quot;, cboOrderBy.Text); DOES NOT WORK ?????
      
      TableDataSource tProducts = Report.GetDataSource(&quot;item_maintenance&quot;) as TableDataSource; 
      string orderBy = String.Empty;
      if (cboOrderBy.Text == &quot;Item code&quot;)
        orderBy = &quot;ProductCode&quot;;      
      else if (cboOrderBy.Text == &quot;Description&quot;)      
        orderBy = &quot;Description&quot;;      
      else if (cboOrderBy.Text == &quot;Qty Difference&quot;)
        orderBy = &quot;QtyDiff&quot;;
      tProducts.SelectCommand = tProducts.SelectCommand.ToString().Replace(&quot;@OrderBy&quot;, orderBy);
      
      
    }
   
    

    private void Form1_Shown(object sender, EventArgs e)
    {
      dtpFromDate.Text = System.DateTime.Now.ToString(&quot;d MMMM yyy&quot;);
      dtpToDate.Text = System.DateTime.Now.ToString(&quot;d MMMM yyy&quot;);
      
      cboOrderBy.Text = &quot;Item code&quot;;
    }

    private void Data1_AfterData(object sender, EventArgs e)
    {
      //Qty Column format      
      int decimalValue = Convert.ToInt32(Report.GetColumnValue(&quot;programs_config.QtyDecimalValue&quot;));
      decimal qtyVal = 0; 
      if (Decimal.TryParse(txtQtyAvailable.Text, out qtyVal))
      {
        txtQtyAvailable.Text = String.Format(&quot;{0:F&quot; + decimalValue + &quot;}&quot;, qtyVal);
      }
      if (Decimal.TryParse(txtQtyFound.Text, out qtyVal))
      {
        txtQtyFound.Text = String.Format(&quot;{0:F&quot; + decimalValue + &quot;}&quot;, qtyVal);
      }
      if (Decimal.TryParse(txtQtyDiff.Text, out qtyVal))
      {
        txtQtyDiff.Text = String.Format(&quot;{0:F&quot; + decimalValue + &quot;}&quot;, qtyVal);
      }
      
    }

    private void ReportSummary1_AfterData(object sender, EventArgs e)
    {
      //total Qty Column format      
      int decimalValue = Convert.ToInt32(Report.GetColumnValue(&quot;programs_config.QtyDecimalValue&quot;));
      decimal qtyVal = 0; 
      if (Decimal.TryParse(txtQtyDiffTotal.Text, out qtyVal))
      {
        txtQtyDiffTotal.Text = String.Format(&quot;{0:F&quot; + decimalValue + &quot;}&quot;, qtyVal);
      }
      
    }

    private void GroupFooter1_AfterData(object sender, EventArgs e)
    {
      //total Qty Column format      
      int decimalValue = Convert.ToInt32(Report.GetColumnValue(&quot;programs_config.QtyDecimalValue&quot;));
      decimal qtyVal = 0; 
      if (Decimal.TryParse(txtQtyDiffSubTot.Text, out qtyVal))
      {
        txtQtyDiffSubTot.Text = String.Format(&quot;{0:F&quot; + decimalValue + &quot;}&quot;, qtyVal);
      }
    }
  }
}
</ScriptText>
  <Dictionary>
    <MySqlDataConnection Name="Connection" ConnectionString="rijcmlqmUGi0DHzhik04BO5+uxHPNJg6XdWlo9sfl3oNLbLcC5ELgVy3yM4U7/vviW/yU/VlCYnkUjA+BNt9VEI/Ru/Vsarm4JmZZziQHhKf0ENT5o=">
      <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="item_maintenance" DataType="System.Int32" Enabled="true" SelectCommand="SELECT `Date`, ProductCode, Description, SUM(ABS(QtyFound - QtyAvailable) * CostPrice) AS CostPrice, &#13;&#10;SUM(ABS(QtyFound - QtyAvailable) * SellingPrice) AS SellingPrice, SUM(QtyAvailable) AS QtyAvailable, &#13;&#10;SUM(QtyFound) AS QtyFound, SUM(QtyFound - QtyAvailable) AS QtyDiff, Reason, IF(LEFT(Reason, 6) = 'Linked', '', Note) AS Note1, `User` &#13;&#10;FROM item_maintenance &#13;&#10;WHERE CompanyID = @CompanyID &#13;&#10;AND DATE_FORMAT(`Date`,'%Y-%m-%d') BETWEEN DATE_FORMAT(@FromDate,'%Y-%m-%d') AND DATE_FORMAT(@ToDate,'%Y-%m-%d') &#13;&#10;AND LEFT(Reason, 6) &lt;&gt; 'Linked' &#13;&#10;GROUP BY Reason, Note1, ProductCode &#13;&#10;ORDER BY @OrderBy&#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="QtyFound" DataType="System.Decimal"/>
        <Column Name="QtyDiff" DataType="System.Decimal"/>
        <Column Name="Reason" DataType="System.String"/>
        <Column Name="User" DataType="System.String"/>
        <Column Name="Date" DataType="System.DateTime"/>
        <Column Name="Note1" Alias="Note" DataType="System.String"/>
        <CommandParameter Name="CompanyID" DataType="254" Expression="[CompanyID]"/>
        <CommandParameter Name="orderBy" DataType="254"/>
        <CommandParameter Name="FromDate" DataType="254" Expression="[FromDate]"/>
        <CommandParameter Name="ToDate" DataType="254" Expression="[ToDate]"/>
      </TableDataSource>
      <TableDataSource Name="Table1" 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>
    </MySqlDataConnection>
    <Parameter Name="CompanyID" DataType="System.Int32"/>
    <Parameter Name="OrderBy" DataType="System.String"/>
    <Parameter Name="FromDate" DataType="System.String"/>
    <Parameter Name="ToDate" DataType="System.String"/>
    <Total Name="Count_Total_Items" TotalType="Count" Evaluator="Data1" ResetAfterPrint="false"/>
    <Total Name="SubTot_QtyDiff" Expression="[item_maintenance.QtyDiff]" Evaluator="Data1" PrintOn="GroupFooter1"/>
    <Total Name="SubTot_Cost" Expression="[item_maintenance.CostPrice]" Evaluator="Data1" PrintOn="GroupFooter1"/>
    <Total Name="SubTot_Retail" Expression="[item_maintenance.SellingPrice]" Evaluator="Data1" PrintOn="GroupFooter1"/>
    <Total Name="Total_Diff" Expression="[item_maintenance.QtyDiff]" Evaluator="Data1" PrintOn="ReportSummary1"/>
    <Total Name="Total_Cost" Expression="[item_maintenance.CostPrice]" Evaluator="Data1" PrintOn="ReportSummary1"/>
    <Total Name="Total_Selling" Expression="[item_maintenance.SellingPrice]" Evaluator="Data1" PrintOn="ReportSummary1"/>
  </Dictionary>
  <inherited Name="Page1" Landscape="true" PaperWidth="297" PaperHeight="210" RawPaperSize="9" FirstPageSource="15" OtherPagesSource="15">
    <inherited Name="PageHeader1" Width="1047.06">
      <inherited Name="_CompanyName"/>
      <ChildBand Name="Child1" ZOrder="-1" Top="41.8" Width="1047.06" Height="151.2">
        <ShapeObject Name="Shape7" Left="37.8" Top="75.6" Width="992.25" Height="66.15" Border.Color="Gainsboro" Fill.Color="WhiteSmoke" Shape="RoundRectangle"/>
        <TextObject Name="Text8" Left="812.7" Top="113.4" Width="94.5" Height="18.9" Text="Cost Price" HorzAlign="Right"/>
        <TextObject Name="Text10" Left="916.65" Top="113.4" Width="94.5" Height="18.9" Text="Selling Excl" HorzAlign="Right"/>
        <TextObject Name="Text18" Left="245.7" Top="113.4" Width="94.5" Height="18.9" Text="Description"/>
        <TextObject Name="Text19" Left="94.5" Top="113.4" Width="141.75" Height="18.9" Text="Item Code"/>
        <TextObject Name="Text21" Left="595.35" Top="94.5" Width="66.15" Height="37.8" Text="Qty Avail." HorzAlign="Right"/>
        <TextObject Name="Text31" Left="37.8" Top="9.45" Width="359.1" Height="56.7" Text="Item Maintenance" Font="Segoe UI Light, 22pt" TextFill.Color="OliveDrab"/>
        <TextObject Name="Text1" Left="841.05" Top="18.9" Width="189" Height="18.9" Text="[FromDate]" Format="Custom" Format.Format="d MMMM yyy"/>
        <TextObject Name="Text3" Left="841.05" Top="47.25" Width="189" Height="18.9" Text="[ToDate]" Format="Custom" Format.Format="d MMMM yyy"/>
        <TextObject Name="Text22" Left="727.65" Top="18.9" Width="94.5" Height="18.9" Text="From Date:" HorzAlign="Right" TextFill.Color="DimGray"/>
        <TextObject Name="Text23" Left="727.65" Top="47.25" Width="94.5" Height="18.9" Text="To Date:" HorzAlign="Right" TextFill.Color="DimGray"/>
        <TextObject Name="Text13" Left="670.95" Top="94.5" Width="66.15" Height="37.8" Text="Qty Found" HorzAlign="Right"/>
        <TextObject Name="Text15" Left="746.55" Top="94.5" Width="56.7" Height="37.8" Text="Qty Diff." HorzAlign="Right"/>
        <TextObject Name="Text82" Left="56.7" Top="85.05" Width="141.75" Height="18.9" Text="Reason"/>
        <TextObject Name="Text83" Left="831.6" Top="94.5" Width="75.6" Height="18.9" Text="Total" HorzAlign="Center"/>
        <TextObject Name="Text84" Left="926.1" Top="94.5" Width="85.05" Height="18.9" Text="Total" HorzAlign="Center"/>
      </ChildBand>
    </inherited>
    <GroupHeaderBand Name="GroupHeader1" ZOrder="0" Top="197" Width="1047.06" Height="18.9" Condition="[item_maintenance.Reason]">
      <TextObject Name="Text6" Left="56.7" Width="283.5" Height="18.9" Text="[item_maintenance.Reason]" Font="Arial, 10pt, style=Bold"/>
      <DataBand Name="Data1" Top="219.9" Width="1047.06" Height="94.5" CanGrow="true" CanShrink="true" AfterDataEvent="Data1_AfterData" DataSource="Table">
        <TextObject Name="Text4" Left="94.5" Width="141.75" Height="18.9" Cursor="Hand" Hyperlink.Kind="DetailPage" ClickEvent="Text4_Click" Text="[item_maintenance.ProductCode]"/>
        <TextObject Name="Text5" Left="245.7" Width="330.75" Height="18.9" Text="[item_maintenance.Description]" WordWrap="false"/>
        <TextObject Name="Text7" Left="812.7" Width="94.5" Height="18.9" Text="[item_maintenance.CostPrice]" Format="Number" Format.UseLocale="true" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
        <TextObject Name="Text9" Left="916.65" Width="94.5" Height="18.9" Text="[item_maintenance.SellingPrice]" Format="Number" Format.UseLocale="false" Format.DecimalDigits="2" Format.DecimalSeparator="." Format.GroupSeparator=" " Format.NegativePattern="1" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
        <TextObject Name="txtQtyAvailable" Left="585.9" Width="75.6" Height="18.9" Text="[item_maintenance.QtyAvailable]" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
        <TextObject Name="Text11" Left="245.7" Top="18.9" Width="765.45" Height="66.15" CanGrow="true" CanShrink="true" Text="[item_maintenance.Note]" Font="Arial, 10pt, style=Italic"/>
        <TextObject Name="txtQtyFound" Left="661.5" Width="75.6" Height="18.9" Text="[item_maintenance.QtyFound]" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
        <TextObject Name="txtQtyDiff" Left="737.1" Width="66.15" Height="18.9" Text="[item_maintenance.QtyDiff]" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
      </DataBand>
      <GroupFooterBand Name="GroupFooter1" Top="318.4" Width="1047.06" Height="56.7" AfterDataEvent="GroupFooter1_AfterData">
        <ShapeObject Name="Shape8" Left="56.7" Top="9.45" Width="973.35" Height="37.8" Border.Color="Gainsboro" Fill.Color="WhiteSmoke" Shape="RoundRectangle"/>
        <TextObject Name="Text32" Left="406.35" Top="18.9" Width="236.25" Height="18.9" Text="Total for [item_maintenance.Reason]:" TextFill.Color="DimGray"/>
        <TextObject Name="txtQtyDiffSubTot" Left="737.1" Top="18.9" Width="66.15" Height="18.9" Text="[SubTot_QtyDiff]" HorzAlign="Right"/>
        <TextObject Name="Text17" Left="812.7" Top="18.9" Width="94.5" Height="18.9" Text="[SubTot_Cost]" Format="Number" Format.UseLocale="false" Format.DecimalDigits="2" Format.DecimalSeparator="." Format.GroupSeparator=" " Format.NegativePattern="1" HorzAlign="Right"/>
        <TextObject Name="Text24" Left="916.65" Top="18.9" Width="94.5" Height="18.9" Text="[SubTot_Retail]" Format="Number" Format.UseLocale="false" Format.DecimalDigits="2" Format.DecimalSeparator="." Format.GroupSeparator=" " Format.NegativePattern="1" HorzAlign="Right"/>
      </GroupFooterBand>
    </GroupHeaderBand>
    <ReportSummaryBand Name="ReportSummary1" ZOrder="-1" Top="379.1" Width="1047.06" Height="56.7" AfterDataEvent="ReportSummary1_AfterData">
      <ShapeObject Name="Shape9" Left="37.8" Top="9.45" Width="992.25" Height="37.8" Border.Color="Gainsboro" Fill.Color="WhiteSmoke" Shape="RoundRectangle"/>
      <TextObject Name="Text30" Left="255.15" Top="18.9" Width="94.5" Height="18.9" Text="[Count_Total_Items]"/>
      <TextObject Name="Text33" Left="66.15" Top="18.9" Width="179.55" Height="18.9" Text="Total Items Processed:" HorzAlign="Right" TextFill.Color="DimGray"/>
      <TextObject Name="Text81" Left="595.35" Top="18.9" Width="132.3" Height="18.9" Text="Total for Period:" TextFill.Color="DimGray"/>
      <TextObject Name="txtQtyDiffTotal" Left="737.1" Top="18.9" Width="66.15" Height="18.9" Text="[Total_Diff]" HorzAlign="Right"/>
      <TextObject Name="Text26" Left="812.7" Top="18.9" Width="94.5" Height="18.9" Text="[Total_Cost]" Format="Number" Format.UseLocale="false" Format.DecimalDigits="2" Format.DecimalSeparator="." Format.GroupSeparator=" " Format.NegativePattern="1" HorzAlign="Right"/>
      <TextObject Name="Text27" Left="916.65" Top="18.9" Width="94.5" Height="18.9" Text="[Total_Selling]" Format="Number" Format.UseLocale="false" Format.DecimalDigits="2" Format.DecimalSeparator="." Format.GroupSeparator=" " Format.NegativePattern="1" HorzAlign="Right"/>
    </ReportSummaryBand>
    <PageFooterBand Name="PageFooter1" ZOrder="-1" Top="439.8" Width="1047.06" Height="37.8">
      <TextObject Name="Text36" Left="9.45" Top="9.45" Width="94.5" Height="18.9" Text="[PageNofM]" Font="Arial, 9pt" TextFill.Color="DimGray"/>
      <TextObject Name="Text79" Left="765.45" Top="9.45" Width="94.5" Height="18.9" Text="Print Date:" HorzAlign="Right" TextFill.Color="DimGray"/>
      <TextObject Name="Text78" Left="869.4" Top="9.45" Width="160.65" Height="18.9" Text="[Date]" TextFill.Color="DimGray"/>
    </PageFooterBand>
  </inherited>
  <DialogPage Name="Form1" ZOrder="1" Width="546" Height="334" AcceptButton="btnOk" CancelButton="btnCancel" ShownEvent="Form1_Shown">
    <ButtonControl Name="btnOk" Left="350" Top="235" Height="40" Anchor="Bottom, Right" Font="Segoe UI Light, 11pt" TabIndex="0" Text="OK" ClickEvent="btnOk_Click" DialogResult="OK"/>
    <ButtonControl Name="btnCancel" Left="433" Top="235" Height="40" Anchor="Bottom, Right" Font="Segoe UI Light, 11pt" TabIndex="1" Text="Cancel" DialogResult="Cancel"/>
    <LabelControl Name="Label3" Left="24" Top="24" Width="218" Height="37" Font="Segoe UI Light, 20pt" ForeColor="OliveDrab" TabIndex="6" Text="Item Maintenance"/>
    <ComboBoxControl Name="cboOrderBy" Left="220" Top="180" Width="233" Font="Segoe UI Light, 11pt" TabIndex="7" ClickEvent="" DropDownStyle="DropDownList" DropDownWidth="233" ItemHeight="20" ItemsText="Item code&#13;&#10;Description&#13;&#10;Qty Difference"/>
    <LabelControl Name="Label4" Left="68" Top="184" Width="116" Height="20" Font="Segoe UI Light, 11pt" TabIndex="5" Text="Order records by"/>
    <DateTimePickerControl Name="dtpFromDate" Left="220" Top="84" Width="220" Height="27" Font="Segoe UI, 11pt" ForeColor="DimGray" TabIndex="2" CustomFormat="d MMMM yyy" Format="Custom" Value="01/02/2014 16:15:55"/>
    <DateTimePickerControl Name="dtpToDate" Left="220" Top="132" Width="220" Height="27" Font="Segoe UI, 11pt" ForeColor="DimGray" TabIndex="3" CustomFormat="d MMMM yyy" Format="Custom" Value="01/02/2014 16:14:02"/>
    <LabelControl Name="Label1" Left="68" Top="88" Width="74" Height="20" Font="Segoe UI Light, 11pt" TabIndex="4" Text="From Date"/>
    <LabelControl Name="Label2" Left="68" Top="132" Width="56" Height="20" Font="Segoe UI Light, 11pt" TabIndex="5" Text="To Date"/>
  </DialogPage>
</inherited>
