private void dgClients_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgClients.Columns[e.ColumnIndex].Name == "NumOfMem")
     {
         DataGridViewRow row = dgClients.Rows[e.RowIndex];
         CustomerId = Convert.ToInt64(row.Cells[0].Value.ToString());
         strSQL1    = "select* from tblActualMembership where tblActualMembership.memberID=" + Convert.ToInt64(CustomerId);
         command sqlCmd1 = new command(strSQL1);
         dgMem.DataSource = sqlCmd1.datatable();
     }
 }
 private void btnQ2_Click(object sender, EventArgs e)
 {
     //  btnQAB.Enabled = false;
     btnQ2.Enabled   = false;
     btnQ1.Visible   = false;
     back.Enabled    = false;
     btnEnd2.Visible = true;
     dgQ2.Visible    = true;
     strSQL          = "select CustomerId, FirstName, SurName, PhoneNum,CellPhone from tblMemberCustomer inner join tblCustomer on tblMemberCustomer.memberID = tblCustomer.CustomerId  left outer join tblEnteringToClub on tblMemberCustomer.memberID = tblEnteringToClub.memberID  where (DateDiff(m, EnteringDate ,getdate() ))< 4 and  tblMemberCustomer.memberID in  (SELECT memberID from tblEnteringToClub  group by memberID having count(memberID) >=1) UNION select CustomerId, FirstName,SurName,PhoneNum,CellPhone from tblPotentialCustomer inner join tblCustomer on tblPotentialCustomer.interestedClientNum = tblCustomer.CustomerId where Status = 1 and tblPotentialCustomer.RecommendedByCustomerId  in ( select RecommendedByCustomerId  from tblPotentialCustomer  group by RecommendedByCustomerId   having count(RecommendedByCustomerId) >=2); ";
     sqlCmd          = new command(strSQL);
     dgQ2.DataSource = sqlCmd.datatable();
 }
        private void ALLClient_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet2.tblActualMembership' table. You can move, or remove it, as needed.
            this.tblActualMembershipTableAdapter.Fill(this.dataSet2.tblActualMembership);
            // TODO: This line of code loads data into the 'dataSet1.tblCustomer' table. You can move, or remove it, as needed.
            this.tblCustomerTableAdapter.Fill(this.dataSet1.tblCustomer);

            strSQL = "select * from tblCustomer";
            command sqlCmd = new command(strSQL);

            dgClients.DataSource = sqlCmd.datatable();
        }
 private void btnQ1_Click(object sender, EventArgs e)
 {
     //  btnQAB.Enabled = false;
     btnQ2.Visible   = false;
     btnQ1.Enabled   = false;
     back.Enabled    = false;
     btnEnd1.Visible = true;
     dgQ1.Visible    = true;
     //string strSQLQ21;
     strSQL = "select distinct CustomerId, FirstName+' '+ SurName AS fullname  from tblMemberCustomer inner join tblCustomer on tblMemberCustomer.memberID = tblCustomer.CustomerId left outer join tblEnteringToClub on tblMemberCustomer.memberID = tblEnteringToClub.memberID where tblEnteringToClub.memberID IS NULL;";
     //    sqlCmd = new command(strSQLQ21);
     //strSQL21 = "SELECT DISTINCT Q.clientId, Q.clientName, Q.siteId,  E.lastName + ' '+ E.firstName AS headTeamName FROM viewQ21 Q INNER JOIN  visits V ON V.clientId=Q.clientId AND V.siteId=Q.siteId INNER JOIN teams T ON T.teamID=V.teamId INNER JOIN Employee E ON E.empID=T.headTeam ORDER BY Q.clientName, Q.siteID DESC";
     sqlCmd          = new command(strSQL);
     dgQ1.DataSource = sqlCmd.datatable();
 }
        public void btnSearchClient_Click(object sender, EventArgs e)
        {
            back.Enabled            = false;
            txtID.Enabled           = false;
            table                   = new DataTable();
            btnWW.Enabled           = false;
            btnWW.Enabled           = false;
            btnSearchClient.Enabled = false;
            this.Size               = new Size(600, 490);
            string strClient = "select count(SerialNum) as numOfMembership, CustomerId, FirstName+' '+ SurName AS fullname,Address,count(interestedClientNum) as NumOfRecommendedCustomer from tblCustomer inner join tblActualMembership on tblCustomer.CustomerId=tblActualMembership.memberID inner join tblPotentialCustomer on tblCustomer.CustomerId=tblPotentialCustomer.RecommendedByCustomerId where tblcustomer.CustomerId=" + Convert.ToInt64(txtID.Text) + "group by CustomerId,FirstName,SurName,Address,RecommendedByCustomerId;";

            sqlCmd = new command(strClient);
            dgsearch.DataSource = sqlCmd.datatable();

            if (dgsearch.Rows.Count < 2)
            {
                MessageBox.Show("Customer is not found");
            }
        }