-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInsurerViewClaimRequestStatus.aspx.cs
152 lines (131 loc) · 5.34 KB
/
InsurerViewClaimRequestStatus.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
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
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 InsurerViewClaimRequestStatus : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader rs;
SqlDataAdapter adp;
DataTable dt;
void bindgrid()
{
adp = new SqlDataAdapter("select i1.claimid, i1.pid,i1.pname, i1.did,i1.dname,i1.ttype,i1.tamount,i1.tdate,c1.status from icrtable i1 , crtable c1 where i1.claimid in (select claimid from crtable where iid=@iid and (status='Accepting' or status='Rejecting'))and i1.status='Claiming' ", con);
adp.SelectCommand.Parameters.AddWithValue("iid", Session["IID"].ToString());
dt = new DataTable();
adp.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
for (int i = 0; i < dt.Rows.Count; i++)
{
string status = dt.Rows[i]["status"].ToString().ToLower();
if (status .Equals ("accepting"))
GridView1 .Rows [i].Cells[9].Enabled =true ;
else
GridView1.Rows[i].Cells[9].Enabled = false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
Label1.Text = "";
Menu m4 = (Menu)Master.FindControl("Menu4");
m4.Visible = true;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
con.Open();
if (!IsPostBack)
{
if (Session["IID"] != null)
{
bindgrid();
}
}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "ap")
{
int claimid = int.Parse(GridView1.DataKeys[int.Parse(e.CommandArgument.ToString())].Value.ToString());
int pid = int.Parse(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[1].Text);
int did = int.Parse(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[3].Text);
float amount = float.Parse(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[6].Text);
/* cmd = new SqlCommand("select mcamount from mstable where iid=(select iid from msatable where cid=@cid)", con);
cmd.Parameters.AddWithValue("cid", pid);
rs = cmd.ExecuteReader();
float mcamount = 0;
if (rs.Read())
{
mcamount = float.Parse(rs["mcamount"].ToString());
rs.Close();
cmd.Dispose();
}
else
{
rs.Close();
cmd.Dispose();
Label1.Text = "Record Not Found.Check MSTable.....";
return;
}*/
cmd = new SqlCommand("select mcamount from pirtable where iid=@iid and cid=@cid", con);
cmd.Parameters.AddWithValue("iid", Session["IID"].ToString());
cmd.Parameters.AddWithValue("cid", pid);
rs = cmd.ExecuteReader();
float mcamount = 0;
if (rs.Read())
{
mcamount = float.Parse(rs["mcamount"].ToString());
rs.Close();
cmd.Dispose();
}
else
{
rs.Close();
cmd.Dispose();
Label1.Text = "Record Not Found.Check MSTable.....";
return;
}
if (amount > mcamount)
{
Label1.Text = "Maximum Claim Amount is Low.So , Claim Details Not Approved......";
return;
}
cmd = new SqlCommand("update icrtable set status=@status where claimid=@claimid", con);
cmd.Parameters.AddWithValue("status", "Approved");
cmd.Parameters.AddWithValue("claimid", claimid);
cmd.ExecuteNonQuery();
cmd.Dispose();
cmd = new SqlCommand("update paytable set status=@status where pid=@pid and did=@did", con);
cmd.Parameters.AddWithValue("status", "Paid");
cmd.Parameters.AddWithValue("pid", pid);
cmd.Parameters.AddWithValue("did", did);
cmd.ExecuteNonQuery();
cmd.Dispose();
cmd = new SqlCommand("update pirtable set mcamount=mcamount-@mcamount where iid=@iid and cid=@cid", con);
cmd.Parameters.AddWithValue("mcamount", amount);
cmd.Parameters.AddWithValue("iid", Session["IID"].ToString());
cmd.Parameters.AddWithValue("cid", pid);
cmd.ExecuteNonQuery();
cmd.Dispose();
bindgrid();
}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
}