Inbox.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Marketing/admin.master" EnableEventValidation="true"
AutoEventWireup="true" CodeFile="Inbox.aspx.cs" Inherits="Marketing_Default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<input id="hdndranch" runat="server" type="hidden" />
<input id="hdnmanager" runat="server" type="hidden" />
<table align="center" class="ad_txt_border" width="700">
<tr>
<td bgcolor="#3399FF" class="ad_head" style="height: 20px" width="20">
<img id="IMG1" src="../images/download_arrow_icon.gif" />Inbox
</td>
<td bgcolor="#3399FF" class="ad_head" style="height: 20px">
</td>
</tr>
<tr>
<td bgcolor="" class="ad_head" style="height: 20px" width="20">
<td bgcolor="" class="ad_head" style="height: 20px">
</td>
</tr>
<tr>
<td class="txt" colspan="2">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%"
DataKeyNames="Id" BackColor="WhiteSmoke" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="" HeaderStyle-BackColor="#3399FF">
<ItemTemplate>
<asp:Label ID="lblfrom" runat="server" Text='<%# Eval("MailFrom") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" HeaderStyle-BackColor="#3399FF">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" Font-Underline="false" runat="server" CommandName='<%# Eval("Id") %>'
Text='<%# Eval("Subject") %>' OnCommand="TabChange"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" HeaderStyle-BackColor="#3399FF">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Visible="false" Text='<%# Eval("status") %>'></asp:Label>
<asp:Label ID="lblfname" runat="server" Visible="false" Text='<%# Eval("Filename") %>'></asp:Label>
<asp:Image ID="imgattach" ImageUrl="~/images/paperclip.gif" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:MultiView ID="MultiView1" runat="server" Visible="false">
<asp:View ID="View1" runat="server">
<asp:Table ID="Table2" runat="server" BorderWidth="1" Width="100%">
<asp:TableRow>
<asp:TableCell>
<asp:Image ID="Image1" ImageUrl="~/images/star_off_sm_2.gif" runat="server" />
<asp:TextBox ID="txtfrom" BorderStyle="None" Width="500px" Text="Renju John <renjujohn.2@gmail.com>"
runat="server"></asp:TextBox>
<asp:TextBox ID="txtdate" BorderStyle="None" Width="500px" Text="Wed, Jul 18, 2012 at 4:28 PM"
runat="server"></asp:TextBox>
<br />
To:
<asp:TextBox ID="txtto" BorderStyle="None" Text="suni <sunichand2000@gmail.com>"
Width="500px" runat="server"></asp:TextBox>
<br />
<asp:LinkButton ID="lbreply" runat="server">Reply</asp:LinkButton>
<asp:LinkButton ID="lbdelete" OnCommand="delete_click" runat="server">Delete</asp:LinkButton>
<asp:LinkButton ID="lbinbox" OnCommand="inbox_click" runat="server">Inbox</asp:LinkButton>
<br />
<asp:TextBox ID="txtbody" BorderStyle="None" TextMode="MultiLine" Width="700px" Height="200px"
runat="server"></asp:TextBox>
<br />
<asp:Label ID="lblattach" runat="server" Text="Label" Visible="false"></asp:Label>
<asp:HyperLink ID="hldownload" runat="server" Visible="false">Download</asp:HyperLink>
<asp:HyperLink ID="hlview" runat="server" Visible="false">View</asp:HyperLink>
<br />
<br />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:View>
</asp:MultiView>
</td>
</tr>
</table>
</asp:Content>
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Web.Mail;
using System.IO;
using System.Drawing;
using System.Diagnostics;
public partial class Marketing_Default2 : System.Web.UI.Page
{
Class1 cls = new Class1();
int cid;
connectionClass.connectionClass db = new connectionClass.connectionClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
hdndranch.Value = Request.QueryString["branch"].ToString();
hdnmanager.Value = Request.QueryString["manager"].ToString();
gridbind();
}
}
public void gridbind()
{
if (cls.con.State == ConnectionState.Closed)
{
cls.con.Open();
}
SqlDataAdapter da = new SqlDataAdapter("select * from mail where ToType='Marketing Desk'", cls.con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
foreach (GridViewRow row in GridView1.Rows)
{
Label lblstatus = (Label)row.FindControl("lblstatus");
Label lblfname = (Label)row.FindControl("lblfname");
System.Web.UI.WebControls.Image imgattach = (System.Web.UI.WebControls.Image)row.FindControl("imgattach");
if (lblstatus.Text == "False")
{
row.BackColor = System.Drawing.Color.White;
}
else
{
row.BackColor = System.Drawing.Color.Gray;
}
if (lblfname.Text == "")
{
imgattach.Visible = false;
}
else
{
imgattach.Visible = true;
}
}
}
protected void TabChange(object sender, CommandEventArgs e)
{
string id = e.CommandName;
SqlDataAdapter da = new SqlDataAdapter("select * from mail where ToType='Marketing Desk' and id='" + id + "'", cls.con);
DataSet ds = new DataSet();
da.Fill(ds);
LinkButton lb = (LinkButton)sender;
if (lb.ID == "LinkButton1")
{
MultiView1.ActiveViewIndex = 0;
MultiView1.Visible = true;
txtfrom.Text = ds.Tables[0].Rows[0]["MailFrom"].ToString();
txtto.Text = ds.Tables[0].Rows[0]["MailTo"].ToString();
txtbody.Text = ds.Tables[0].Rows[0]["MailContent"].ToString();
txtdate.Text = ds.Tables[0].Rows[0]["Date"].ToString();
lbdelete.CommandArgument = id;
if (ds.Tables[0].Rows[0]["Filename"].ToString() != "")
{
lblattach.Text = ds.Tables[0].Rows[0]["Filename"].ToString();
lblattach.Visible = true;
hldownload.Visible = true;
hlview.Visible = true;
hldownload.NavigateUrl = "~/Marketing/DownloadFile.aspx?Id="+id+"&branch=" + hdndranch.Value + "&manager=" + hdnmanager.Value;
hlview.NavigateUrl = "~/Marketing/DownloadFile.aspx?Id="+id+"&branch=" + hdndranch.Value + "&manager=" + hdnmanager.Value;
}
GridView1.Visible = false;
db.executeNonQuery("update mail set status='1' where id='" + id + "' and ToType='Marketing Desk'", cls.conStr);
db.close();
}
else if (lb.ID == "LinkButton2")
{
MultiView1.ActiveViewIndex = 1;
}
else if (lb.ID == "LinkButton3")
{
MultiView1.ActiveViewIndex = 2;
}
}
public void delete_click(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
try
{
int id = Convert.ToInt16(e.CommandArgument);
db.executeNonQuery("delete from mail where id='" + id + "' and ToType='Marketing Desk'", cls.conStr);
db.close();
gridbind();
}
catch (Exception ex)
{
}
}
public void inbox_click(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
try
{
GridView1.Visible = true;
MultiView1.Visible = false;
}
catch (Exception ex)
{
}
}
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkTest = (CheckBox)sender;
GridViewRow grdRow = (GridViewRow)chkTest.NamingContainer;
grdRow.BackColor = Color.Red;
Label lblfrom = (Label)grdRow.FindControl("lblfrom");
Label lblto = (Label)grdRow.FindControl("lblto");
if (chkTest.Checked)
{
lblfrom.ForeColor = System.Drawing.Color.Black;
lblto.ForeColor = System.Drawing.Color.Black;
}
else
{
grdRow.BackColor = Color.White;
lblfrom.ForeColor = System.Drawing.Color.Blue;
lblto.ForeColor = System.Drawing.Color.Blue;
}
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow rs in GridView1.Rows)
{
CheckBox chkUncheck = (CheckBox)
rs.FindControl("chkSelect");
if (chkUncheck.Checked)
{ chkUncheck.Checked = false; }
else
{ chkUncheck.Checked = true; }
}
}
}
<%@ Page Title="" Language="C#" MasterPageFile="~/Marketing/admin.master" EnableEventValidation="true"
AutoEventWireup="true" CodeFile="Inbox.aspx.cs" Inherits="Marketing_Default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<input id="hdndranch" runat="server" type="hidden" />
<input id="hdnmanager" runat="server" type="hidden" />
<table align="center" class="ad_txt_border" width="700">
<tr>
<td bgcolor="#3399FF" class="ad_head" style="height: 20px" width="20">
<img id="IMG1" src="../images/download_arrow_icon.gif" />Inbox
</td>
<td bgcolor="#3399FF" class="ad_head" style="height: 20px">
</td>
</tr>
<tr>
<td bgcolor="" class="ad_head" style="height: 20px" width="20">
<td bgcolor="" class="ad_head" style="height: 20px">
</td>
</tr>
<tr>
<td class="txt" colspan="2">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%"
DataKeyNames="Id" BackColor="WhiteSmoke" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="" HeaderStyle-BackColor="#3399FF">
<ItemTemplate>
<asp:Label ID="lblfrom" runat="server" Text='<%# Eval("MailFrom") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" HeaderStyle-BackColor="#3399FF">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" Font-Underline="false" runat="server" CommandName='<%# Eval("Id") %>'
Text='<%# Eval("Subject") %>' OnCommand="TabChange"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" HeaderStyle-BackColor="#3399FF">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Visible="false" Text='<%# Eval("status") %>'></asp:Label>
<asp:Label ID="lblfname" runat="server" Visible="false" Text='<%# Eval("Filename") %>'></asp:Label>
<asp:Image ID="imgattach" ImageUrl="~/images/paperclip.gif" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:MultiView ID="MultiView1" runat="server" Visible="false">
<asp:View ID="View1" runat="server">
<asp:Table ID="Table2" runat="server" BorderWidth="1" Width="100%">
<asp:TableRow>
<asp:TableCell>
<asp:Image ID="Image1" ImageUrl="~/images/star_off_sm_2.gif" runat="server" />
<asp:TextBox ID="txtfrom" BorderStyle="None" Width="500px" Text="Renju John <renjujohn.2@gmail.com>"
runat="server"></asp:TextBox>
<asp:TextBox ID="txtdate" BorderStyle="None" Width="500px" Text="Wed, Jul 18, 2012 at 4:28 PM"
runat="server"></asp:TextBox>
<br />
To:
<asp:TextBox ID="txtto" BorderStyle="None" Text="suni <sunichand2000@gmail.com>"
Width="500px" runat="server"></asp:TextBox>
<br />
<asp:LinkButton ID="lbreply" runat="server">Reply</asp:LinkButton>
<asp:LinkButton ID="lbdelete" OnCommand="delete_click" runat="server">Delete</asp:LinkButton>
<asp:LinkButton ID="lbinbox" OnCommand="inbox_click" runat="server">Inbox</asp:LinkButton>
<br />
<asp:TextBox ID="txtbody" BorderStyle="None" TextMode="MultiLine" Width="700px" Height="200px"
runat="server"></asp:TextBox>
<br />
<asp:Label ID="lblattach" runat="server" Text="Label" Visible="false"></asp:Label>
<asp:HyperLink ID="hldownload" runat="server" Visible="false">Download</asp:HyperLink>
<asp:HyperLink ID="hlview" runat="server" Visible="false">View</asp:HyperLink>
<br />
<br />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:View>
</asp:MultiView>
</td>
</tr>
</table>
</asp:Content>
Inbox.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Web.Mail;
using System.IO;
using System.Drawing;
using System.Diagnostics;
public partial class Marketing_Default2 : System.Web.UI.Page
{
Class1 cls = new Class1();
int cid;
connectionClass.connectionClass db = new connectionClass.connectionClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
hdndranch.Value = Request.QueryString["branch"].ToString();
hdnmanager.Value = Request.QueryString["manager"].ToString();
gridbind();
}
}
public void gridbind()
{
if (cls.con.State == ConnectionState.Closed)
{
cls.con.Open();
}
SqlDataAdapter da = new SqlDataAdapter("select * from mail where ToType='Marketing Desk'", cls.con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
foreach (GridViewRow row in GridView1.Rows)
{
Label lblstatus = (Label)row.FindControl("lblstatus");
Label lblfname = (Label)row.FindControl("lblfname");
System.Web.UI.WebControls.Image imgattach = (System.Web.UI.WebControls.Image)row.FindControl("imgattach");
if (lblstatus.Text == "False")
{
row.BackColor = System.Drawing.Color.White;
}
else
{
row.BackColor = System.Drawing.Color.Gray;
}
if (lblfname.Text == "")
{
imgattach.Visible = false;
}
else
{
imgattach.Visible = true;
}
}
}
protected void TabChange(object sender, CommandEventArgs e)
{
string id = e.CommandName;
SqlDataAdapter da = new SqlDataAdapter("select * from mail where ToType='Marketing Desk' and id='" + id + "'", cls.con);
DataSet ds = new DataSet();
da.Fill(ds);
LinkButton lb = (LinkButton)sender;
if (lb.ID == "LinkButton1")
{
MultiView1.ActiveViewIndex = 0;
MultiView1.Visible = true;
txtfrom.Text = ds.Tables[0].Rows[0]["MailFrom"].ToString();
txtto.Text = ds.Tables[0].Rows[0]["MailTo"].ToString();
txtbody.Text = ds.Tables[0].Rows[0]["MailContent"].ToString();
txtdate.Text = ds.Tables[0].Rows[0]["Date"].ToString();
lbdelete.CommandArgument = id;
if (ds.Tables[0].Rows[0]["Filename"].ToString() != "")
{
lblattach.Text = ds.Tables[0].Rows[0]["Filename"].ToString();
lblattach.Visible = true;
hldownload.Visible = true;
hlview.Visible = true;
hldownload.NavigateUrl = "~/Marketing/DownloadFile.aspx?Id="+id+"&branch=" + hdndranch.Value + "&manager=" + hdnmanager.Value;
hlview.NavigateUrl = "~/Marketing/DownloadFile.aspx?Id="+id+"&branch=" + hdndranch.Value + "&manager=" + hdnmanager.Value;
}
GridView1.Visible = false;
db.executeNonQuery("update mail set status='1' where id='" + id + "' and ToType='Marketing Desk'", cls.conStr);
db.close();
}
else if (lb.ID == "LinkButton2")
{
MultiView1.ActiveViewIndex = 1;
}
else if (lb.ID == "LinkButton3")
{
MultiView1.ActiveViewIndex = 2;
}
}
public void delete_click(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
try
{
int id = Convert.ToInt16(e.CommandArgument);
db.executeNonQuery("delete from mail where id='" + id + "' and ToType='Marketing Desk'", cls.conStr);
db.close();
gridbind();
}
catch (Exception ex)
{
}
}
public void inbox_click(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
try
{
GridView1.Visible = true;
MultiView1.Visible = false;
}
catch (Exception ex)
{
}
}
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkTest = (CheckBox)sender;
GridViewRow grdRow = (GridViewRow)chkTest.NamingContainer;
grdRow.BackColor = Color.Red;
Label lblfrom = (Label)grdRow.FindControl("lblfrom");
Label lblto = (Label)grdRow.FindControl("lblto");
if (chkTest.Checked)
{
lblfrom.ForeColor = System.Drawing.Color.Black;
lblto.ForeColor = System.Drawing.Color.Black;
}
else
{
grdRow.BackColor = Color.White;
lblfrom.ForeColor = System.Drawing.Color.Blue;
lblto.ForeColor = System.Drawing.Color.Blue;
}
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow rs in GridView1.Rows)
{
CheckBox chkUncheck = (CheckBox)
rs.FindControl("chkSelect");
if (chkUncheck.Checked)
{ chkUncheck.Checked = false; }
else
{ chkUncheck.Checked = true; }
}
}
}
2 comments:
can u post ur screenshot for this inbox program?
can u post ur screenshot for this inbox program???
Post a Comment