Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                CatergoriesID cat = new CatergoriesID();
                categoryList = cat.GetAll();

                DataListCategory.DataSource = categoryList;
                DataListCategory.DataBind();

                if (Session["catid"] != null)
                {
                    int Catid = Convert.ToInt32(Session["catid"]);


                    Place pl = new Place();
                    placeList = pl.GetAllPlacesByCat(Catid);

                    DataListPlaces.DataSource = placeList;
                    DataListPlaces.DataBind();
                }
                else
                {
                    Place pl = new Place();
                    placeList = pl.GetAllPlaces();

                    DataListPlaces.DataSource = placeList;
                    DataListPlaces.DataBind();
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                CatergoriesID cat = new CatergoriesID();
                categoryList = cat.GetAll();

                DataListCategory.DataSource = categoryList;
                DataListCategory.DataBind();

                if (Session["catid"] != null)
                {
                    int Catid = Convert.ToInt32(Session["catid"]);
                    Label13.Text = Catid.ToString();

                    Activity ac = new Activity();
                    activityList = ac.GetAllActivityByCategory(Catid);

                    DataListActivity.DataSource = activityList;
                    DataListActivity.DataBind();
                }
                else
                {
                }
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                if (Session["Catid"] != null)
                {
                    int           id = Convert.ToInt32(Session["Catid"]);
                    CatergoriesID ca = new CatergoriesID();
                    ca = ca.Select(id);

                    CatergoriesID cat = new CatergoriesID();
                    cTlist = cat.Catbyid(id);

                    DataListk.DataSource = cTlist;
                    DataListk.DataBind();

                    TextBoxName.Text = ca.CatName;
                    string img = ca.CatImage;
                    img = img.Replace("~/uploads/", "");
                    LabelCatName.Text = img;
                }
                else
                {
                    Response.Redirect("AddCategory.aspx");
                }
            }
        }
Example #4
0
        protected void LinkButtonCreate_Click(object sender, EventArgs e)
        {
            string name = TextBoxName.Text;


            int plid = Convert.ToInt32(Session["CatId"]);

            if (FileUploadCat.HasFile)
            {
                var    folder   = Server.MapPath("~/uploads");
                string fileName = Path.GetFileName(FileUploadCat.PostedFile.FileName);
                string filePath = "~/uploads/" + fileName;
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                FileUploadCat.PostedFile.SaveAs(Server.MapPath(filePath));

                CatergoriesID pl = new CatergoriesID(name, filePath);

                int result = pl.Updateee(plid);
                if (result == 1)
                {
                    LblErrorr.Text      = "Category successfully updated";
                    LblErrorr.ForeColor = System.Drawing.Color.Green;
                    Response.Redirect("ViewAllCategory.aspx");
                }
                else
                {
                    LblErrorr.Text      = "An error occured while adding, try again.";
                    LblErrorr.ForeColor = System.Drawing.Color.Red;
                }
            }
            else
            {
                var    folder   = Server.MapPath("~/uploads");
                string fileName = LabelCatName.Text;
                string filePath = "~/uploads/" + fileName;
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                FileUploadCat.PostedFile.SaveAs(Server.MapPath(filePath));

                CatergoriesID pl = new CatergoriesID(name, filePath);

                int result = pl.Updateee(plid);
                if (result == 1)
                {
                    LblErrorr.Text      = "Category successfully updated!";
                    LblErrorr.ForeColor = System.Drawing.Color.Green;
                    Response.Redirect("ViewAllCategory.aspx");
                }
                else
                {
                    LblErrorr.Text      = "An error occured while updating";
                    LblErrorr.ForeColor = System.Drawing.Color.Red;
                }
            }
        }
Example #5
0
        public List <CatergoriesID> GetEverything()
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            String sqlstmt = "SELECT CatID, CatName, CatImage FROM Category";

            SqlDataAdapter da = new SqlDataAdapter(sqlstmt, myConn);

            DataSet ds = new DataSet();

            da.Fill(ds);

            List <CatergoriesID> recList = new List <CatergoriesID>();

            int rec_cnt = ds.Tables[0].Rows.Count;

            if (rec_cnt == 0)
            {
                recList = null;
            }
            else
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int           catid      = Convert.ToInt32(row["CatID"]);
                    string        catname    = Convert.ToString(row["CatName"]);
                    string        catimage   = Convert.ToString(row["CatImage"]);
                    CatergoriesID categories = new CatergoriesID(catid, catname, catimage);
                    recList.Add(categories);
                }
            }
            return(recList);
        }
Example #6
0
        public CatergoriesID getOne(int id)
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string         sqlstmt = "SELECT * From Category where CatId = @paraId";
            SqlDataAdapter da      = new SqlDataAdapter(sqlstmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@paraId", id);

            DataSet ds = new DataSet();

            da.Fill(ds);

            CatergoriesID ca      = null;
            int           rec_cnt = ds.Tables[0].Rows.Count;

            if (rec_cnt == 1)
            {
                DataRow row   = ds.Tables[0].Rows[0];
                string  name  = row["CatName"].ToString();
                string  image = row["CatImage"].ToString();

                int catid = Convert.ToInt32(row["CatId"].ToString());


                ca = new CatergoriesID(catid, name, image);
            }
            return(ca);
        }
Example #7
0
        public int UpdateCat(CatergoriesID ca, int id)
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string sqlStmt = "UPDATE Category SET CatName = @parapname, CatImage = @paraimage WHERE CatId =  @paraplid";

            int        result = 0; // Execute NonQuery return an integer value
            SqlCommand sqlCmd = new SqlCommand(sqlStmt, myConn);


            sqlCmd = new SqlCommand(sqlStmt.ToString(), myConn);

            sqlCmd.Parameters.AddWithValue("@paraplid", id);
            sqlCmd.Parameters.AddWithValue("@parapname", ca.CatName);
            sqlCmd.Parameters.AddWithValue("@paraimage", ca.CatImage);


            myConn.Open();
            result = sqlCmd.ExecuteNonQuery();

            myConn.Close();

            return(result);
        }
