Outstanding

Published on July 2016 | Categories: Documents | Downloads: 46 | Comments: 0 | Views: 313
of 9
Download PDF   Embed   Report

Comments

Content


alter view In_Cust
as
select d.Customer_Name,
a.Company_name_details,convert(varchar,(convert(datetime,b.Events_Adv_Invoice_Da
te)),106) as In_Date,
convert(varchar,(convert(datetime,b.Events_Adv_Billing_From_Date)),106) as From_
Date,
convert(varchar,(convert(datetime,b.Events_Adv_Billing_To_Date)),106) as To_Date
,
b.Events_Adv_Invoice_No,
b.Events_Adv_Month,b.Events_Adv_Total_Invoice_Amount,
b.Events_Total_Rental,
(convert(char(5),e.Receipts_Vch_No)+''+(convert(char(5),e.Receipts_Vch_Dt))) as
Payment_Details
from Company_Name_Details a,Events_Advertisement_Invoice b,Adv_Order_Agreement_M
aster c,
Enquiry_Advertisement_Master d,Accounts_Receipts_Root e where a.Company_code=b.C
ompany_code and
a.Company_code=e.Company_code and d.Enquiry_No=c.Enquiry_No and b.Adv_Order_No=c
.Adv_Order_No

select * from In_Cust where Customer_Name='SUNIL' and Company_name_details='comp
any03' and From_Date='07 Apr 2011' and To_Date='08 Apr 2011'
================================================================================
================
alter view All_Cust
as
select
d.Customer_Name,
a.Company_code,
b.Events_Adv_Invoice_No,
b.Events_Adv_Month,b.Events_Adv_Total_Invoice_Amount,
b.Events_Total_Rental,
convert(varchar,(convert(datetime,b.Events_Adv_Invoice_Date)),106) as In_Date,
convert(varchar,(convert(datetime,b.Events_Adv_Billing_From_Date)),106) as From_
Date,
convert(varchar,(convert(datetime,b.Events_Adv_Billing_To_Date)),106) as To_Date
,
(convert(char(5),e.Receipts_Vch_No)+''+(convert(char(5),e.Receipts_Vch_Dt))) as
Payment_Details
from Company_Name_Details a,Events_Advertisement_Invoice b,Adv_Order_Agreement_M
aster c,
Enquiry_Advertisement_Master d,Accounts_Receipts_Root e where a.Company_code=b.C
ompany_code and
a.Company_code=e.Company_code and d.Enquiry_No=c.Enquiry_No and b.Adv_Order_No=c
.Adv_Order_No
select * from All_Cust where Company_code= 'C01'and Customer_Name='PRAVEENA' and
From_Date='01 Mar 2011' and To_Date='22 Mar 2011'
select * from All_Cust where From_Date='01 Mar 2011' and To_Date='22 Mar 2011'
=================================================================
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
public partial class Report_Advertisement_and_Rental_Outstanding_Report : System
.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings
["erpdata"].ConnectionString);
SqlCommand cmd = new SqlCommand();
SqlDataAdapter adp = new SqlDataAdapter();
SqlDataReader dr2;
string query;
decimal price_sum;
decimal price_sum1;
decimal price_sum2;
protected void Page_Load(object sender, EventArgs e)
{
Label5.Visible = false; Label15.Visible = false;
Label6.Visible = false; Label16.Visible = false;
Label7.Visible = false; Label17.Visible = false;
Label8.Visible = false; Label18.Visible = false;
Lab_cust.Visible = false; Label19.Visible = false;
ddl_customer.Visible = false; lblmsg.Visible = false;
Label23.Visible = false;
Label24.Visible = false;
if (!Page.IsPostBack)
{
con.Open();
cmd = new SqlCommand("Select Company_code,Company_name_details from
Company_Name_Details Order By Company_name_details asc", con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
ddl_company.DataSource = dr;
ddl_company.DataTextField = "Company_name_details";
ddl_company.DataValueField = "Company_code";
ddl_company.DataBind();
ddl_company.Items.Insert(0, "--select--");
ddl_company.Items.Insert(1, "--All--");
con.Close();
}
}
protected void bnt_View_Click(object sender, ImageClickEventArgs e)
{
Repeater2.DataSource = null;
Repeater2.DataBind();
Repeater3.DataSource = null;
Repeater3.DataBind();
if (rbtsummary.Checked == true && rbtcust.Checked == false)
{
if (ddl_company.SelectedIndex == 1)
{
Label6.Visible = true; Label5.Visible = true;
Label8.Visible = true; Label7.Visible = true;
Lab_cust.Visible = false; Label23.Visible = true; FormView1.Visible
= true;
query = "select * from All_Cust where From_Date='" + txt_fromdate.Te
xt + "' and To_Date='" + txt_todate.Text + "'";
con.Open();
cmd = new SqlCommand(query, con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ada = new SqlDataAdapter(query, con);
DataSet dset = new DataSet();
ada.Fill(dset);
if (dset.Tables[0].Rows.Count != 0)
{
Repeater3.DataSource = dset;
Repeater3.DataBind();
FormView1.DataSource = dset;
FormView1.DataBind();
Label6.Text = txt_fromdate.Text;
Label8.Text = txt_todate.Text;
Panel1.Visible = true;
}
else
{
ddl_customer.Visible = false; FormView1.Visible = false;
lblmsg.Visible = true; lblmsg.Text = "No Data Found";

}
con.Close();
}
else
{
ddl_customer.Visible = false; FormView1.Visible = false;
lblmsg.Visible = true; lblmsg.Text = "No Data Found";

}
}
else if (rbtcust.Checked == true && rbtsummary.Checked == false)
{
string a = ddl_customer.Text.ToString();
if (ddl_company.SelectedIndex != 1 & ddl_customer.SelectedIndex != 0)
{
Label16.Visible = true; Label15.Visible = true;
Label18.Visible = true; Label17.Visible = true;
Label19.Visible = true; FormView2.Visible = true;
FormView1.Visible = false; Label24.Visible = true; ddl_customer.Visi
ble = true;
query = "select * from All_Cust where Company_name_details='" + ddl_
company.SelectedItem.ToString() + "' and Customer_Name='" + a + "' and From_Date
='" + txt_fromdate.Text + "' and To_Date='" + txt_todate.Text + "'";
con.Open();
cmd = new SqlCommand(query, con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ada = new SqlDataAdapter(query, con);
DataSet dset = new DataSet();
ada.Fill(dset);
if (dset.Tables[0].Rows.Count != 0)
{
Repeater2.DataSource = dset;
Repeater2.DataBind();
FormView2.DataSource = dset;
FormView2.DataBind();
Label16.Text = txt_fromdate.Text;
Label18.Text = txt_todate.Text;
Label20.Text = ddl_customer.SelectedItem.ToString();
}
else
{
FormView2.Visible = false;
ddl_customer.Visible = false;
Label20.Visible = false; Label15.Visible = false;
Label16.Visible = false; Label17.Visible = false; Label18.Visibl
e = false;
lblmsg.Visible = true; lblmsg.Text = "No Data Found";

}
con.Close();
}
else
{
FormView2.Visible = false;
ddl_customer.Visible = false; Label24.Visible = false;
Label20.Visible = false; Label15.Visible = false;
Label16.Visible = false; Label17.Visible = false; Label18.Visibl
e = false;
lblmsg.Visible = true; lblmsg.Text = "No Data Found";
}
//else if (ddl_customer.SelectedIndex == 0)

}
}


public override void VerifyRenderingInServerForm(Control control)
{
}
protected void Repeater3_ItemDataBound(object sender, RepeaterItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Header)
{
price_sum = 0;
}
else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == List
ItemType.AlternatingItem)
{
price_sum +=
(decimal)((DataRowView)e.Item.DataItem)["Events_Adv_Total_Invoice_Amo
unt"];
}
else if (e.Item.ItemType == ListItemType.Footer)
{
Label lblSum = e.Item.FindControl("lbltotal") as Label;
lblSum.Text = " " + price_sum;
}
}
protected void Repeater2_ItemDataBound1(object sender, RepeaterItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Header)
{
price_sum = 0;
price_sum1 = 0;
price_sum2 = 0;
}
else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == List
ItemType.AlternatingItem)
{
price_sum +=
(decimal)((DataRowView)e.Item.DataItem)["Events_Adv_Total_Invoice_Amou
nt"];
price_sum1 +=
(decimal)((DataRowView)e.Item.DataItem)["Events_Total_Rental"];
price_sum2 +=
(decimal)((DataRowView)e.Item.DataItem)["Balance"];
}
else if (e.Item.ItemType == ListItemType.Footer)
{
Label lblSum = e.Item.FindControl("lbltot") as Label;
lblSum.Text = " " + price_sum;
Label lblSum1 = e.Item.FindControl("lbltot1") as Label;
lblSum1.Text = " " + price_sum1;
Label lblSum2 = e.Item.FindControl("lbltot2") as Label;
lblSum2.Text = " " + price_sum2;
}
}
protected void ddl_company_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("select a.Customer_Name,b.Company_Code,b.Company_na
me_details from Enquiry_Advertisement_Master a,Company_Name_Details b where b.Co
mpany_name_details='" + ddl_company.SelectedItem.ToString() + "'", con);
dr2 = cmd.ExecuteReader();
ddl_customer.DataSource = dr2;
ddl_customer.DataBind();
ddl_customer.Items.Insert(0, "Select ");
ddl_customer.Items.Insert(1, "All ");
con.Close();
string a = ddl_customer.Text.ToString();
}
protected void btn_doc_Click(object sender, ImageClickEventArgs e)
{
if (rbtsummary.Checked == true && rbtcust.Checked == false)
{
Label6.Visible = true; Label5.Visible = true;
Label8.Visible = true; Label7.Visible = true;
Label23.Visible = true;
}
else if(rbtcust.Checked==true && rbtsummary.Checked==false)
{
Label19.Visible = true; Label20.Visible = true;
Label24.Visible = true;Label16.Visible = true; Label15.Visible = true;
Label18.Visible = true; Label17.Visible = true;
}
try
{
string attachment = "attachment; filename=Contacts.doc";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-word";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Panel1.RenderControl(htw);
Panel2.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception)
{
//throw;
Type ob = this.GetType();
ClientScript.RegisterStartupScript(ob, "", "<script/type='text/javascrip
t'>alert('No Report Found');</script>");
}
}
protected void btn_Excel_Click(object sender, ImageClickEventArgs e)
{
if (rbtsummary.Checked == true && rbtcust.Checked == false)
{
Label6.Visible = true; Label5.Visible = true;
Label8.Visible = true; Label7.Visible = true;
Label23.Visible = true;
}
else if (rbtcust.Checked == true && rbtsummary.Checked == false)
{
Label19.Visible = true; Label20.Visible = true;
Label24.Visible = true; Label16.Visible = true; Label15.Visible = tr
ue;
Label18.Visible = true; Label17.Visible = true;
}
try
{
string attachment = "attachment; filename=Contacts.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Panel1.RenderControl(htw);
Panel2.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception)
{
//throw;
Type ob = this.GetType();
ClientScript.RegisterStartupScript(ob, "", "<script/type='text/javas
cript'>alert('No Report Found');</script>");
}
}
protected void btn_Pdf_Click(object sender, ImageClickEventArgs e)
{
if (rbtsummary.Checked == true && rbtcust.Checked == false)
{
Label6.Visible = true; Label5.Visible = true;
Label8.Visible = true; Label7.Visible = true;
Label23.Visible = true;
}
else if (rbtcust.Checked == true && rbtsummary.Checked == false)
{
Label19.Visible = true; Label20.Visible = true;
Label24.Visible = true; Label16.Visible = true; Label15.Visible = tr
ue;
Label18.Visible = true; Label17.Visible = true;
}
try
{
string attachment = "attachment; filename=Contacts.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Panel1.RenderControl(htw);
Panel2.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception)
{
//throw;
Type ob = this.GetType();
ClientScript.RegisterStartupScript(ob, "", "<script/type='text/javas
cript'>alert('No Report Found');</script>");
}
}
protected void btn_Print_Click(object sender, ImageClickEventArgs e)
{
if (rbtsummary.Checked == true && rbtcust.Checked == false)
{
Label6.Visible = true; Label5.Visible = true;
Label8.Visible = true; Label7.Visible = true;
Label23.Visible = true;
}
else if (rbtcust.Checked == true && rbtsummary.Checked == false)
{
Label19.Visible = true; Label20.Visible = true;
Label24.Visible = true; Label16.Visible = true; Label15.Visible = tr
ue;
Label18.Visible = true; Label17.Visible = true;
}
{
Session["print"] = PanMain;
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script l
anguage=javascript>window.open('TestOrderForm.aspx','PrintMe','height=300px,widt
h=300px,scrollbars=1');</script>");
Control ctrl = (Control)Session["print"];
PrintWebControl(ctrl);
}
}
public void PrintHelper()
{
}
public static void PrintWebControl(Control ctrl)
{
PrintWebControl(ctrl, string.Empty);
}
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWrite
r(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Widt
h = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript
", Script);
}
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
protected void rbtcust_CheckedChanged(object sender, EventArgs e)
{
ddl_customer.Visible = true;

}
protected void btn_clear_Click(object sender, ImageClickEventArgs e)
{
Repeater2.DataSource = null;
Repeater2.DataBind();
Repeater3.DataSource = null;
Repeater3.DataBind();
Label20.Visible = false;
FormView1.Visible = false;
FormView2.Visible = false;
}
}

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close