Hi indradeo,
Refer below code.
HTML
<form id="form1" runat="server">
<table width="100%" height="30" border="1" cellpadding="1" cellspacing="1" align="center">
<tr bgcolor="#3090C7">
<td class="auto-style4"> <img src="image/m1.png" class="auto-style1" />
</td>
<th colspan="5" class="auto-style3">
<u><span class="auto-style8">
<font color="white" class="auto-style9"><strong class="auto-style12">COMPLAINT MANAGEMENT SYSTEM</strong></font></span></u>
<marquee attribute_name="attribute_value">For any assistance please contact 3126 or mail to munplit@ntpc.co.in</marquee>
</th>
<th class="auto-style3">
<script type="text/javascript">
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var day1 = currentTime.getDay()
if (day1 == 1)
document.write("Monday")
else if (day1 == 2)
document.write("Tuesday")
else if (day1 == 3)
document.write("Wednesday")
else if (day1 == 4)
document.write("Thursday")
else if (day1 == 5)
document.write("Friday")
else if (day1 == 6)
document.write("Saturday")
else if (day1 == 7)
document.write("Sunday"
)
document.write(" " + day + "/" + month + "/" + year)
</script>
<br />
<strong>
<br />
Emp. Id:
<asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
<br />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CssClass="auto-style7">BACK</asp:LinkButton>
</strong>
</th>
</tr>
</table>
<table border="1">
<tr>
<td>
<h4>COMPLAINT CATEGORY</h4>
<select name="cat" size="1" onchange="redirect(this.options.selectedIndex);SetMessage();">
<option value="0" selected="selected">Select a category</option>
<option value=""></option>
<option value="--">-----------------------------------------</option>
<option value="PC -">PC</option>
<option value="Printer -">Printer</option>
<option value="Phone">Phone</option>
<option value="Scanner -">Scanner</option>
<option value="UPS -">UPS</option>
<option value="Network -">Network</option>
<option value="Application -">Application</option>
<option value="Software -">Software</option>
<option value="General -">General</option>
<option value="ERP -">ERP</option>
<option value="Mail -">Mail</option>
</select>
</td>
<td>
<div name="dvPrinter" style="display: none;">
<h4>PRINTER TYPE:</h4>
<select name="printer" size="1" onchange="SetMessage()">
<option value="0" selected="selected">Select a category</option>
<option value=""></option>
<option value="--">-----------------------------------------</option>
<option value="Personal -">Personal</option>
<option value="Common -">Common</option>
</select>
</div>
</td>
<td>
<h4>TYPE</h4>
<select name="type" size="1" onchange="SetMessage()"></select>
</td>
<td>
<div name="Location">
<h4>LOCATION:</h4>
<select name="Location" size="1" onchange="SetMessage()">
<option value="0" selected="selected">Select a category</option>
<option value=""></option>
<option value="--">-----------------------------------------</option>
<option value="H-type">H-type</option>
<option value="DM Plant -">DM Plant</option>
<option value="Service Building -">Service Building </option>
<option value="MGR">MGR</option>
<option value="CHP">CHP</option>
<option value="CCD Township">CCD Township</option>
<option value="Hospital Township">Hospital Township</option>
<option value="Switchyard">Switchyard</option>
<option value="Kanta">Kanta</option>
<option value="Main Gate Plant">Main Gate Plant</option>
<option value="AHP">AHP</option>
<option value="UPL Office">UPL Office</option>
<option value="CCR">CCR</option>
<option value="Fire Station">Fire Station</option>
<option value="Guest House">Guest House</option>
<option value="Township">Township</option>
<option value="Safety Park">Safety Park</option>
</select>
</div>
</td>
<td>
<h4>Image File:</h4>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<script type="text/javascript">
var groups = document.forms.form1.cat.length
var group = new Array(groups)
for (i = 0; i < groups; i++)
group[i] = new Array()
group[3][0] = new Option("CD/DVD/Pen--Drive/Writer not working", "CD/DVD/Pen--Drive/Writer problem")
group[3][1] = new Option("Monitor problem", "Monitor problem")
group[3][2] = new Option("Keyboard Problem", "Keyboard Problem")
group[3][3] = new Option("Mouse Problem", "Mouse Problem")
group[3][4] = new Option("PC Not Booting", "Booting Problem")
group[3][5] = new Option("PC Running slow", "PC Running slow")
group[3][6] = new Option("PC Connection Problem", "PC Connection Problem")
group[3][7] = new Option("PC Shifting", "PC Connection Problem")
group[4][0] = new Option("Paper Jam Problem", "Paper Jam Problem")
group[4][1] = new Option("Printer not Installed/Issue", "Installation/Driver Issue")
group[4][2] = new Option("Garbage/Junk Printing Problem", "Garbage Printing Problem")
group[4][3] = new Option("Red LED/Error Light Blinking ", "Printer Error(Red LED)")
group[5][0] = new Option("Intercom Dead", "Intercom Dead")
group[5][1] = new Option("Landline Dead", "Landline Dead")
group[5][2] = new Option("Phone Set Problem", "Phone Set Problem")
group[5][3] = new Option("Line shifting", "Line shifting")
group[6][0] = new Option("Device Connectivity Error", "Connectivity Problem")
group[6][1] = new Option("Driver Installation/Issue", "Driver problem")
group[6][2] = new Option("Not scanning Properly", "Function Problem")
group[7][0] = new Option("Cannot Start", "On/Off Problem")
group[7][1] = new Option("Not giving Backup", "Backup Problem")
group[7][2] = new Option("DG Set Switching Problem", "DG Set Switch problem")
group[7][3] = new Option("eProcurement System")
group[8][0] = new Option("Internet not working", "Internet Problem")
group[8][1] = new Option("Intranet not opening", "Intranet problem")
group[8][2] = new Option("Links/Peoplesoft does not open", "Links Problem")
group[8][3] = new Option("Internet/Intranet Slow", "Intranet/Internet slow speed Problem")
group[9][0] = new Option("Complaint Management Sys. not working", "IT Assets sys. Problem")
group[9][1] = new Option("E-Workspace not working", "E-Workspace Appl. problem")
group[9][2] = new Option("EIS not working", "EIS Appl. problem")
group[9][3] = new Option("File Tracking System not working", "FTS Appl. problem")
group[9][4] = new Option("OS daily report not working", "OS-Daily report Appl. problem")
group[9][5] = new Option("RED(N)'s Desk not working", "RED(N)'s Appl. Problem")
group[9][6] = new Option("GDAMS application Problem", "GDAMS Problem")
group[9][7] = new Option("Application USERID/PASSWORD Problem", "Userid/Password Problem")
group[9][8] = new Option("Application Data not updated", "Appl. Data Problem")
group[9][9] = new Option("MS Team")
group[9][10] = new Option("MS Office")
group[9][11] = new Option("Adobe")
group[9][12] = new Option("Java")
group[9][13] = new Option("Finmat")
group[9][14] = new Option("eProcurement System")
group[10][0] = new Option("Acorbat Reader Installation/Error", "Acrobat Issue")
group[10][1] = new Option("Antivirus Patch/Virus Issue", "Antivirus Issue")
group[10][2] = new Option("CD Writer S/W Installation/Error", "CD Writer S/W Issue")
group[10][3] = new Option("Hindi Fonts Installation", "Hindi Fonts Issue")
group[10][4] = new Option("MS Office Installation/Error", "MS Office Issue")
group[10][5] = new Option("PDF Writer", "PDF Writer Issue")
group[10][6] = new Option("Winzip/Winrar Installation/Issue", "Winzip/Rar Issue")
group[10][7] = new Option("Installation of a software", "Some software to be loaded")
group[11][0] = new Option("Intranet not updated", "Intranet Update Issue")
group[11][1] = new Option("Lodged Complaint still pending", "Complaint Handling problem")
group[12][0] = new Option("ESS ID Locked", "ESS ID Locked")
group[12][1] = new Option("SAP - R/3 ID Locked", "SAP R/3 ID Locked")
group[12][2] = new Option("ESS password forgetton", "ESS Password forgetton")
group[12][3] = new Option("SAP password forgetton", "SAP - R/3 Password forgetton")
group[12][4] = new Option("ESS Page not displayed properly", "ESS Page not displayed properly")
group[12][5] = new Option("ESS/SAP not installed", "ESS/SAP not installed")
group[13][0] = new Option("Cant open mail in Browser", "Browser Mail Problem")
group[13][1] = new Option("Cant open Lotus Notes", "Lotus Notes Problem")
group[13][2] = new Option("Internet Mail access problem", "Internet Mail access problem")
group[13][3] = new Option("Archiving Problem", "Archiving Problem")
group[13][4] = new Option("Certificate Expired", "Certificate Expired")
group[13][5] = new Option("Mobile mail configuration", "Mobile mail configuration")
var temp = document.forms.form1.type
function redirect(x) {
document.getElementsByName('dvPrinter')[0].style.display = "none";
if (document.forms.form1.cat[x].text == 'Printer') {
document.getElementsByName('dvPrinter')[0].style.display = "block";
}
for (m = temp.options.length - 1; m > 0; m--)
temp.options[m] = null
i = 0;
temp.options[i] = new Option("", "0")
for (i = 0; i < group[x].length; i++) {
temp.options[i + 1] = new Option(group[x][i].text, group[x][i].value)
}
temp.options[0].selected = true
}
function SetMessage() {
var str = document.forms.form1.str;
var cat = document.forms.form1.cat.value;
var printer = document.forms.form1.printer.value;
var type = document.forms.form1.type.value;
var location = document.forms.form1.Location.value;
var message = "";
if (cat != "0" && cat != '' && cat != '--') {
message += cat;
}
if (printer != "0" && printer != '' && printer != '--') {
message += ":- " + printer;
}
if (type != "0" && type != '' && type != '--') {
message += ":- " + type;
}
if (location != "0" && location != '' && location != '--') {
message += " :- " + location;
}
str.value = message;
}
</script>
<u>
<h3 align="left">IT COMPLAINT BOX :</h3>
</u>
</center>
<table width="700" height="168" border="3" bgcolor="#99CCCC" bordercolor="#000000">
<br />
<tr>
<td width="120" scope="col">
<center><b>COMPLAINT MESSAGE </b></center>
</td>
<td>
<asp:TextBox runat="server" ID="str" TextMode="Multiline" Columns="20" Name="S1" Rows="2" CssClass="auto-style10" Height="144px" Width="559px"></asp:TextBox>
<center><asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" CssClass="auto-style15"></asp:Button></center>
</td>
</tr>
</table>
<div align="left">
<div class="auto-style14">
<span class="auto-style13"><strong>Yours complaint(s)</strong></span>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="OnRowDataBound"
BackColor="White" Width="1100px" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CssClass="auto-style16" Height="170px">
<Columns>
<asp:TemplateField HeaderText="COMP_ID">
<ItemTemplate>
<asp:Label ID="lblCOMP_ID" runat="server" Text='<%# Eval("COMP_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EmpCode">
<ItemTemplate>
<asp:Label ID="lblEmpCode" runat="server" Text='<%# Eval("EmpCode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="COMP_MESSAGE">
<ItemTemplate>
<asp:Label ID="lblCOMP_MESSAGE" runat="server" Text='<%# Eval("COMP_MESSAGE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="STATUS_ID">
<ItemTemplate>
<asp:Label ID="lblSTATUS_ID" runat="server" Text='<%# Eval("STATUS_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="COMP_LODGE_DATE">
<ItemTemplate>
<asp:Label ID="lblCOMP_LODGE_DATE" runat="server" Text='<%# Eval("COMP_LODGE_DATE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CLOSING_DATE">
<ItemTemplate>
<asp:Label ID="lblCLOSING_DATE" runat="server" Text='<%# Eval("CLOSING_DATE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="REMARKS">
<ItemTemplate>
<asp:Label ID="lblREMARKS" runat="server" Text='<%# Eval("REMARKS") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<img id="Image1" runat="server" alt="" height="50" width="50" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
</div>
</table>
</form>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string employeeId = lblName.Text.Trim();
string message = str.Text.Trim();
string image = "";
if (FileUpload1.HasFile)
{
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
if (!Directory.Exists(Server.MapPath("~/Images")))
{
Directory.CreateDirectory(Server.MapPath("~/Images"));
}
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Images/") + fileName);
image = "~/Images/" + fileName;
}
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string query = "insert_it";
using (SqlConnection con = new SqlConnection(conString))
{
SqlCommand cmd = new SqlCommand(query);
cmd.Parameters.AddWithValue("@EmpCode", employeeId);
cmd.Parameters.AddWithValue("@COMP_MESSAGE", message);
cmd.Parameters.AddWithValue("@image", image);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
Response.Redirect(Request.Url.AbsoluteUri);
}
private void BindGrid()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM IT_comp_box", con);
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView dr = (DataRowView)e.Row.DataItem;
HtmlImage img = e.Row.FindControl("Image1") as HtmlImage;
if (!Convert.IsDBNull(dr["Image "]))
{
(e.Row.FindControl("Image1") as HtmlImage).Src = dr["Image "].ToString();
}
else
{
img.Visible = false;
}
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
BindGrid()
End If
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim employeeId As String = lblName.Text.Trim()
Dim message As String = str.Text.Trim()
Dim image As String = ""
If FileUpload1.HasFile Then
Dim fileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
If Not Directory.Exists(Server.MapPath("~/Images")) Then
Directory.CreateDirectory(Server.MapPath("~/Images"))
End If
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Images/") & fileName)
image = "~/Images/" & fileName
End If
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim query As String = "insert_it"
Using con As SqlConnection = New SqlConnection(conString)
Dim cmd As SqlCommand = New SqlCommand(query)
cmd.Parameters.AddWithValue("@EmpCode", employeeId)
cmd.Parameters.AddWithValue("@COMP_MESSAGE", message)
cmd.Parameters.AddWithValue("@image", image)
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
Private Sub BindGrid()
Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
Dim sda As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM IT_comp_box", con)
Dim dt As DataTable = New DataTable()
sda.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Protected Sub OnRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dr As DataRowView = CType(e.Row.DataItem, DataRowView)
Dim img As HtmlImage = TryCast(e.Row.FindControl("Image1"), HtmlImage)
If Not Convert.IsDBNull(dr("Image ")) Then
TryCast(e.Row.FindControl("Image1"), HtmlImage).Src = dr("Image ").ToString()
Else
img.Visible = False
End If
End If
End Sub