<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="viewsalesinvoice.aspx.vb" Inherits="FutureERP.viewsalesinvoice" %>
<%@ Register Assembly="Syncfusion.EJ.Web, Version=14.3400.0.49, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
<%@ Register assembly="Syncfusion.EJ, Version=14.3400.0.49, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" namespace="Syncfusion.JavaScript.Models" tagprefix="ej" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#<%=cmbday.ClientID %>").focus();
$("#aspnetForm").submit(function () {
if ($("#<%=cmbday.ClientID %>").val() == '') {
jAlert('Please select Day', 'Message', function () {
$("#<%=cmbday.ClientID %>").focus();
});
return false
} else if ($("#<%=cmbmonth.ClientID %>").val() == '') {
jAlert('Please select Month', 'Message', function () {
$("#<%=cmbmonth.ClientID %>").focus();
});
return false
} else if ($("#<%=cmbyear.ClientID %>").val() == '') {
jAlert('Please select Year', 'Message', function () {
});
$("#<%=cmbyear.ClientID %>").focus();
return false
} else if (validate_date($("#<%=cmbday.ClientID %>").val(), $("#<%=cmbmonth.ClientID %>").val(), $("#<%=cmbyear.ClientID %>").val()) == false) {
jAlert('Invalid Date', 'Message', function () {
$("#<%=cmbday.ClientID %>").focus();
});
return false;
} else if ($("#<%=cmbtday.ClientID %>").val() == '') {
jAlert('Please select Day', 'Message', function () {
$("#<%=cmbtday.ClientID %>").focus();
});
return false
} else if ($("#<%=cmbtmonth.ClientID %>").val() == '') {
jAlert('Please select Month', 'Message', function () {
$("#<%=cmbtmonth.ClientID %>").focus();
});
return false
} else if ($("#<%=cmbtyear.ClientID %>").val() == '') {
jAlert('Please select Year', 'Message', function () {
$("#<%=cmbtyear.ClientID %>").focus();
});
return false
} else if (validate_date($("#<%=cmbtday.ClientID %>").val(), $("#<%=cmbtmonth.ClientID %>").val(), $("#<%=cmbtyear.ClientID %>").val()) == false) {
jAlert('Invalid Date', 'Message', function () {
$("#<%=cmbtday.ClientID %>").focus();
});
return false;
} else if (doDateperiod($("#<%=cmbday.ClientID %>").val(), $("#<%=cmbmonth.ClientID %>").val(), $("#<%=cmbyear.ClientID %>").val(), $("#<%=cmbtday.ClientID %>").val(), $("#<%=cmbtmonth.ClientID %>").val(), $("#<%=cmbtyear.ClientID %>").val()) == false) {
jAlert('Invalid Period', 'Message', function () {
$("#<%=cmbtday.ClientID %>").focus();
});
return false
}
return true;
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="pagecontent" runat="server">
<input type="hidden" id="txtid" runat="server" />
<div id="form-panel">
<h1 id="lblinvoice" class="form-panel-heading">Modify/View Stock Quality Check</h1>
<div class="form-panel-mid">
<div id="divtable" style="width:100%; margin:0; padding:10px 0 0 0;">
<asp:ScriptManager ID="ScriptManager" runat="server" EnablePartialRendering="true" />
<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<contenttemplate>
<table id="tbentry" cellpadding="1" cellspacing="2" border="0" width="100%">
<tr class="entry" style="height:22px">
<td style="width:25%; text-align:right">
<label for="user">From : </label>
</td>
<td style="width:75%; text-align:left">
<SELECT style="float: left; width:50px;" id="cmbday" runat="server">
<OPTION value="" selected="selected">DD</OPTION><OPTION
value="1">1</OPTION><OPTION value="2">2</OPTION><OPTION
value="3">3</OPTION><OPTION value="4">4</OPTION><OPTION
value="5">5</OPTION><OPTION value="6">6</OPTION><OPTION
value="7">7</OPTION><OPTION value="8">8</OPTION><OPTION
value="9">9</OPTION><OPTION value="10">10</OPTION><OPTION value="11">11</OPTION><OPTION
value="12">12</OPTION><OPTION value="13">13</OPTION><OPTION value="14">14</OPTION><OPTION
value="15">15</OPTION><OPTION value="16">16</OPTION><OPTION value="17">17</OPTION><OPTION
value="18">18</OPTION><OPTION value="19">19</OPTION><OPTION value="20">20</OPTION><OPTION
value="21">21</OPTION><OPTION value="22">22</OPTION><OPTION value="23">23</OPTION><OPTION
value="24">24</OPTION><OPTION value="25">25</OPTION><OPTION
value="26">26</OPTION><OPTION
value="27">27</OPTION><OPTION value="28">28</OPTION><OPTION value="29">29</OPTION><OPTION
value="30">30</OPTION>
<OPTION value="31">31</OPTION></SELECT>
<select id="cmbmonth" class="cmb" runat="server" style="width:100px;">
<OPTION value="" selected="selected">Month</OPTION>
<OPTION value="1">January</OPTION>
<OPTION value="2">February</OPTION>
<OPTION value="3">March</OPTION>
<OPTION value="4">April</OPTION>
<OPTION value="5">May</OPTION>
<OPTION value="6">June</OPTION>
<OPTION value="7">July</OPTION>
<OPTION value="8">August</OPTION>
<OPTION value="9">September</OPTION>
<OPTION value="10">October</OPTION>
<OPTION value="11">November</OPTION>
<OPTION value="12">December</OPTION>
</select>
<select id="cmbyear" class="cmb" runat="server" style="width:75px">
<option selected="selected" value="">Year</option>
</select></td>
</tr>
<tr class="entry" style="height:22px">
<td style="width:25%; text-align:right">
<label for="user">To : </label>
</td>
<td style="width:75%; text-align:left">
<select id="cmbtday" style="float: left; width:50px;" runat="server">
<option selected="selected" value="">DD</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select id="cmbtmonth" style="width: 100px; float: left;" runat="server">
<option selected="selected" value="">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="cmbtyear" runat="server" style="float: left; width:75px;">
<option value="">Year</option>
</select>
</td>
</tr>
<tr class="entry" style="height:22px">
<td style="width:25%; text-align:right"></td>
<td style="width:75%; text-align:left">
<asp:Button ID="btnsubmit" runat="server" OnClick="btn_Click" Text="Submit" Width="110" />
</td>
</tr>
</table>
<ej:Grid ID="dg" runat="server" IsResponsive="true" AllowSelection="false" AllowSorting="True" DataSourceID="sql" AllowSearching="True"
OnServerWordExporting="FlatGrid_ServerWordExporting" OnServerPdfExporting="FlatGrid_ServerPdfExporting"
OnServerExcelExporting="FlatGrid_ServerExcelExporting" AllowScrolling="true" AllowTextWrap="true" ShowSummary="true">
<SummaryRows>
<ej:SummaryRow Title="Total">
<SummaryColumn>
<ej:SummaryColumn SummaryType="Sum" DisplayColumn="value" DataMember="value" />
</SummaryColumn>
</ej:SummaryRow>
</SummaryRows>
<Columns>
<ej:Column Field="vno" HeaderText="No." Template="<a rel='nofollow' href='salesinvoice.aspx?id={{:id}}'>{{:vno}}</a>" Width="75" />
<ej:Column Field="vdate" HeaderText="Date" Width="100" Format="{0:dd-MM-yyyy}" />
<ej:Column Field="billno" HeaderText="Ref. No." Width="125"/>
<ej:Column Field="name" HeaderText="Party Name" Width="250" />
<ej:Column Field="saletype" HeaderText="SaleType" Width="100" />
<ej:Column Field="value" HeaderText="Value" TextAlign="Right" Width="100" />
<ej:Column Field="status" HeaderText="Status" TextAlign="Center" AllowFiltering="false" Width="70" />
<ej:Column HeaderText="Print" TextAlign="Center" Template="<a target='_blank' rel='nofollow' href='reportviewer.aspx?id={{:id}}&tp=10'>Print</a>" Width="60" AllowSorting="false" AllowFiltering="false" />
</Columns>
<ScrollSettings Width="800" Height="400" />
<ToolbarSettings ShowToolbar="True" ToolbarItems="search,excelExport,wordExport,pdfExport"></ToolbarSettings>
</ej:Grid>
</contenttemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnsubmit" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
</div>
<asp:SqlDataSource ID="sql" ConnectionString="<%$ ConnectionStrings:connectinfo %>" runat="server"
SelectCommand="Select a.id,a.vno,a.vdate,isnull(e.name,'') as name,case when a.saletype=0 then 'Local' else 'Central' end as saletype,isnull(round(a.amount,0),0) as value,isnull(a.billno,'') as billno,
case a.status when 1 then 'Done' else 'Canceled' end as status
from voucherMaster a
left join PartyMaster e on a.distid=e.ID and a.CompanyID=e.CompanyID
where a.vtype=@vtype and a.departmentid=@depid and a.companyid=@compid and convert(datetime,convert(varchar(80),a.vdate,112))>=@from and convert(datetime,convert(varchar(80),a.vdate,112))<=@to order by a.vdate">
<SelectParameters>
<asp:Parameter Name="depid" Type="String" Direction="Input" />
<asp:Parameter Name="compid" Type="Int64" Direction="Input" />
<asp:Parameter Name="from" Type="DateTime" Direction="Input" />
<asp:Parameter Name="to" Type="DateTime" Direction="Input" />
<asp:Parameter Name="vtype" Type="Int16" Direction="Input" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
//Server code
Imports System.Data.SqlClient
Imports Syncfusion.EJ.Export
Imports DevExpress.XtraPrinting
Imports System.Globalization
Public Class viewsalesinvoice
Inherits System.Web.UI.Page
Dim myconn As New SqlConnection(ConfigurationManager.ConnectionStrings("connectinfo").ToString())
Dim script As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If Not IsPostBack Then
myconn.Open()
For i As Integer = 2013 To Date.Now.Year + 1
cmbyear.Items.Add(New ListItem(i, i))
cmbtyear.Items.Add(New ListItem(i, i))
Next
cmbday.Value = 1
cmbtday.Value = Date.Now.Day
cmbmonth.Value = Date.Now.Month
cmbtmonth.Value = Date.Now.Month
cmbyear.Value = Date.Now.Year
cmbtyear.Value = Date.Now.Year
Dim vtype As Integer = Val(Request.QueryString("tp"))
Dim formid As Integer = 0
If vtype = 8 Then
formid = 73
ElseIf vtype = 9 Then
formid = 82
End If
If FormAuthentication(formid, Page.User.Identity.Name, myconn) = False Then
Response.Redirect("index.aspx")
Exit Sub
End If
Dim cmd As New SqlCommand("Select name from voucher_info where vtype=" & vtype, myconn)
Dim vname As String = cmd.ExecuteScalar()
ViewState("vname") = vname
script = script & "$('#lblinvoice').text('Modify/View " & vname & "');"
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "editscript", "$(function(){" & script & "});", True)
sql.SelectParameters("vtype").DefaultValue = vtype
sql.SelectParameters.Item("depid").DefaultValue = GetDepartmentID(myconn)
sql.SelectParameters.Item("compid").DefaultValue = GetCompID(myconn)
sql.SelectParameters.Item("from").DefaultValue = New Date(Date.Now.Year, Date.Now.Month, 1)
sql.SelectParameters.Item("to").DefaultValue = Date.Now
dg.DataBind()
myconn.Close()
End If
Catch ex As Exception
End Try
End Sub
Protected Overrides Sub InitializeCulture()
Dim ci As New CultureInfo("en-IN")
ci.NumberFormat.CurrencySymbol = "Rs"
Threading.Thread.CurrentThread.CurrentCulture = ci
MyBase.InitializeCulture()
End Sub
Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs)
Try
btnsubmit.Text = "Clicked"
sql.SelectParameters.Item("from").DefaultValue = New Date(Val(cmbyear.Value), Val(cmbmonth.Value), Val(cmbday.Value))
sql.SelectParameters.Item("to").DefaultValue = New Date(Val(cmbtyear.Value), Val(cmbtmonth.Value), Val(cmbtday.Value))
'dg.DataBind()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Public Sub FlatGrid_ServerExcelExporting(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.GridEventArgs)
Try
Dim exp As ExcelExport = New ExcelExport()
'exp.Export(dg.Model, DirectCast(dg.DataSource, IEnumerable), "CityList.xlsx", ExcelVersion.Excel2007, True, True, ExportTheme.FlatLime)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Public Sub FlatGrid_ServerWordExporting(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.GridEventArgs)
Try
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Public Sub FlatGrid_ServerPdfExporting(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.GridEventArgs)
Try
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
End Class