public bool CheckVisitorInfo(Visitor aVisitor,out string message)
        {
            if (aVisitor.Name == "")
            {
                message = "Name is not inserted";
                return false;

            }
             else if (aVisitor.ContactNo == "")
            {
                message = "Contact Number is not inserted";
                return false;

            }
            else if (aVisitor.Email == "")
            {
                message = "Email is not inserted";
                return false;

            }
            else if (visitorGateway.IsEmailExist(aVisitor.Email))
            {
                message = "Email is exist";
                return false;
            }
            else
            {
                message = "Saved visitor information Successfully";
                return true;
            }
        }
 public string Save(Visitor aVisitor,List<string> zoneVisit )
 {
     if (visitorGateway.SaveVisitorInformation(aVisitor,zoneVisit) > 0)
     {
         return " Successfully Save !";
     }
     else
     {
         return "Save Failed !";
     }
 }
        public void LoadZoneTypeVisitor(ZoneType zoneName)
        {
            visitorDetails= new List<Visitor>();

              visitorIdList = zoneManager.ZoneTypeVisitor(zoneName);
            foreach (int id in visitorIdList)
            {
                Visitor aVisitor=new Visitor();
                aVisitor = visitorManager.GetVisitorInfo(id);
                visitorDetails.Add(aVisitor);
            }

            LoadDataGridView(visitorDetails);
        }
 public Visitor GetVisitorDetails(int visitorID)
 {
     Visitor visitorDetails=new Visitor();
     dbGateway.SqlCommandObj.CommandText = "SELECT * FROM VisitorInfo_tbl WHERE ID='"+visitorID+"'";
     dbGateway.SqlConnectionObj.Open();
     SqlDataReader reader = dbGateway.SqlCommandObj.ExecuteReader();
     while (reader.Read())
     {
         visitorDetails.Name = reader[1].ToString();
         visitorDetails.Email = reader[2].ToString();
         visitorDetails.ContactNo = reader[3].ToString();
     }
     reader.Close();
     dbGateway.SqlConnectionObj.Close();
     return visitorDetails;
 }
        public int SaveVisitorInformation(Visitor visitorInfo,List<string> zoneVisit )
        {
            dbGateway.SqlCommandObj.CommandText = "INSERT INTO VisitorInfo_tbl(Name,Email,Contact_No) VALUES('" + visitorInfo.Name + "','" + visitorInfo.Email + "','" + visitorInfo.ContactNo + "')";
            dbGateway.SqlConnectionObj.Open();
            int rowAffected = dbGateway.SqlCommandObj.ExecuteNonQuery();
            dbGateway.SqlConnectionObj.Close();
            int visitorId = GetVisitorID(visitorInfo.Email);
            int zoneID = 0;
            foreach (string zone in zoneVisit)
            {
                zoneID = zoneGateway.GetZoneID(zone);
                relationship.SaveRelation(visitorId,zoneID);

            }

            return rowAffected;
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            Visitor aVisitor=new Visitor();
            aVisitor.Name = nameTextBox.Text;
            aVisitor.Email = emailTextBox.Text;
            aVisitor.ContactNo = contactTextBox.Text;
            List<string> visitorZoneTypeList= new List<string>();

            if (!aVisitorManager.CheckVisitorInfo(aVisitor, out message))
            {
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else
            {
                for (int i = 1; i <= count; i++)
                {
                    if (i == 1 && checkBox1.Checked == true)
                    {
                        visitorZoneTypeList.Add(checkBox1.Text);
                    }
                    else if (i == 2 && checkBox2.Checked == true)
                    {
                        visitorZoneTypeList.Add(checkBox2.Text);
                    }
                    else if (i == 3 && checkBox3.Checked == true)
                    {
                        visitorZoneTypeList.Add(checkBox3.Text);
                    }
                    else if (i == 4 && checkBox4.Checked == true)
                    {
                        visitorZoneTypeList.Add(checkBox4.Text);
                    }

                    else if (i == 5 && checkBox5.Checked == true)
                    {
                        visitorZoneTypeList.Add(checkBox5.Text);
                    }
                    else if (i == 6 && checkBox6.Checked == true)
                    {
                        visitorZoneTypeList.Add(checkBox6.Text);
                    }
                }

                aVisitorManager.Save(aVisitor, visitorZoneTypeList);
                MessageBox.Show(message, "Successfully Saved", MessageBoxButtons.OK);

            }
            nameTextBox.Text = emailTextBox.Text = contactTextBox.Text = null;
            zoneList = aZoneManager.ZoneList();
            CheckZoneType(zoneList);
        }