Example #8
0
        public void BindData()
        {
            CatergoriesID cat = new CatergoriesID();

            categoryList = cat.GetAll();

            GridViewCat.DataSource = categoryList;
            GridViewCat.DataBind();
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                CatergoriesID cat = new CatergoriesID();
                categoryList = cat.GetAll();

                DataListCategory.DataSource = categoryList;
                DataListCategory.DataBind();
            }
        }
Example #10
0
        protected void GridViewCat_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(GridViewCat.DataKeys[e.RowIndex].Value);



            CatergoriesID rec = new CatergoriesID();

            rec.DeleteSelected(id);
            LabelMessage.Text      = "Successfully deleted!";
            LabelMessage.ForeColor = System.Drawing.Color.Green;
            BindData();
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CatergoriesID cc = new CatergoriesID();
                catList = cc.GetAll();

                category.Items.Clear();
                category.Items.Insert(0, new ListItem("--Select--", "0"));
                category.AppendDataBoundItems = true;
                category.DataTextField        = "CatName";
                category.DataValueField       = "CatId";
                category.DataSource           = catList;
                category.DataBind();
            }
        }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                Place pl = new Place();
                plList = pl.GetAllPlaces();

                DataListPlaces.DataSource = plList;
                DataListPlaces.DataBind();

                CatergoriesID cat = new CatergoriesID();
                categoryList = cat.GetAll();

                DataListCategory.DataSource = categoryList;
                DataListCategory.DataBind();
            }
        }
Example #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack == false)
     {
         CatergoriesID cc = new CatergoriesID();
         catList = cc.GetAll();
         category.Items.Clear();
         category.Items.Insert(0, new ListItem("--Select--", "0"));
         category.AppendDataBoundItems = true;
         category.DataTextField        = "CatName";
         category.DataValueField       = "CatId";
         category.DataSource           = catList;
         category.DataBind();
         if (Session["ActId"] != null)
         {
             int acid = Convert.ToInt32(Session["ActId"]);
             lblAcId.Text = acid.ToString();
             Activity ac = new Activity();
             ac = ac.RetrieveOne(acid);
             if (ac != null)
             {
                 AName.Text             = ac.AName;
                 ADesc.Text             = ac.ADesc;
                 ALocation.Text         = ac.ALocation;
                 category.SelectedValue = ac.CatId.ToString();
                 string img = ac.ImagePath;
                 img            = img.Replace("~/uploads/", "");
                 imgName.Text   = img;
                 APrice.Text    = ac.APrice;
                 AProvided.Text = ac.AProvided;
                 ABring.Text    = ac.ABring;
             }
             else
             {
                 Response.Redirect("AddActivity.aspx");
             }
         }
         else
         {
             Response.Redirect("AddActivity.aspx");
         }
     }
 }
Example #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                CatergoriesID cc = new CatergoriesID();
                catList = cc.GetAll();

                category.Items.Clear();
                category.Items.Insert(0, new ListItem("--Select--", "0"));
                category.AppendDataBoundItems = true;
                category.DataTextField        = "CatName";
                category.DataValueField       = "CatId";
                category.DataSource           = catList;
                category.DataBind();
                if (Session["PlaceId"] != null)
                {
                    int   id = Convert.ToInt32(Session["PlaceId"]);
                    Place pl = new Place();
                    pl = pl.retrieveOne(id);
                    if (pl != null)
                    {
                        Pname.Text             = pl.PName;
                        PDesc.Text             = pl.PDesc;
                        PLocation.Text         = pl.PLocation;
                        category.SelectedValue = pl.CatId.ToString();
                        region.SelectedValue   = pl.Region;
                        string img = pl.ImagePath;
                        img          = img.Replace("~/uploads/", "");
                        imgName.Text = img;
                    }
                    else
                    {
                        Response.Redirect("~/Views/Places/AddPlace.aspx");
                    }
                }
                else
                {
                    Response.Redirect("~/Views/Places/AddPlace.aspx");
                }
            }
        }
Example #15
0
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            string substring = TextBoxSearch.Text;

            if (substring == "")
            {
                CatergoriesID cat = new CatergoriesID();
                categoryList = cat.GetAll();

                DataListCategory.DataSource = categoryList;
                DataListCategory.DataBind();
            }
            else
            {
                CatergoriesID cat = new CatergoriesID();
                categoryList = cat.GetBySearch(substring);

                DataListCategory.DataSource = categoryList;
                DataListCategory.DataBind();
            }
        }
Example #16
0
        public List <CatergoriesID> SearchFor(string substring)
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            String sqlstmt = "SELECT * FROM Category where CatName LIKE @query";

            SqlDataAdapter da = new SqlDataAdapter(sqlstmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@query", "%" + substring + "%");

            DataSet ds = new DataSet();

            da.Fill(ds);

            List <CatergoriesID> plList = new List <CatergoriesID>();

            int rec_cnt = ds.Tables[0].Rows.Count;

            if (rec_cnt == 0)
            {
                plList = null;
            }
            else
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int    catid    = Convert.ToInt32(row["CatId"]);
                    string catname  = row["CatName"].ToString();
                    string catimage = row["CatImage"].ToString();

                    CatergoriesID objRate = new CatergoriesID(catid, catname, catimage);
                    plList.Add(objRate);
                }
            }
            return(plList);
        }