Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Reply
Implementing Credit Limit
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Hold On
7y
185
1
Reply
I have created a webforms application for a micro-insurance business. In one of my forms, I added a button which redirects a user to page where he can sell insurance. Each user has a credit limit. Once reached, the idea is that the button which redirects to selling will be invisible.
I was able to get the credit limit from the database. My problem is how can I hide or show the button if the condition is satisfied. Below is my design and snipets of my code behind. I'm still new in programming.
public
partial
class
credit_limit : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
lblUserName.Text = Session[
"username"
].ToString();
lblDepartment.Text = Session[
"department"
].ToString();
if
(!IsPostBack)
{
viewCreditLimit();
}
}
protected
void
btnMotor_Click(
object
sender, EventArgs e)
{
}
private
void
viewCreditLimit()
{
using
(SqlConnection con = DBConn.GetDbCon())
{
con.Open();
SqlCommand cmd =
new
SqlCommand(
"select CreditLimit from Login where UserName = @UserName and DepartmentID=@DepartmentID"
, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@UserName"
, lblUserName.Text);
cmd.Parameters.AddWithValue(
"@DepartmentID"
, lblDepartment.Text);
using
(SqlDataReader rdr = cmd.ExecuteReader())
{
try
{
while
(rdr.Read())
{
lblcreditlimit.Text = rdr[
"CreditLimit"
].ToString();
}
}
catch
(Exception ex)
{
throw
ex;
}
}
}
}
private
void
showButton()
{
if
(lblcreditlimit.Text < lblcreditlimit.Text)
{
Panel1.Visible =
true
;
}
else
{
Panel1.Visible =
false
;
lblMessage.Text =
"Your credit limit is already reached."
;
}
}
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
code for image control
I am working on a project using C# and need help in this.