-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoints.aspx.cs
93 lines (85 loc) · 2.81 KB
/
Points.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
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Collections;
namespace FoodPantry
{
public partial class Points : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["Authenticated"].ToString() == "True")
{
if (Session["Role"].ToString() != "Admin")
{
Response.Redirect("500http.aspx");
}
}
else
{
Response.Redirect("Default.aspx");
}
}
catch (Exception ex)
{
Response.Redirect("Default.aspx");
};
}
[WebMethod]
public static string setMaxPoint(string point)
{
try
{
int pointVal = Convert.ToInt32(point);
if(pointVal > 0)
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SetMaxPoint";
cmd.Parameters.AddWithValue("@point", pointVal);
cmd.Parameters.AddWithValue("@lastUpdateUser", HttpContext.Current.Session["Access_Net"].ToString());
cmd.Parameters.AddWithValue("@lastUpdateDate", DateTime.Now.ToString());
int ret = objDB.DoUpdateUsingCmdObj(cmd);
return pointVal.ToString();
}
else
{
throw new FormatException();
}
}
catch (Exception ex)
{
throw ex;
}
}
[WebMethod]
public static string getMaxPoint()
{
string point = "";
try
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetMaxPoint";
DataSet ds = objDB.GetDataSetUsingCmdObj(cmd);
if(ds.Tables[0].Rows.Count != 0)
{
point = ds.Tables[0].Rows[0]["MaxPoint"].ToString();
}
return point;
}
catch (Exception ex)
{
return "Error" + ex.Message;
}
}
}
}