Sir Its My Complete Code
(BillPrepare.aspx)
<%@ Page Title="" EnableViewState="true" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="BillPrepare.aspx.cs" Inherits="EncashmentSystem.MenuForms.BillPrepare" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type = "text/javascript">
function closeBrowser() {
window.open('', '_self', '');
window.close();
}
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to Delete Record?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
<style type="text/css">
input[type='text'] {
width: 80%;
}
select {
width: 80%;
height: 23px;
border: solid 1px;
border-radius: 3px;
}
select :focus {
-webkit-box-shadow: 1px 1px 1px 2px;
-moz-box-shadow: 1px 1px 1px 2px;
box-shadow: 1px 1px 2px 2px aqua;
}
table {
width: 100%;
}
td {
text-align: center;
}
.lbl {
margin-left: 130px;
text-align: right;
}
.auto-style2 {
text-align: center;
}
.btn {
height: 30px;
width: 96%;
}
/*.btn {
height: 30px;
width: 15%;
/*height: 30px;
width:100%-140px;*/
/*}*/
.auto-style3 {
width: 171px;
}
.auto-style4 {
text-align: center;
width: 181px;
}
.auto-style5 {
width: 181px;
}
.auto-style6 {
height: 20px;
}
.auto-style7 {
width: 181px;
height: 20px;
}
.auto-style8 {
height: 6px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<%--<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>--%>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Panel ID="Panel1" runat="server" Width="100%"> </asp:Panel>
<%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>--%>
<asp:Button ID="btnShowMsgPopup" runat="server" style="display:none"/>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowMsgPopup" PopupControlID="pnlMsg">
</cc1:ModalPopupExtender>
<asp:panel ID="pnlMsg" runat="server" BackColor="white" Height="150px" Width="300px"
Style="display: none">
<table style="width: 100%; border: Solid 2px #D46900; width: 100%; height: 100%; font-family: Verdana; font-size: small" cellspacing="0" class="pnlUpdatePopUp">
<tr style="background-image: url(Images/header.gif)">
<td style="height: 10%; color: White; font-weight: bold; padding: 3px; font-size: larger; font-family: Calibri" align="Left">Message Box</td>
<td style="color: White; font-weight: bold; padding: 3px; font-size: larger" align="Right">
<a href="javascript:void(0)" onclick="closepopup()">
<img src="Images/Close.gif" style="border: 0px" align="right" /></a>
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px; text-align: center"></td>
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px; text-align: center">
<asp:Label ID="lblpmsg" runat="server" /><br />
<asp:Label ID="lblFromDate" runat="server" />
<asp:Label ID="lblToDate" runat="server" />
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td style="text-align: center" colspan="2">
<asp:Button ID="btnok" runat="server" Text="OK!!" CssClass="btnokpopup" />
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px; text-align: center"></td>
</tr>
</table>
<br />
</asp:panel>
<asp:Button ID="btnShowMsgPopupYesNo" runat="server" style="display:none" />
<cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="btnShowMsgPopupYesNo" PopupControlID="pnlMsgYesNo" CancelControlID="btnPopNo"></cc1:ModalPopupExtender>
<asp:Panel ID="pnlMsgYesNo" runat="server" BackColor="white" Height="150px" Width="300px"
Style="display:none " >
<table style="width: 100%;">
<tr style="background-image: url(Images/header.gif)">
<td style="height: 10%; color: White; font-weight: bold; padding: 3px; font-size: larger; font-family: Calibri" align="Left">Message Box</td>
<td style="color: White; font-weight: bold; padding: 3px; font-size: larger" align="Right">
<a href="javascript:void(0)" onclick="closepopup()">
<img src="Images/Close.gif" style="border: 0px" align="right" /></a>
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px; text-align: center">
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px; text-align: center">
<asp:Label ID="lblMsgPopY" runat="server" /><br />
<asp:Label ID="Label2" runat="server" />
<asp:Label ID="Label3" runat="server" />
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td style="text-align: center" colspan="2">
<asp:Button ID="btnpopYes" runat="server" Text="Yes" CssClass="btnokpopup" OnClick="btnpopYes_Click" />
<asp:Button ID="btnPopNo" runat="server" Text="No" CssClass="btnokpopup" OnClick="btnPopNo_Click" />
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px; text-align: center"></td>
</tr>
</table>
<br />
</asp:Panel>
<table ="width=100%;" >
<tr>
<td style="width:14.28%">
<asp:Label ID="lblfinyear" runat="server" Text="Fin Year"></asp:Label>
</td>
<td style="width:14.28%">
<asp:TextBox ID="txtFinYear" runat="server" ></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtFinYearFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtFinYear"/>
</td>
<td style="width:14.28%">
<asp:Button ID="btnChangeFYear" runat="server" Text="Change Financial Year" OnClick="btnChangeFYear_Click" Width="100%" />
</td>
<td style="width:14.28%">
<asp:Label ID="lblTrnDate" runat="server" Text="TRN Date :"></asp:Label>
</td>
<td style="width:14.28%">
<asp:TextBox ID="txtTrnDate" runat="server" ></asp:TextBox>
<cc1:CalendarExtender ID="txtTrnDate_CalendarExtender" runat="server" TargetControlID="txtTrnDate" Format="dd MMM yyyy" />
</td>
<td style="width:14.28%">
<asp:Label ID="lblCgNo" runat="server" Text="CG No :"></asp:Label>
</td>
<td style="width:14.28%">
<asp:TextBox ID="txtCgNo" runat="server" ></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtCgNoFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtCgNo" />
</td>
</tr>
<tr>
<td style="width:14.28%">
<asp:Label ID="lblName" runat="server" Text="Name :"></asp:Label>
</td>
<td style="width:14.28%">
<asp:DropDownList ID="drpName" runat="server" Width="91%" OnSelectedIndexChanged="drpName_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
</td>
<td style="width:14.28%"></td>
<td style="width:14.28%">
<asp:Label ID="lblDesg" runat="server" Text="Designation :" Style="text-align: left"></asp:Label>
</td>
<td style="width:14.28%">
<asp:TextBox ID="txtDesg" runat="server" Enabled="False"></asp:TextBox>
</td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td colspan="7" style="width:100%">
<asp:Panel ID="Panel2" runat="server" GroupingText="Entry" Width="100%">
<asp:UpdatePanel ID="pnl2" runat="server">
<ContentTemplate>
<table style="width:100%">
<tr>
<td class="auto-style2" style="width:14.28%">
<asp:Label ID="lblPay" runat="server" align="center" Text="Pay :"></asp:Label></td>
<td class="auto-style4" style="width:14.28%">
<asp:Label ID="lblGp" runat="server" Text="GP :"></asp:Label></td>
<td class="auto-style2" style="width:14.28%">
<asp:Label ID="lblBasicPay" runat="server" Text="Basic Pay :"></asp:Label></td>
<td class="auto-style2" style="width:14.28%">
<asp:Label ID="lblDaRate" runat="server" Text="DA Rate :"></asp:Label></td>
<td class="auto-style2" style="width:14.28%">
<asp:Label ID="lblDaAmont" runat="server" Text="DA Amount :"></asp:Label></td>
<td class="auto-style2" style="width:14.28%">
<asp:Label ID="lblTotal" runat="server" Text="Total :"></asp:Label></td>
</tr>
<tr>
<td class="auto-style2" style="width:14.28%">
<asp:TextBox ID="txtPay" runat="server" AutoPostBack="True" OnTextChanged="txtpay_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtPayFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtPay" />
</td>
<td class="auto-style4" style="width:14.28%">
<asp:TextBox ID="txtGp" runat="server" AutoPostBack="True" OnTextChanged="txtgp_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtGpFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtGp" />
</td>
<td class="auto-style2" style="width:14.28%">
<asp:TextBox ID="txtBasicPay" runat="server" OnTextChanged="txtBasicPay_TextChanged" AutoPostBack="True"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtBasicPayFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtBasicPay" />
</td>
<td class="auto-style2" style="width:14.28%">
<asp:TextBox ID="txtDaRate" runat="server" AutoPostBack="True" OnTextChanged="txtdarate_TextChanged" Width="80%"></asp:TextBox>%
<cc1:FilteredTextBoxExtender ID="txtDaRateFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtDaRate" />
</td>
<td class="auto-style2" style="width:14.28%; margin-left: 40px;">
<asp:TextBox ID="txtDaAmount" runat="server" Enabled="False" AutoPostBack="True"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtDaAmountFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtDaAmount" />
</td>
<td class="auto-style2" style="width:14.28%">
<asp:TextBox ID="txtTotal" runat="server" Enabled="False" AutoPostBack="True"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtTotalFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtTotal" />
</td>
<td class="auto-style2" style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td class="auto-style5" style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td class="auto-style2" style="width:14.28%"></td>
</tr>
<tr>
<td class="auto-style2" style="width:14.28%">
</td>
<td class="auto-style4" style="width:14.28%">
</td>
<td class="auto-style2" style="width:14.28%">
</td>
<td style="width:14.28%">
</td>
<td class="auto-style2" style="width:14.28%">
</td>
<td class="auto-style2" style="width:14.28%">
</td>
<td class="auto-style2" style="width:14.28%"></td>
</tr>
<tr>
<td class="auto-style2" style="width:14.32%">
<asp:Label ID="lblElEncashDay" runat="server" Text="ELEncashment Day"></asp:Label> </td>
<td style="width:14.28%">
<asp:TextBox ID="txtElEncashDay" runat="server" Enabled="False" AutoPostBack="True"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtElEncashDayFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtElEncashDay" />
</td>
<td style="width:14.28%">
</td>
<td style="width:14.28%">
</td>
<td style="width:14.28%">
</td>
<td class="auto-style2" style="width:14.28%"><asp:Label ID="lblElEncashAmount" runat="server" Text="ElEncash Amount"></asp:Label></td>
<td style="width:14.28%">
<asp:TextBox ID="txtElEncashAmount" runat="server" AutoPostBack="True" Enabled="False"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtElEncashAmountFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtElEncashAmount" />
</td>
</tr>
<tr><td class="auto-style8"></td></tr>
<tr>
<td class="auto-style6" style="width:14.28%"><asp:Label ID="lblItPer" runat="server" Text="IT- %"></asp:Label></td>
<td class="auto-style7" style="width:14.28%">
<asp:Label ID="lblIncomeTax" runat="server" Text="Income Tax"></asp:Label></td>
<td class="auto-style6" style="width:14.28%"><asp:Label ID="lblCess" runat="server" Text="Cess"></asp:Label></td>
<td class="auto-style6" style="width:14.28%"></td>
<td class="auto-style6" style="width:14.28%"></td>
<td class="auto-style6" style="width:14.28%"></td>
<td class="auto-style2" style="width:14.28%"></td>
</tr>
<tr>
<td class="auto-style6" style="width:14.28%"><asp:DropDownList ID="drpItPer" runat="server" Width="70%" AutoPostBack="True" OnSelectedIndexChanged="drpItPer_SelectedIndexChanged">
<asp:ListItem Value="0">NA</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
</asp:DropDownList></td>
<td class="auto-style7" style="width:14.28%">
<asp:TextBox ID="txtIncomeTax" runat="server" AutoPostBack="True" OnTextChanged="txtIncomeTax_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtIncomeTaxFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtIncomeTax" />
</td>
<td class="auto-style6" style="width:14.28%"><asp:TextBox ID="txtCess" runat="server" AutoPostBack="True" OnTextChanged="txtCess_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtCessFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtCess" />
</td>
<td class="auto-style6" style="width:14.28%"></td>
<td class="auto-style6" style="width:14.28%"></td>
<td class="auto-style6" style="width:14.28%"><asp:Label ID="lblTotalTax" runat="server" Text="Total Tax"></asp:Label></td>
<td class="auto-style2" style="width:14.28%"><asp:TextBox ID="txtTotalTax" runat="server" AutoPostBack="True" Enabled="False"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtTotalTaxFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtTotalTax" />
</td>
</tr>
<tr>
<td style="width:14.28%"> </td>
<td class="auto-style5" style="width:14.28%"> </td>
<td style="width:14.28%"> </td>
<td style="width:14.28%"> </td>
<td style="width:14.28%"> </td>
<td style="width:14.28%"> </td>
<td class="auto-style2" style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"> </td>
<td class="auto-style5" style="width:14.28%"> </td>
<td style="width:14.28%"> </td>
<td style="width:14.28%"> </td>
<td style="width:14.28%">
<asp:TextBox ID="txtNetAmtInWords" runat="server" Visible="false" OnTextChanged="txtNetAmtInWords_TextChanged" AutoPostBack="True"></asp:TextBox>
</td>
<td style="width:14.28%"> <asp:Label ID="lblNetAmount" runat="server" Text="NetAmount"></asp:Label></td>
<td class="auto-style2" style="width:14.28%"><asp:TextBox ID="txtNetAmount" runat="server" AutoPostBack="True" Enabled="False"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtNetAmountFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtNetAmount" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</td>
</tr>
<tr>
<td colspan="7" style="width:100%">
<table style="width:100%">
<tr>
<td style="width:16.66%">
<asp:Label ID="lblDoPartNo" runat="server" Text="DO Part No :"></asp:Label>
</td>
<td style="width:16.66%"> <asp:TextBox ID="txtDoPartNo" runat="server" AutoPostBack="True" OnTextChanged="txtDoPartNo_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtDoPartNoFilteredTextBoxExtender1" runat="server" Enabled="true" FilterType="Numbers" TargetControlID="txtDoPartNo" />
</td>
<td style="width:16.66%">
<asp:Label ID="lblDoPartDate" runat="server" Text="DO PartDate"></asp:Label>
</td>
<td style="width:16.66%">
<asp:TextBox ID="txtDoPartDate" runat="server" AutoPostBack="True" OnTextChanged="txtDoPartDate_TextChanged"></asp:TextBox>
<cc1:CalendarExtender ID="txtDoPartDate_CalendarExtender" runat="server" TargetControlID="txtDoPartDate" Format="dd MMM yyyy" />
</td>
<td class="auto-style3" style="width:16.66%"> </td>
<td style="width:16.66%"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
<td style="width:14.28%"></td>
</tr>
<tr>
<td colspan="7" style="width:100%">
<asp:Panel ID="Panel4" runat="server">
<table style="width:100%">
<tr>
<td style="width:12.8%" >
<asp:Button ID="btnPrintBill" runat="server" Text="PrintBill" CssClass="btn" OnClick="btnPrintBill_Click" />
</td>
<td style="width:12.8%" >
<asp:Button ID="btnPrintSanction" runat="server" Text="Print Sanction" CssClass="btn" OnClick="btnPrintSanction_Click" /></td>
<td style="width:12.8%">
<asp:Button ID="btnPrintCoverLetter" runat="server" Text="Print Covering Letter" CssClass="btn" OnClick="btnPrintCoverLetter_Click" /></td>
<td style="width:12.8%">
<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btn" OnClick="btnSearch_Click" /></td>
<td style="width:12.8%">
<asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="btn" OnClick="btnAdd_Click" />
<asp:Button ID="btnEdit" runat="server" Text="Add" CssClass="btn" OnClick="btnEdit_Click" />
</td>
<td style="width:12.8%">
<asp:Button ID="btnRemove" runat="server" Text="Remove" CssClass="btn" OnClick="btnRemove_Click1" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="btn" OnClick="btnCancel_Click" />
</td>
<td style="width:12.8%">
<asp:Button ID="btnExit" runat="server" Text="Exit" CssClass="btn" OnClick="btnExit_Click" />
</td>
<td style="width:12.8%">
<asp:Button ID="btnQuit" runat="server" Text="Quit" CssClass="btn" OnClientClick="return closeBrowser();" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
<%-- </ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
<%-- <asp:aspostBackTrigger ControlID="btnAdd" />--%>
<%--<aspostBackTrigger ControlID="btnok" />
<asp:AsyncPostBackTrigger ControlID="btnShowPopup" />--%>
<%--</Triggers>
</asp:UpdatePanel>--%>
<div style="display: none">
<div id="DvHtmlBill" runat="server">
</div>
</div>
<div style="display: none">
<div id="dvHtml" runat="server">
</div>
</div>
<div style="display: none">
<div id="DvHtmlSanction" runat="server">
</div>
</div>
</asp:Content>
(BillPrepare.aspx.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
namespace EncashmentSystem.MenuForms
{
public partial class BillPrepare : System.Web.UI.Page
{
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
//OleDbConnection con = new OleDbConnection("Provider=MSDAORA.1;User Id=Paybill;Password=Paybill123;Data Source=oraarde;persis Security Info=false ");
string Menu1Id;
int MenuNo1 = 0;
int SelectedCgNo = 0;
int SelectedFinYear;
int SelectedFinYear1;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
foreach (string Menu1 in Session)
{
Menu1Id = Convert.ToInt32(Session["Menu1"]).ToString();
foreach (string userid in Session)
{
txtCgNo.Text = Convert.ToInt32(Session["userid"]).ToString();
//BindControlvalues();
//BindComboByCGNo();
SelectedCgNo = Convert.ToInt32(txtCgNo.Text.ToString());
}
if (SelectedCgNo > 0)
{
BindControlvalues();
BindComboByCGNo();
//ShowMessaage("selected record menu ");
btnAdd.Visible = false;
}
else
{
BindCombo();
btnAdd.Visible = true;
btnEdit.Visible = false;
txtIncomeTax.Text = "0";
txtCess.Text = "0";
//ShowMessaage("Direct Menu Welcome");
}
}
EnableFalse();
btnCancel.Visible = false;
}
}
private void BindControlvalues()
{
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from Encashment e inner join pis.Designation_table d on e.Dcode = d.Dcode where CgNo= '" + txtCgNo.Text + "'", con);
//OleDbCommand cmd1 = new OleDbCommand("select distinct * from Encashment en inner join pis.Employee_table emp on en.EmpNumber=emp.EmpNumber where en.CgNo= '" + userid + "'", con);
OleDbCommand cmd1 = new OleDbCommand("select en.EmpNumber,emp.Name from Encashment en inner join pis.Employee_table emp on en.EmpNumber=emp.EmpNumber where en.CgNo= '" + txtCgNo.Text + "'", con);
OleDbDataReader dr1 = cmd.ExecuteReader();
if (dr1.Read())
{
txtCgNo.Text = dr1["CgNo"].ToString();
txtFinYear.Text = dr1["Fy"].ToString();
// txtCbNo.Text = dr1["CbNo"].ToString();
var cgdatechk = dr1["CgDate"].ToString();
if (cgdatechk == "")
{
txtTrnDate.Text = dr1["CgDate"].ToString();
}
else
{
txtTrnDate.Text = Convert.ToDateTime(dr1["CgDate"]).Date.ToString("dd MMM yyyy");
}
// txtTrnDate.Text = Convert.ToDateTime(dr1["CgDate"]).ToString("dd-MM-yyyy");///it comment at the time of oracle dbconnect time./////
drpName.Text = dr1["EmpNumber"].ToString();
//txtDesg.Text = dr1["Dcode"].ToString();
txtDesg.Text = dr1["Designation"].ToString();// this line of code fetch the designation with designation table
txtDoPartNo.Text = dr1["DoptNo"].ToString();
var doptdatechk = dr1["DoptDate"].ToString();
if (doptdatechk == "")
{
txtDoPartDate.Text = dr1["DoptDate"].ToString();
}
else
{
txtDoPartDate.Text = Convert.ToDateTime(dr1["DoptDate"]).Date.ToString("dd MMM yyyy");
}
// txtDoPartDate.Text = Convert.ToDateTime(dr1["DoptDate"]).ToString("dd-MM-yyyy");///it comment at the time of oracle dbconnect time./////
txtPay.Text = dr1["Pay"].ToString();
txtGp.Text = dr1["Gp"].ToString();
var b = ((Convert.ToInt32(txtPay.Text)) + ((Convert.ToInt32(txtGp.Text))));
txtBasicPay.Text = b.ToString();
txtDaRate.Text = dr1["DaRate"].ToString();
txtDaAmount.Text = dr1["DAAmt"].ToString();
var d = ((Convert.ToInt32(txtBasicPay.Text)) + ((Convert.ToInt32(txtDaAmount.Text))));
txtTotal.Text = d.ToString();
txtElEncashDay.Text = dr1["ElDays"].ToString();
var f = ((Convert.ToInt32(txtTotal.Text)) / 30) * 10;
txtElEncashAmount.Text = f.ToString();
txtIncomeTax.Text = dr1["IncomeTax"].ToString();
txtCess.Text = dr1["Cess"].ToString();
txtTotalTax.Text = dr1["TotalTax"].ToString();
txtNetAmount.Text = dr1["NetAmt"].ToString();
}
dr1.Close();
con.Close();
}
public void BindComboByCGNo()
{
// Use for selected Combo Fetch Present in Gridview//
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from Encashment e inner join pis.Employee_table em on e.EmpNumber= em.EmpNumber where CgNo='" + txtCgNo.Text + "'", con);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
drpName.DataSource = dt;
drpName.DataValueField = "EmpNumber";
drpName.DataTextField = "Name";
drpName.DataBind();
drpName.Items.Insert(0, new ListItem("--Select Name--", "0"));
con.Close();
drpName.Enabled = false;
}
catch (Exception)
{
throw;
}
}
public void BindCombo()
{
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from pis.Employee_table", con);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
drpName.DataSource = dt;
drpName.DataValueField = "EmpNumber";
drpName.DataTextField = "Name";
drpName.DataBind();
drpName.Items.Insert(0, new ListItem("--Select Name--", "0"));
con.Close();
}
catch (Exception)
{
throw;
}
}
public void IncrementCgNo()
{
int AID = 0;
int lastID = 0;
string sql = "select CgNo from Encashment";
con.Open();
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
AID = Convert.ToInt32(dr["CgNo"]);
}
con.Close();
if (AID != 0)
{
//String query11 = "SELECT MAX(CgNo) as 'LastID' FROM Encashment";
String query11 = "SELECT MAX(CgNo) FROM Encashment";
con.Open();
OleDbCommand cmdid = new OleDbCommand(query11, con);
lastID = int.Parse(cmdid.ExecuteScalar().ToString()) + 1;
txtCgNo.Text = lastID.ToString();
con.Close();
}
else
{
txtCgNo.Text = (lastID + 1).ToString();
}
}
public void txtBtnEnable()
{
}
void ShowMessaage(String msg)
{
ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language='javascript'> alert('" + msg + "');</script>");
}
void ShowMessaage1(String msg)
{
ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language='javascript'> alert('" + msg + "');</script>");
}
public void EnableFalse()
{
txtFinYear.Enabled = false;
txtTrnDate.Enabled = false;
txtCgNo.Enabled = false;
// drpName.SelectedIndex = -1;
txtDesg.Enabled = false;
txtPay.Enabled = false;
txtGp.Enabled = false;
txtBasicPay.Enabled = false;
txtDaRate.Enabled = false;
txtDaAmount.Enabled = false;
txtTotal.Enabled = false;
txtElEncashDay.Enabled = false;
txtElEncashAmount.Enabled = false;
txtIncomeTax.Enabled = false;
txtCess.Enabled = false;
txtTotalTax.Enabled = false;
txtNetAmount.Enabled = false;
txtDoPartNo.Enabled = false;
txtDoPartDate.Enabled = false;
btnChangeFYear.Enabled = false;
drpName.Enabled = false;
drpItPer.Enabled = false;
}
public void clear()
{
txtFinYear.Text = "";
txtTrnDate.Text = "";
txtCgNo.Text = "";
drpName.SelectedIndex = -1;
txtDesg.Text = "";
txtPay.Text = "";
txtGp.Text = "";
txtBasicPay.Text = "";
txtDaRate.Text = "";
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashDay.Text = "";
txtElEncashAmount.Text = "";
txtIncomeTax.Text = "";
txtCess.Text = "";
txtTotalTax.Text = "";
txtNetAmount.Text = "";
txtDoPartNo.Text = "";
txtDoPartDate.Text = "";
// Panel1.Enabled = false;
Panel2.Enabled = false;
}
protected void txtpay_TextChanged(object sender, EventArgs e)
{
if (txtPay.Text != "")
{
if (txtGp.Text == "".ToString())
{
var a = (Convert.ToInt32(txtPay.Text).ToString());
txtBasicPay.Text = a.ToString();
if (txtDaRate.Text != "")
{
if (txtBasicPay.Text == "")
{
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashAmount.Text = "";
txtElEncashAmount.Text = "";
txtIncomeTax.Text = "";
txtCess.Text = "";
txtNetAmount.Text = "";
txtElEncashDay.Text = "";
}
else
{
var c = (((Convert.ToInt32(txtBasicPay.Text) * (Convert.ToInt32(txtDaRate.Text)) / 100).ToString()));
txtDaAmount.Text = c.ToString();
var d = ((Convert.ToInt32(txtBasicPay.Text)) + ((Convert.ToInt32(txtDaAmount.Text))));
txtTotal.Text = d.ToString();
txtElEncashDay.Text = "10";
var f = ((Convert.ToInt32(txtTotal.Text)) / 30) * 10;
txtElEncashAmount.Text = f.ToString();
}
}
}
else
{
var b = ((Convert.ToInt32(txtPay.Text)) + ((Convert.ToInt32(txtGp.Text))));
txtBasicPay.Text = b.ToString();
if (txtDaRate.Text != "")
{
if (txtBasicPay.Text == "")
{
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashAmount.Text = "";
txtElEncashAmount.Text = "";
txtIncomeTax.Text = "";
txtCess.Text = "";
txtNetAmount.Text = "";
txtElEncashDay.Text = "";
}
else
{
var c = (((Convert.ToInt32(txtBasicPay.Text) * (Convert.ToInt32(txtDaRate.Text)) / 100).ToString()));
txtDaAmount.Text = c.ToString();
var d = ((Convert.ToInt32(txtBasicPay.Text)) + ((Convert.ToInt32(txtDaAmount.Text))));
txtTotal.Text = d.ToString();
txtElEncashDay.Text = "10";
var f = ((Convert.ToInt32(txtTotal.Text)) / 3);
txtElEncashAmount.Text = f.ToString();
if (txtElEncashAmount.Text != "")
{
if (drpItPer.SelectedValue != "Not Applicable")
{
var IncomeTaxValue = Convert.ToInt32(txtElEncashAmount.Text) * Convert.ToInt32(drpItPer.SelectedValue) / 100;
txtIncomeTax.Text = IncomeTaxValue.ToString();
var f2 = ((Convert.ToInt32(txtIncomeTax.Text)) * 3 / 100);
txtCess.Text = f2.ToString();
var g = ((Convert.ToInt32(txtIncomeTax.Text)) + (Convert.ToInt32(txtCess.Text)));
txtTotalTax.Text = g.ToString();
var a = ((Convert.ToInt32(txtElEncashAmount.Text)) - ((Convert.ToInt32(txtTotalTax.Text))));
txtNetAmount.Text = a.ToString();
txtDoPartNo.Focus();
}
else
{
}
}
else
{
ShowMessaage("Amount Should Not Be Empty !!!");
}
}
}
}
//txtGp.Text = Focus();
txtGp.Focus();
}
}
protected void txtgp_TextChanged(object sender, EventArgs e)
{
if (txtPay.Text != "" && txtGp.Text !="")
{
var b = ((Convert.ToInt32(txtPay.Text)) + ((Convert.ToInt32(txtGp.Text))));
txtBasicPay.Text = b.ToString();
if (txtDaRate.Text != "")
{
if (txtBasicPay.Text == "")
{
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashAmount.Text = "";
txtElEncashAmount.Text = "";
txtIncomeTax.Text = "";
txtCess.Text = "";
txtNetAmount.Text = "";
txtElEncashDay.Text = "";
}
else
{
var c = (((Convert.ToInt32(txtBasicPay.Text) * (Convert.ToInt32(txtDaRate.Text)) / 100).ToString()));
txtDaAmount.Text = c.ToString();
var d = ((Convert.ToInt32(txtBasicPay.Text)) + ((Convert.ToInt32(txtDaAmount.Text))));
txtTotal.Text = d.ToString();
txtElEncashDay.Text = "10";
//var f = ((Convert.ToInt32(txtTotal.Text)) / 30) * 10;
var f = ((Convert.ToInt32(txtTotal.Text)) / 3);
txtElEncashAmount.Text = f.ToString();
if (txtElEncashAmount.Text != "")
{
if (drpItPer.SelectedValue != "Not Applicable")
{
var IncomeTaxValue = Convert.ToInt32(txtElEncashAmount.Text) * Convert.ToInt32(drpItPer.SelectedValue) / 100;
txtIncomeTax.Text = IncomeTaxValue.ToString();
var f2 = ((Convert.ToInt32(txtIncomeTax.Text)) * 3 / 100);
txtCess.Text = f2.ToString();
var g = ((Convert.ToInt32(txtIncomeTax.Text)) + (Convert.ToInt32(txtCess.Text)));
txtTotalTax.Text = g.ToString();
var a = ((Convert.ToInt32(txtElEncashAmount.Text)) - ((Convert.ToInt32(txtTotalTax.Text))));
txtNetAmount.Text = a.ToString();
txtDoPartNo.Focus();
}
else
{
}
}
}
}
}
txtDaRate.Focus();
}
protected void txtdarate_TextChanged(object sender, EventArgs e)
{
if (txtDaRate.Text != "")
{
if (txtBasicPay.Text == "")
{
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashAmount.Text = "";
txtElEncashAmount.Text = "";
txtIncomeTax.Text = "";
txtCess.Text = "";
txtNetAmount.Text = "";
txtElEncashDay.Text = "";
}
else
{
var c = (((Convert.ToInt32(txtBasicPay.Text) * (Convert.ToInt32(txtDaRate.Text)) / 100).ToString()));
txtDaAmount.Text = c.ToString();
var d = ((Convert.ToInt32(txtBasicPay.Text)) + ((Convert.ToInt32(txtDaAmount.Text))));
txtTotal.Text = d.ToString();
txtElEncashDay.Text = "10";
var f = ((Convert.ToInt32(txtTotal.Text)) / 3);
txtElEncashAmount.Text = f.ToString();
if (txtDaRate.Text != "")
{
if (txtBasicPay.Text == "")
{
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashAmount.Text = "";
txtElEncashAmount.Text = "";
txtIncomeTax.Text = "";
txtCess.Text = "";
txtNetAmount.Text = "";
txtElEncashDay.Text = "";
}
else
{
var c1 = (((Convert.ToInt32(txtBasicPay.Text) * (Convert.ToInt32(txtDaRate.Text)) / 100).ToString()));
txtDaAmount.Text = c1.ToString();
var d1 = ((Convert.ToInt32(txtBasicPay.Text)) + ((Convert.ToInt32(txtDaAmount.Text))));
txtTotal.Text = d1.ToString();
txtElEncashDay.Text = "10";
var f1 = ((Convert.ToInt32(txtTotal.Text)) / 3);
txtElEncashAmount.Text = f1.ToString();
if (txtElEncashAmount.Text != "")
{
if (drpItPer.SelectedValue != "Not Applicable")
{
var IncomeTaxValue = Convert.ToInt32(txtElEncashAmount.Text) * Convert.ToInt32(drpItPer.SelectedValue) / 100;
txtIncomeTax.Text = IncomeTaxValue.ToString();
var f2 = ((Convert.ToInt32(txtIncomeTax.Text)) * 3 / 100);
txtCess.Text = f2.ToString();
var g = ((Convert.ToInt32(txtIncomeTax.Text)) + (Convert.ToInt32(txtCess.Text)));
txtTotalTax.Text = g.ToString();
var a = ((Convert.ToInt32(txtElEncashAmount.Text)) - ((Convert.ToInt32(txtTotalTax.Text))));
txtNetAmount.Text = a.ToString();
txtDoPartNo.Focus();
}
else
{
}
}
}
}
}
drpItPer.Focus();
}
}
protected void txtIncomeTax_TextChanged(object sender, EventArgs e)
{
if (txtIncomeTax.Text == "")
{
txtCess.Text = "";
txtNetAmount.Text = "";
txtTotalTax.Text = "";
drpItPer.SelectedIndex = -1;
}
else
{
if (txtIncomeTax.Text != "" && txtElEncashAmount.Text !="")
{
//var f = ((Convert.ToInt32(txtIncomeTax.Text)) / 100) * (Convert.ToInt32(txtCess.Text));
//txtTotalTax.Text = f.ToString();
var f = ((Convert.ToInt32(txtIncomeTax.Text)) * 3 / 100);
txtCess.Text = f.ToString();
var g = ((Convert.ToInt32(txtIncomeTax.Text)) + (Convert.ToInt32(txtCess.Text)));
txtTotalTax.Text = g.ToString();
var a = ((Convert.ToInt32(txtElEncashAmount.Text)) - ((Convert.ToInt32(txtTotalTax.Text))));
txtNetAmount.Text = a.ToString();
}
}
}
protected void txtCess_TextChanged(object sender, EventArgs e)
{
if (txtCess.Text == "")
{
txtIncomeTax.Text = "";
txtNetAmount.Text = "";
txtTotalTax.Text = "";
}
else {
if (txtCess.Text != "" && txtElEncashAmount.Text !="")
{
var f = ((Convert.ToInt32(txtIncomeTax.Text)) / 100) * (Convert.ToInt32(txtCess.Text));
txtTotalTax.Text = f.ToString();
var a = ((Convert.ToInt32(txtElEncashAmount.Text)) - ((Convert.ToInt32(txtTotalTax.Text))));
txtNetAmount.Text = a.ToString();
}
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
if ((btnEdit.Text == "Add"))
{
txtFinYear.Enabled = false;
txtTrnDate.Enabled = true;
// txtCgNo.Enabled = true;
//drpName.SelectedIndex = -1;
// txtDesg.Enabled = true;
txtPay.Enabled = true;
txtGp.Enabled = true;
// txtBasicPay.Enabled = true;
txtDaRate.Enabled = true;
// txtDaAmount.Enabled = true;
//txtTotal.Enabled = true;
// txtElEncashDay.Enabled = true;
//txtElEncashAmount.Enabled = true;
txtIncomeTax.Enabled = true;
txtCess.Enabled = true;
//txtTotalTax.Enabled = true;
// txtNetAmount.Enabled = true;
txtDoPartNo.Enabled = true;
txtDoPartDate.Enabled = true;
btnChangeFYear.Enabled = true;
drpItPer.Enabled = true;
btnEdit.Text = "Save";
btnCancel.Visible = true;
btnRemove.Visible = false;
}
else if (btnEdit.Text == "Save")
{
if (txtFinYear.Text != "" && txtTrnDate.Text != "" && txtCgNo.Text != "" && drpName.Text != "" && txtDesg.Text != "" && txtPay.Text != "" && txtGp.Text != "" && txtBasicPay.Text != "" && txtDaRate.Text != "" && txtIncomeTax.Text != "" && txtCess.Text != "" && txtDoPartNo.Text != "" && txtDoPartDate.Text != "")
{
con.Open();
OleDbCommand cmd11 = new OleDbCommand("select Dcode from pis.Designation_table where Designation='" + txtDesg.Text + "' ", con);
var i = cmd11.ExecuteScalar();
//OleDbCommand cmd1 = new OleDbCommand("Update pis.Designation_table set Dcode=i where Designation='" + txtDesg.Text + "'", con);
//var j = cmd1.ExecuteScalar();
OleDbCommand cmd31 = new OleDbCommand("Update Encashment set Fy='" + txtFinYear.Text + "',Cgdate='" + Convert.ToDateTime(txtTrnDate.Text).Date.ToShortDateString() + "',EmpNumber='" + drpName.SelectedValue + "',Dcode='" + i + "',DoptNo='" + txtDoPartNo.Text + "',DoptDate='" + Convert.ToDateTime(txtDoPartDate.Text).Date.ToShortDateString() + "',Pay='" + txtPay.Text + "',Gp='" + txtGp.Text + "',DaRate='" + txtDaRate.Text + "',DAAmt='" + txtDaAmount.Text + "',ElDays='" + txtElEncashDay.Text + "',BillAmt='" + txtElEncashAmount.Text + "',IncomeTax='" + txtIncomeTax.Text + "',Cess='" + txtCess.Text + "',TotalTax='" + txtTotalTax.Text + "',NetAmt='" + txtNetAmount.Text + "' where cgno='" + txtCgNo.Text + "' ", con);
cmd31.ExecuteNonQuery();
//clear();
//drpName.SelectedIndex = -1;
EnableFalse();
con.Close();
ShowMessaage(" Record Saved SucessFully !!!");
btnEdit.Text = "Add";
btnCancel.Visible = false;
btnRemove.Visible = true;
}
else {
lblpmsg.Text = "Record Sholud Not Be Empty !!!";
ModalPopupExtender1.Show();
//ShowMessaage("Record Sholud Not Be Empty !!!");
}
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
foreach (int SelectedFinYear1 in (txtFinYear.Text))
{
SelectedFinYear = Convert.ToInt32(txtFinYear.Text);
}
if (SelectedFinYear > 0)
{
Session["SelectedFinYearid"] = SelectedFinYear;
Response.Redirect("ListOfRecords.aspx");
Session.RemoveAll();
}
else {
DateTime now = DateTime.Now;
SelectedFinYear = Convert.ToInt32(now.ToString("yyyy"));
Session["SelectedFinYearid"] = SelectedFinYear;
Response.Redirect("ListOfRecords.aspx");
Session.RemoveAll();
}
//Response.Redirect("~/ListOfRecords.aspx");
}
protected void drpName_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand("select l.DesignationEmpLinkNo,l.EmpNumber as EmployeeNumber ,e.Name,l.Dcode , d.Designation from pis.DesignationEmpLink_table l inner join pis.Employee_table e on l.EmpNumber = e.EmpNumber inner join pis.Designation_table d on l.Dcode=d.Dcode where e.EmpNumber='" + drpName.SelectedValue + "'", con);
OleDbDataReader dr = cmd.ExecuteReader();
txtDesg.Text = "";
if (dr.Read())
{
txtDesg.Text = dr["Designation"].ToString();
}
txtDesg.DataBind();
con.Close();
}
catch (Exception)
{
throw;
}
}
protected void btnRemove_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand("delete from Encashment where CgNo='" + txtCgNo.Text + "'", con);
cmd.ExecuteNonQuery();
ShowMessaage("Record Deleted Sucessfully");
con.Close();
}
protected void btnPrintCoverLetter_Click(object sender, EventArgs e)
{
if (drpName.Text != "" && txtDesg.Text != "" && txtPay.Text != "" && txtGp.Text != "" && txtBasicPay.Text != "" && txtDaRate.Text != "" && txtIncomeTax.Text != "" && txtCess.Text != "" && txtDoPartNo.Text != "" && txtDoPartDate.Text != "")
{
string html = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/CoveringLetter.html")))
{
html = reader.ReadToEnd();
}
html = html.Replace("{CurrentYear}", txtFinYear.Text);
html = html.Replace("{Name}", drpName.SelectedItem.Text);
html = html.Replace("{Designation}", txtDesg.Text);
html = html.Replace("{DOPartNo}", txtDoPartNo.Text);
html = html.Replace("{DOPtDate}", txtDoPartDate.Text);
html = html.Replace("{CurrentYear}", txtFinYear.Text);
html = html.Replace("{NetAmount}", txtNetAmount.Text);
this.dvHtml.InnerHtml = html;
int startIndex = html.IndexOf("table");
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.dvHtml.RenderControl(hw);
string divHTML = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload = new function(){");
sb.Append("var printWin = window.open('', '', 'left=0");
sb.Append(",top=0,width=1000,height=600,status=0');");
sb.Append("printWin.document.write(\"");
sb.Append(divHTML);
sb.Append("\");");
sb.Append("printWin.document.close();");
sb.Append("printWin.focus();");
sb.Append("printWin.print();");
sb.Append("printWin.close();};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
}
else {
lblpmsg.Text = "Record Should Not Be Blank For Print";
ModalPopupExtender1.Show();
}
}
protected void btnExit_Click(object sender, EventArgs e)
{
//int SelectedFyId = Convert.ToInt32(txtFinYear.Text.ToString());
//Response.Redirect("ListOfRecords.aspx?SelectedFyIdEncashFormTextBox=" + SelectedFyId);
Session.RemoveAll();
Response.Redirect("FinancialYearSelect.aspx");
}
protected void btnChangeFYear_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Response.Redirect("FinancialYearSelect.aspx");
}
public static string ConvertNumbertoWords(int number)
{
if (number == 0)
return "ZERO";
if (number < 0)
return "minus " + ConvertNumbertoWords(Math.Abs(number));
string words = "";
if ((number / 1000000000) > 0)
{
words += ConvertNumbertoWords(number / 1000000000) + " Billion ";
number %= 1000000000;
}
if ((number / 10000000) > 0)
{
words += ConvertNumbertoWords(number / 10000000) + " Crore ";
number %= 10000000;
}
if ((number / 1000000) > 0)
{
words += ConvertNumbertoWords(number / 1000000) + " MILLION ";
number %= 1000000;
}
if ((number / 1000) > 0)
{
words += ConvertNumbertoWords(number / 1000) + " THOUSAND ";
number %= 1000;
}
if ((number / 100) > 0)
{
words += ConvertNumbertoWords(number / 100) + " HUNDRED ";
number %= 100;
}
if (number > 0)
{
if (words != "")
words += "AND ";
var unitsMap = new[] { "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN" };
var tensMap = new[] { "ZERO", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY" };
if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += " " + unitsMap[number % 10];
}
}
return words;
}
protected void btnPrintSanction_Click(object sender, EventArgs e)
{
string word = ConvertNumbertoWords(Convert.ToInt32(txtNetAmount.Text));
//txtNetAmtInWords.Text.InnerText = word;
txtNetAmtInWords.Text = word;
string html = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/SanctionLetter.html")))
{
html = reader.ReadToEnd();
}
html = html.Replace("{CurrentYear}", txtFinYear.Text);
//html = html.Replace("{Name}", drpName.Text);
html = html.Replace("{Name}", drpName.SelectedItem.Text);
html = html.Replace("{Designation}", txtDesg.Text);
html = html.Replace("{DOPartNo}", txtDoPartNo.Text);
html = html.Replace("{DOPtDate}", txtDoPartDate.Text);
html = html.Replace("{CurrentYear}", txtFinYear.Text);
html = html.Replace("{NetAmount}", txtNetAmount.Text);
html = html.Replace("{NetAmountInWords}", txtNetAmtInWords.Text);
this.DvHtmlSanction.InnerHtml = html;
int startIndex = html.IndexOf("table");
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.DvHtmlSanction.RenderControl(hw);
string DvHtmlSanction = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload = new function(){");
sb.Append("var printWin = window.open('', '', 'left=0");
sb.Append(",top=0,width=1000,height=600,status=0');");
sb.Append("printWin.document.write(\"");
sb.Append(DvHtmlSanction);
sb.Append("\");");
sb.Append("printWin.document.close();");
sb.Append("printWin.focus();");
sb.Append("printWin.print();");
sb.Append("printWin.close();};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
}
protected void btnOk_Click(object sender, EventArgs e)
{
//txtFinYear.Text = drpFinYearpop.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void drpFinYear_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void btnPrintBill_Click(object sender, EventArgs e)
{
string word = ConvertNumbertoWords(Convert.ToInt32(txtNetAmount.Text));
//txtNetAmtInWords.Text.InnerText = word;
txtNetAmtInWords.Text = word;
string html = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/BillPrint.html")))
{
html = reader.ReadToEnd();
}
//html = html.Replace("{CurrentYear}", txtFinYear.Text);
html = html.Replace("{Name1}", drpName.SelectedItem.Text);
html = html.Replace("{Designation1}", txtDesg.Text);
html = html.Replace("{DoptNo1}", txtDoPartNo.Text);
html = html.Replace("{DoptDate1}", txtDoPartDate.Text);
html = html.Replace("{Rate}", txtPay.Text);
html = html.Replace("{Name2}", drpName.SelectedItem.Text);
html = html.Replace("{Desgnation2}", txtDesg.Text);
html = html.Replace("{DoPartNo2}", txtDoPartNo.Text);
html = html.Replace("{DoPartDate2}", txtDoPartDate.Text);
html = html.Replace("{NetAmount1}", txtNetAmount.Text);
html = html.Replace("{PAY}", txtPay.Text);
html = html.Replace("{GP}", txtGp.Text);
html = html.Replace("{DA}", txtDaAmount.Text);
html = html.Replace("{Total1}", txtTotal.Text);
//html = html.Replace("{NetAmountInWords}", drpName.Text);
html = html.Replace("{Total2}", txtPay.Text);
html = html.Replace("{Eldays}", txtGp.Text);
html = html.Replace("{NetAmount2}", txtNetAmount.Text);
html = html.Replace("{NetAmount3}", txtNetAmount.Text);
html = html.Replace("{Name3}", drpName.SelectedItem.Text);
html = html.Replace("{Designation3}", txtDesg.Text);
html = html.Replace("{NetAmountInWords}", txtNetAmtInWords.Text);
this.DvHtmlBill.InnerHtml = html;
int startIndex = html.IndexOf("table");
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.DvHtmlBill.RenderControl(hw);
string DvHtmlBill = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload = new function(){");
sb.Append("var printWin = window.open('', '', 'left=0");
sb.Append(",top=0,width=1000,height=600,status=0');");
sb.Append("printWin.document.write(\"");
sb.Append(DvHtmlBill);
sb.Append("\");");
sb.Append("printWin.document.close();");
sb.Append("printWin.focus();");
sb.Append("printWin.print();");
sb.Append("printWin.close();};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
}
protected void drpItPer_SelectedIndexChanged(object sender, EventArgs e)
{
if (txtElEncashAmount.Text != "")
{
if (drpItPer.SelectedValue != "Not Applicable")
{
var IncomeTaxValue = Convert.ToInt32(txtElEncashAmount.Text) * Convert.ToInt32(drpItPer.SelectedValue) / 100;
txtIncomeTax.Text = IncomeTaxValue.ToString();
var f = ((Convert.ToInt32(txtIncomeTax.Text)) * 3 / 100);
txtCess.Text = f.ToString();
var g = ((Convert.ToInt32(txtIncomeTax.Text)) + (Convert.ToInt32(txtCess.Text)));
txtTotalTax.Text = g.ToString();
var a = ((Convert.ToInt32(txtElEncashAmount.Text)) - ((Convert.ToInt32(txtTotalTax.Text))));
txtNetAmount.Text = a.ToString();
txtDoPartNo.Focus();
}
else
{
}
}
else
{
ShowMessaage("Amount Should Not Be Empty !!!");
}
}
protected void txtDoPartNo_TextChanged(object sender, EventArgs e)
{
txtDoPartDate_CalendarExtender.Focus();
}
protected void txtDoPartDate_TextChanged(object sender, EventArgs e)
{
}
protected void txtCbNo_TextChanged(object sender, EventArgs e)
{
}
protected void btnQuit1(object sender, System.EventArgs e)
{
//Response.Write("window.close();")
//this.Response.Write("window.close();");
//Response.Write("<script language="javascript">)");
////Response.Write("<script language=""javascript"">");
//Response.Write("window.close();");
//Response.Write("</script>");
}
protected void btnCancel_Click(object sender, System.EventArgs e)
{
BindControlvalues();
BindComboByCGNo();
btnEdit.Text = "Add";
btnAdd.Text = "Add";
btnCancel.Visible = false;
btnRemove.Visible = true;
EnableFalse();
}
protected void txtNetAmtInWords_TextChanged(object sender, System.EventArgs e)
{
}
protected void txtBasicPay_TextChanged(object sender, System.EventArgs e)
{
var ChkNull = txtBasicPay.Text;
if (ChkNull == "")
{
txtDaRate.Text = "";
txtDaAmount.Text = "";
txtTotal.Text = "";
txtElEncashDay.Text = "";
txtElEncashAmount.Text = "";
drpItPer.SelectedIndex = -1;
txtIncomeTax.Text = "";
txtCess.Text = "";
txtTotalTax.Text = "";
}
}
protected void btnAdd_Click(object sender, System.EventArgs e)
{
if ((btnAdd.Text == "Add"))
{
txtFinYear.Enabled = false;
txtTrnDate.Enabled = true;
// txtCgNo.Enabled = true;
//drpName.SelectedIndex = -1;
// txtDesg.Enabled = true;
txtPay.Enabled = true;
txtGp.Enabled = true;
// txtBasicPay.Enabled = true;
txtDaRate.Enabled = true;
// txtDaAmount.Enabled = true;
//txtTotal.Enabled = true;
// txtElEncashDay.Enabled = true;
//txtElEncashAmount.Enabled = true;
txtIncomeTax.Enabled = true;
txtCess.Enabled = true;
//txtTotalTax.Enabled = true;
// txtNetAmount.Enabled = true;
txtDoPartNo.Enabled = true;
txtDoPartDate.Enabled = true;
btnChangeFYear.Enabled = true;
drpItPer.Enabled = true;
drpName.Enabled = true;
btnEdit.Text = "Save";
btnCancel.Visible = true;
btnRemove.Visible = false;
BindCombo();
IncrementCgNo();
DateTime now = DateTime.Now;
txtTrnDate.Text = now.ToString("dd MMM yyyy");
btnAdd.Text = "Save";
txtCgNo.Enabled = false;
txtFinYear.Text = now.ToString("yyyy");
}
else if (btnAdd.Text == "Save")
{
if (txtFinYear.Text != "" && txtTrnDate.Text != "" && txtCgNo.Text != "" && drpName.Text != "" && txtDesg.Text != "" && txtPay.Text != "" && txtGp.Text != "" && txtBasicPay.Text != "" && txtDaRate.Text != "" && txtIncomeTax.Text != "" && txtCess.Text != "" && txtDoPartNo.Text != "" && txtDoPartDate.Text != "")
{
IncrementCgNo();
con.Open();
OleDbCommand cmd11 = new OleDbCommand("select Dcode from pis.Designation_table where Designation='" + txtDesg.Text + "' ", con);
var i = cmd11.ExecuteScalar();
//OleDbCommand cmd1 = new OleDbCommand("Update pis.Designation_table set Dcode=i where Designation='" + txtDesg.Text + "'", con);
//var j = cmd1.ExecuteScalar();
OleDbCommand cmd31 = new OleDbCommand("insert into Encashment(Fy,cgno,Cgdate,EmpNumber,Dcode,DoptNo,DoptDate,Pay,Gp,DaRate,DAAmt,ElDays,BillAmt,IncomeTax,Cess,TotalTax,NetAmt,itper) values ('" + txtFinYear.Text + "','" + txtCgNo.Text + "','" + Convert.ToDateTime(txtTrnDate.Text).Date.ToShortDateString() + "','" + drpName.SelectedValue + "','" + i + "','" + txtDoPartNo.Text + "','" + Convert.ToDateTime(txtDoPartDate.Text).Date.ToShortDateString() + "','" + txtPay.Text + "','" + txtGp.Text + "','" + txtDaRate.Text + "','" + txtDaAmount.Text + "','" + txtElEncashDay.Text + "','" + txtElEncashAmount.Text + "','" + txtIncomeTax.Text + "','" + txtCess.Text + "','" + txtTotalTax.Text + "','" + txtNetAmount.Text + "','"+drpItPer.SelectedItem+"') ", con);
cmd31.ExecuteNonQuery();
lblpmsg.Text = "Record Saved SucessFully !!!";
ModalPopupExtender1.Show();
//clear();
//drpName.SelectedIndex = -1;
EnableFalse();
con.Close();
//ShowMessaage(" Record Saved SucessFully !!!");
btnAdd.Text = "Add";
btnCancel.Visible = false;
btnRemove.Visible = true;
int id = Convert.ToInt32(txtCgNo.Text);
Session["userid"] = id;
Response.Redirect("BillPrepare.aspx");
Session.RemoveAll();
Session["userid"] = id;
Response.Redirect("Send To JCDA.aspx");
Session.RemoveAll();
//lblpmsg.Text = "Record Saved SucessFully !!!";
//ModalPopupExtender1.Show();
}
else {
lblpmsg.Text = "Record Sholud Not Be Empty !!!";
ModalPopupExtender1.Show();
//ShowMessaage("Record Sholud Not Be Empty !!!");
}
}
}
protected void btnpopYes_Click(object sender, System.EventArgs e)
{
if(Convert.ToInt32(txtCgNo.Text) > 0)
{
con.Open();
OleDbCommand cmd = new OleDbCommand("delete from Encashment where CgNo='" + txtCgNo.Text + "'", con);
cmd.ExecuteNonQuery();
ShowMessaage("Record Deleted Sucessfully");
con.Close();
clear();
txtCgNo.Text = "0";
}
else{
}
}
protected void btnPopNo_Click(object sender, System.EventArgs e)
{
}
protected void btnRemove_Click1(object sender, System.EventArgs e)
{
if (Convert.ToInt32(txtCgNo.Text) > 0)
{
lblMsgPopY.Text = "Do you want to Remove Record ";
ModalPopupExtender2.Show();
}
else
{
lblpmsg.Text = "Select Record For Remove !!!";
ModalPopupExtender1.Show();
}
}
}
}