Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6781721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:39:27+00:00 2026-05-26T16:39:27+00:00

I have a form, in that I have user control(for displaying member name with

  • 0

I have a form, in that I have user control(for displaying member name with datetime) and two comboboxes(one is cbstatus values like (refused , accepts , logout) and another combobox cbperiod and values like (today, 7 days, 30 days..)
I am showing the member name along with visit datetime and logout datetime like this..)

by using the following query

  sql = @"SELECT member_Firstname, member_Lastname, member_Postcode,  
          visit_DateTime, visit_Status, visit_Logout_DateTime, visits.member_Id, visit_AlertMsg
          FROM members,visits
          WHERE members.member_Id = visits.member_Id
          AND members.member_Active LIKE 'y%'";

this is working fine …..

I am getting the values depends on the combobox values like this ..

 if (cbStatus.Text == "Accepts")
 {
    sql += " AND visits.visit_Status = 'accepted' ";
 }

i have got the two more conditions like this…

  if (cbStatus.Text == "refusals")
 {
    sql += blahh blahh blahhhh
 }

i am getting values for selecting cbperiod combobox like this…

  if (cbPeriod.Text == "Today")
  {
    string dtStartString = DateTime.Today.ToString(DataHelper.dateFormat);

    sql += string.Format(" AND visits.visit_Date = '{0}'", dtStartString);
  }
//here i am comparing the cbstatus value logout and cbperiod text with today to get the member details whose logout datetime is today

  if (cbStatus.Text == "Logout" && cbPeriod.Text == "Today")
  {
    string dtStartString = DateTime.Today.ToString("yyyy-MM-dd");            
    sql += string.Format(" AND DATE(visits.visit_Logout_DateTime) = '{0}'", dtStartString);

  }

and i have got two more conditions like this…. for values in cbstatus and cbperiod

here i binding my values with usercontrol….

 datatable dt1 =  Helper.GetData(sql);


  if (dt1 != null)
  {
    if (dt1.Rows.Count > 0)
    {         
      foreach (DataRow row in dt1.Rows)
      {
        newItem = new EntryItem();// this is my usercontrol        
        if (cbStatus.Text != "Logout")
        {
          DateTime dtTemp = DateTime.Parse(row["visit_DateTime"].ToString()); // here I    am showing the data when user not selected the cbstatus text as logout I mean (refusal,..)
   but the below function overrides this data ....
          if (cbPeriod.Text == "Today") newItem.lblTime.Text = dtTemp.ToString("HH':'mm':'ss");
          else newItem.lblTime.Text = dtTemp.ToString("yyyy'-'MM'-'dd'  -  'HH':'mm':'ss");
        }

        if (row["visit_Logout_DateTime"] != DBNull.Value)
        {
          DateTime dtlogout = DateTime.Parse(row["visit_Logout_DateTime"].ToString());
          if (dtlogout != null)
          {
            if (cbStatus.Text == "Logout" && cbPeriod.Text == "Today")
            {
              newItem.lblTime.Text = dtlogout.ToString("HH':'mm':'ss");
              newItem.lblName.Text = row["member_Firstname"].ToString() + " " + row["member_Lastname"].ToString();
              newItem.lblAlertMessage.Text =  row["visit_AlertMsg"].ToString();

            }
            else
              newItem.lblTime.Text = dtlogout.ToString("yyyy'-'MM'-'dd'  -  'HH':'mm':'ss");
            newItem.lblName.Text = row["member_Firstname"].ToString() + " " + row["member_Lastname"].ToString();
            newItem.lblAlertMessage.Text = row["visit_AlertMsg"].ToString();               
          }
        }

     newItem.lblName.Text = row["member_Firstname"].ToString() + " " + row["member_Lastname"].ToString();
        newItem.lblAlertMessage.Text =  row["visit_AlertMsg"].ToString();

when i select cbstatus.text == logout it will showing the correct data with members with logout datetime…

but when i select cbstatus.text == refusals .. it was showing logout data (members with logoutdaatetime) ..this is wrong actual it has to show the refusal members with visit_Datetime

how can i show both data with members has logoutdatetime and visit datetime

Note:one member have both logoutdatetime and visitdatetime….

and my data is like this…

  firstname     lastname   postcode   status        visit_Logout_DateTime        visit_datetime
-------------  --------   ---------   -------        ---------------------    ----------------
 rob           peter     hhd344h      refused          2011-05-06 12:09:07     2011-05-06 08:09:34                          
peter          chan      hy78kjk      refused          2011-09-08 12:09:08     2011-05-03 06:09:34
 rock         sam        yudufg3746h  refused          2011-08-08 09:08:45    
 rob           peter     hhd344h      refused          2011-05-10 12:09:07     2011-05-10 08:09:34      
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:39:27+00:00Added an answer on May 26, 2026 at 4:39 pm

    I have solved my problem… like this….

            if (row["visit_Logout_DateTime"] != DBNull.Value || row["visit_DateTime"] == DBNull.Value)
            {
              if (cbStatus.Text != "Refusals" && cbStatus.Text != "Accepts" && row["visit_Logout_DateTime"] != DBNull.Value)
              {
                DateTime dtlogout = DateTime.Parse(row["visit_Logout_DateTime"].ToString());
    
                if (true)
                {
                  if (cbPeriod.Text == "Today")
                  {
                    newItem.lblTime.Text = dtlogout.ToString("HH:mm:ss");
                    newItem.BackColor = Color.Cyan;
                  }
                  else
                    newItem.lblTime.Text = dtlogout.ToString("yyyy'-'MM'-'dd'  -  'HH':'mm':'ss");               
                  newItem.lblName.Text = string.Format("{0} {1}", row["member_Firstname"].ToString(), row["member_Lastname"].ToString());
                  newItem.lblAlertMessage.Text = string.Format("{0} {1}", row["member_EntryMessage"].ToString(), row["visit_AlertMsg"].ToString());
    
                  newItem.lblName.Text = string.Format("{0} {1}", row["member_Firstname"].ToString(), row["member_Lastname"].ToString());
                  newItem.lblAlertMessage.Text = string.Format("{0} {1}", row["member_EntryMessage"].ToString(), row["visit_AlertMsg"].ToString());              
                  newItem.tbHiddenId.Text = row["member_Id"].ToString();
                  newItem.ID = Convert.ToInt32(row["member_Id"].ToString());
                }
              }
    
            }
            else if (row["visit_Logout_DateTime"] == DBNull.Value || row["visit_DateTime"] != DBNull.Value)
            {
              DateTime dtTemp = DateTime.Parse(row["visit_DateTime"].ToString());
              newItem.lblTime.Text = dtTemp.ToString(cbPeriod.Text == "Today" ? "HH':'mm':'ss" : "yyyy'-'MM'-'dd'  -  'HH':'mm':'ss");
    
              newItem.lblName.Text = string.Format("{0} {1}", row["member_Firstname"].ToString(), row["member_Lastname"].ToString());
              newItem.lblAlertMessage.Text = string.Format("{0} {1}", row["member_EntryMessage"].ToString(), row["visit_AlertMsg"].ToString());
    
              newItem.tbHiddenId.Text = row["member_Id"].ToString();
              newItem.ID = Convert.ToInt32(row["member_Id"].ToString());
            }           
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view user control that can post form. This control can be
I have a user control on a web form that is declared as follows:
I have a Windows Form (C#) that dynamically generates copies of a User Control.
I have a form that has a file input control: <input type=file onclick=this.blur() name=descFile
I have a User Control displaying some data and a button that displays a
I have a user control on a form that can spawn several non-modal child
I have a Windows form user control that is made COM visible. Now I
So I have a form that the user fills out, when submitted an new
So I have a form that accepts some input from a user that may
We have a form that allows a user to filter a list with by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.