TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
739
1.2k
280.2k
Implementing Credit Limit
Feb 25 2017 4:39 AM
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."
;
}
}
}
Reply
Answers (
2
)
code for image control
I am working on a project using C# and need help in this.