Click here to Skip to main content
12,406,971 members (61,771 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
if (DateTime.Now.Hour >= 10 && DateTime.Now.Hour < 20)
        {
           //i want here condition if its that id has access once in day he my not                   //access this code again          
            com = new SqlCommand("SELECT COUNT(*) FROM Registration_Master WHERE sponcorid='" + code + "'", con);
            int count = (int)com.ExecuteScalar();
            if (count == 2)
            {
                string query = "SELECT count_mem FROM Registration_Master WHERE sponcorid='" + code + "'";
                com = new SqlCommand(query, con);
                com.CommandType = CommandType.Text;
                da = new SqlDataAdapter(com);
                DataTable dtquery = new DataTable();
                da.Fill(dtquery);
                if (dtquery.Rows.Count == 1)
                {
                    double income = Convert.ToDouble(txtamount.Text.ToString());
                    double tds = ((income / 100.0) * 10.0);
 
                    double admin = ((income / 100.0) * 10.0);
                    double net = 0;
                    net = income - tds - admin;
 
                    double totdeduct = tds + admin;
                    int totbinary = 1;
                                   
 
                    com.Connection = con;
                    com.CommandText = "INSERT INTO Payout_Master (sponcorid,session,total_binary,gross_total,tds,admin_charges,binary_income,total_deduct,net_payment,createddate) VALUES('" + txtid.Text + "','MORNING',"+totbinary+"," + income + "," + tds + " ," + admin + "," + income + "," + totdeduct + "," + net + ","+DateTime.Now+")";
                    com.CommandType = CommandType.Text;
                    com.ExecuteNonQuery();
 
                    txtamount.Text = "";
                    txtid.Text = "";
                    DataTable dt1 = new DataTable();
                    dt1 = DAL.Payout_Master.View();
                    Repeater1.DataSource = dt1;
                    Repeater1.DataBind();
                    MultiView1.ActiveViewIndex = 1;
                    flag = true;
                }
                if (dtquery.Rows.Count == 2)
                {
                    
                    
                    double income = Convert.ToDouble(txtamount.Text.ToString());
                    double tds = ((income / 100.0) * 10.0);
 
                    double admin = ((income / 100.0) * 10.0);
                    double net = 0;
                    net = income - tds - admin;
 
                    double totdeduct = tds + admin;
 
                   int totbinary=2;
                   double gtot = 2 * 500;                   
                    com.Connection = con;
                    com.CommandText = "INSERT INTO Payout_Master (sponcorid,session,total_binary,gross_total,tds,admin_charges,binary_income,total_deduct,net_payment,createddate) VALUES('" + txtid.Text + "','MORNING'," + totbinary + "," + gtot + "," + tds + " ," + admin + "," + income + "," + totdeduct + "," + net + ",'" + DateTime.Now +"')";
                    com.CommandType = CommandType.Text;
                    com.ExecuteNonQuery();
 
                    txtamount.Text = "";
                    txtid.Text = "";
                    DataTable dt1 = new DataTable();
                    dt1 = DAL.Payout_Master.View();
                    Repeater1.DataSource = dt1;
                    Repeater1.DataBind();
                    MultiView1.ActiveViewIndex = 1;
                    flag = true;
 
                }
               
            }
            
        }
Posted 21-Nov-12 18:59pm
Updated 21-Nov-12 19:19pm
v4
Comments
Mohd. Mukhtar 22-Nov-12 1:03am
   
What have you tried so for???
Nandakishorerao 22-Nov-12 2:04am
   
does your question means the user can get payment once a day.. right..i prefer using stored procedure it can be done...becoz, you are storing the transaction in Payoutmaster table....then you can get the count of it and perform it in sp itself..dont perform it in codebehind..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi Sumit,

You should check this condition on login button click.

See below code snippet.
First you need to create table DailyUserLoggedInStatus with below column.
UserID
LastLoginDate

if (DateTime.Now.Hour >= 10 && DateTime.Now.Hour < 20)
{
  com = new SqlCommand("Select * from DailyUserLoggedInStatus  Where UserID = " + userId.ToString() + " AND LastLoginDate = '" DateTime.Now.ToString("d")+"'", con);
  da = new SqlDataAdapter(com);
  DataSet ds = new DataSet ();
  da.Fill(ds);
  if (ds.Table[0].Rows.Count>0)
  {
    //Already logged in today 
    return;
  }
  else
  {
    com = new SqlCommand("UPDATE DailyUserLoggedInStatus  SET LastLoginDate = '" + DateTime.Now.ToString("d")+"' WHERE UserID = " + userId.ToString(), con);
   com.ExecuteNonQuery();
  }
  //...Your more code
}

Follow below technique to implement this.

protected void Login_Button_Click(object sender, EventArg e)
{
   //Check user credential
   if(AuthenticateUser)
   { 
     //Check if user logged in for today
     if(LoggedInToday)
        //Show error
     else
        //Update the table DailyUserLoggedInStatus
   }
}
If you are not able to solve the problem, Please copy your code here.
  Permalink  
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Make 2 columns in a table, lastLogin and lockout, then Just write the last login date into a table column, and when they logout, flip the bit in the lockout column to 1.

Then when they login, if the lockout bit is 1, calculate the next available date to login, if it's the next day, unlock them and let them login.

[Edit]

you might need this to unlock the account
UPDATE CustomerInfo Set Lockout = 0 WHERE AccountName=@AccountName AND DATEDIFF(hour, LastLogin, GetDate()) > 0"
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Create a table with columns - usercode,date of login, page viewed & sysdate to store user login details. When a user logged in, make an entry in that table.
Then you can easily find out whether that user has logged into the application
or not. if the count per day for that particular user is greater than 1, then u can lock the user from logging in.


Thanks & regards,
Fathima.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160730.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100