-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComplaint.aspx.cs
75 lines (73 loc) · 2.95 KB
/
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
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.SqlClient;
namespace DC
{
public partial class Complaint : System.Web.UI.Page
{
static int ComplaintId;
protected void Page_Load(object sender, EventArgs e)
{
getcomplaintid();
Label3.Text = DateTime.Now.ToLongDateString().ToString() + " " +
DateTime.Now.ToLongTimeString().ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
String query = "insert into ComplaintDetails(ComplaintId, ComplaintDate, Name,BookingId, ComplaintDetail, Status) values(" +
ComplaintId + ",'" + Label3.Text + "','" + TextBox1.Text + "','" + TextBox3.Text + "','" + TextBox2.Text +
"','Under Processing')";
String mycon = "Data Source=DESKTOP-V7UTR4K; Initial Catalog=DataDictionary; Integrated Security = true";
SqlConnection con = new SqlConnection(mycon);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = query;
cmd.Connection = con;
cmd.ExecuteNonQuery();
TextBox1.Text = "";
TextBox2.Text = "";
Label4.Text = "Your Complaint ID is " + ComplaintId + " . You can Check the Status of Complaint Using this Complaint ID,We will contact soon.";
}
public void getcomplaintid()
{
String mycon = "Data Source=DESKTOP-V7UTR4K; Initial Catalog=DataDictionary; Integrated Security = true";
SqlConnection scon = new SqlConnection(mycon);
String myquery = "select ComplaintId from ComplaintDetails";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = myquery;
cmd.Connection = scon;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
scon.Close();
if (ds.Tables[0].Rows.Count < 1)
{
ComplaintId = 10001;
}
else
{
String mycon1 = "Data Source=DESKTOP-V7UTR4K; Initial Catalog=DataDictionary; Integrated Security = true";
SqlConnection scon1 = new SqlConnection(mycon1);
String myquery1 = "select max(ComplaintId) from ComplaintDetails";
SqlCommand cmd1 = new SqlCommand();
cmd1.CommandText = myquery1;
cmd1.Connection = scon1;
SqlDataAdapter da1 = new SqlDataAdapter();
da1.SelectCommand = cmd1;
DataSet ds1 = new DataSet();
da1.Fill(ds1);
int a;
a = Convert.ToInt16(ds1.Tables[0].Rows[0][0].ToString());
a = a + 1;
ComplaintId = a;
scon1.Close();
}
}
}
}