-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPatientApplyMedicalInsuranceScheme.aspx.cs
More file actions
166 lines (152 loc) · 6.04 KB
/
PatientApplyMedicalInsuranceScheme.aspx.cs
File metadata and controls
166 lines (152 loc) · 6.04 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class PatientApplyMedicalInsuranceScheme : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader rs;
SqlDataAdapter adp;
DataTable dt;
void autonumber()
{
cmd = new SqlCommand("select isnull(max(policyno), 10000)+1 from msatable", con);
TextBox2.Text = cmd.ExecuteScalar().ToString();
cmd.Dispose();
}
void bindview1()
{
adp = new SqlDataAdapter("select * from ptable where pid=@pid", con);
adp.SelectCommand.Parameters.AddWithValue("pid", Session["PID"].ToString());
dt = new DataTable();
adp.Fill(dt);
DetailsView1.DataSource = dt;
DetailsView1.DataBind();
}
void bindview2()
{
adp = new SqlDataAdapter("select * from mstable where rid=@rid", con);
adp.SelectCommand.Parameters.AddWithValue("rid", Request.QueryString.Get("RID"));
dt = new DataTable();
adp.Fill(dt);
DetailsView2.DataSource = dt;
DetailsView2.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
//RID
Label1.Text = "";
Menu m5 = (Menu)Master.FindControl("Menu5");
m5.Visible = true;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
con.Open();
if (!IsPostBack)
{
if (Session["PID"] != null)
{
TextBox1.Text = Session["PID"].ToString();
autonumber();
TextBox3.Text = DateTime.Now.ToString("dd-MMM-yyyy");
bindview1();
bindview2();
}
}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
try
{
//cmd = new SqlCommand("Select * from msatable where cid=@cid", con);
//cmd.Parameters.AddWithValue("cid", TextBox1.Text);
//rs = cmd.ExecuteReader();
//bool b = rs.Read();
//rs.Close();
//cmd.Dispose();
//if (b)
//{
// Label1.Text = "Medical Insurance Scheme Already Applied......";
// return;
//}
cmd = new SqlCommand("select rid from msatable where rid =@rid and cid=@cid", con);
cmd.Parameters.AddWithValue("rid", Request .QueryString .Get ("RID"));
cmd.Parameters.AddWithValue("cid", TextBox1.Text);
rs = cmd.ExecuteReader();
bool b = rs.Read();
rs.Close();
cmd.Dispose();
if (b)
{
Label1.Text = "Patient Already Apply this Medical Scheme......";
return;
}
cmd = new SqlCommand("select policyno from msatable where policyno=@policyno", con);
cmd.Parameters.AddWithValue("policyno", TextBox2.Text);
rs = cmd.ExecuteReader();
b = rs.Read();
rs.Close();
cmd.Dispose();
if (b)
{
Label1.Text = "Policy Number Already Found......";
return;
}
cmd = new SqlCommand("insert into msatable values(@policyno,@cid,@cusname,@rid,@iid,@cname,@padate)", con);
cmd.Parameters.AddWithValue("policyno", TextBox2.Text);
cmd.Parameters.AddWithValue("cid", TextBox1.Text);
cmd.Parameters.AddWithValue("cusname", DetailsView1.Rows[0].Cells[1].Text);
cmd.Parameters.AddWithValue("rid", Request.QueryString.Get("RID"));
cmd.Parameters.AddWithValue("iid", DetailsView2.Rows[0].Cells[1].Text);
cmd.Parameters.AddWithValue("cname", DetailsView2.Rows[1].Cells[1].Text);
cmd.Parameters.AddWithValue("padate", TextBox3.Text);
int no= cmd.ExecuteNonQuery();
cmd.Dispose();
if (no != 0)
{
cmd = new SqlCommand("select * from pirtable where iid=@iid and cid=@cid", con);
cmd.Parameters.AddWithValue("iid", DetailsView2.Rows[0].Cells[1].Text);
cmd.Parameters.AddWithValue("cid", TextBox1.Text);
rs = cmd.ExecuteReader();
bool bb = rs.Read();
rs.Close();
cmd.Dispose();
if (bb)
{
cmd = new SqlCommand("update pirtable set mcamount=mcamount + @mcamount where iid=@iid and cid=@cid", con);
cmd.Parameters.AddWithValue("mcamount", DetailsView2.Rows[6].Cells[1].Text);
cmd.Parameters.AddWithValue("iid", DetailsView2.Rows[0].Cells[1].Text);
cmd.Parameters.AddWithValue("cid", TextBox1.Text);
cmd.ExecuteNonQuery();
cmd.Dispose();
}
else
{
cmd = new SqlCommand("insert into pirtable values(@iid,@cid,@mcamount)", con);
cmd.Parameters.AddWithValue("iid", DetailsView2.Rows[0].Cells[1].Text);
cmd.Parameters.AddWithValue("cid", TextBox1.Text);
cmd.Parameters.AddWithValue("mcamount", DetailsView2.Rows[6].Cells[1].Text);
cmd.ExecuteNonQuery();
cmd.Dispose();
}
}
Label1.Text = "Medical Insurance Scheme Details Successfully Applied.......";
LinkButton1.Enabled = false;
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
}