public Center GetCenter(string centerCode, string password)
        {
            Center aCenter = new Center();

            SqlConnection connection = new SqlConnection(connectionString);
            string query = string.Format("SELECT * FROM Center Where CenterCode='{0}' AND CenterPassword='******'", centerCode, password);

            connection.Open();
            SqlCommand command = new SqlCommand(query, connection);

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {

                aCenter.CenterId = Convert.ToInt32(reader["CenterId"]);
                aCenter.CenterName = reader["CenterName"].ToString();
                aCenter.CenterCode = reader["CenterCode"].ToString();
                aCenter.CenterPassword = reader["CenterPassword"].ToString();
                aCenter.ThanaId = Convert.ToInt32(reader["ThanaId"]);

            }
            reader.Close();
            connection.Close();
            return aCenter;
        }
        public bool IsCenterNameExists(Center aCenter)
        {
            bool isCenterNameExists = false;

            SqlConnection connection = new SqlConnection(connectionString);
            string query = string.Format("Select * From Center where CenterName='{0}' and ThanaId='{1}'", aCenter.CenterName,aCenter.ThanaId);
            SqlCommand command = new SqlCommand(query, connection);
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                isCenterNameExists = true;
                break;
            }
            reader.Close();
            connection.Close();
            return isCenterNameExists;
        }
 public int Save(Center aCenter)
 {
     string query = string.Format("INSERT INTO Center VALUES('{0}','{1}','{2}','{3}')", aCenter.CenterName, aCenter.CenterCode,aCenter.CenterPassword,aCenter.ThanaId);
     SqlConnection connection = new SqlConnection(connectionString);
     SqlCommand command = new SqlCommand(query, connection);
     connection.Open();
     int rowAffected = command.ExecuteNonQuery();
     connection.Close();
     return rowAffected;
 }
        public List<Center> PopulateCenterDropDownList(int thanaId)
        {
            List<Center> centerList = new List<Center>();
            SqlConnection connection = new SqlConnection(connectionString);
            string query = string.Format("SELECT * FROM Center Where ThanaId='{0}'", thanaId);

            connection.Open();
            SqlCommand command = new SqlCommand(query, connection);

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Center aCenter = new Center();
                aCenter.CenterId = Convert.ToInt32(reader["CenterId"]);
                aCenter.CenterName = reader["CenterName"].ToString();
                centerList.Add(aCenter);

            }
            reader.Close();
            connection.Close();
            return centerList;
        }
        public string Save(Center aCenter)
        {
            if (gateway.IsCenterNameExists(aCenter))
            {
                return "CenterName Already Exists";
            }
            else
            {
                if (gateway.Save(aCenter) > 0)
                {
                    return "Saved Succesfully";
                }
                else
                {
                    return "Saving failed";
                }

            }
        }