-
Notifications
You must be signed in to change notification settings - Fork 1
/
user-add-complaint.aspx.cs
119 lines (84 loc) · 3.74 KB
/
user-add-complaint.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ComplaintManagement
{
public partial class user_add_complaint : System.Web.UI.Page
{
String con = System.Configuration.ConfigurationManager.ConnectionStrings["Complaint_dbConnectionString"].ConnectionString;
// String con = @"Data Source=(localdb)\ProjectsV13;Initial Catalog=Complaint_db;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
string id;
protected void Page_Load(object sender, EventArgs e)
{
string current_user = Session["logged_user"].ToString();
string fname = "";
string lname = "";
using (SqlConnection myConnection = new SqlConnection(con))
{
string oString = "Select * from dbo.user_data where email=@email";
SqlCommand oCmd = new SqlCommand(oString, myConnection);
oCmd.Parameters.AddWithValue("@email", current_user);
myConnection.Open();
using (SqlDataReader oReader = oCmd.ExecuteReader())
{
while (oReader.Read())
{
fname = oReader["fname"].ToString();
lname = oReader["lname"].ToString();
id = oReader["id"].ToString();
}
myConnection.Close();
}
}
lbl_user_name.Text = fname + " " + lname;
}
protected void Add_complaint(object sender, EventArgs e)
{
if (!imgUpload.HasFile)
{
Response.Write("<script>alert('Image Field is Empty')</script>");
}
else
{
int lenght = imgUpload.PostedFile.ContentLength;
byte[] image = new byte[lenght];
imgUpload.PostedFile.InputStream.Read(image, 0, lenght);
using (SqlConnection sqlconn = new SqlConnection(con))
{
sqlconn.Open();
SqlCommand add = new SqlCommand("add_complaint", sqlconn);
add.CommandType = System.Data.CommandType.StoredProcedure;
add.Parameters.AddWithValue("@id", Convert.ToInt32(hfuserid.Value == "" ? "0" : hfuserid.Value));
add.Parameters.AddWithValue("@user_id", id);
add.Parameters.AddWithValue("@title", title.Text.Trim());
add.Parameters.AddWithValue("@description", description.Text.Trim());
add.Parameters.AddWithValue("@address", address.Text.Trim());
add.Parameters.AddWithValue("@city", city.Text.Trim());
add.Parameters.AddWithValue("@pincode", pincode.Text.Trim());
add.Parameters.AddWithValue("@photo", "test string");
add.Parameters.AddWithValue("@department", department.SelectedValue);
add.Parameters.AddWithValue("@image", image);
try{
add.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally{
clr();
}
// errormsg.Visible = false;
// successmsg.Text = "success";
}
}
}
public void clr()
{
title.Text = pincode.Text= city.Text = description.Text = address.Text = " ";
}
}
}