Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Request["CategoryId"] != null)
            {
                // get categoryID from Query string
                int categoryId = int.Parse(Request["CategoryId"]);
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                //Bind all the images of the selected category
                var image = from i in data.ImageInfoes where i.CategoryId == categoryId select i;
                rptPortfolio.DataSource = image.ToList();
                rptPortfolio.DataBind();

                //get category name for Heading
                var cate = from c in data.CategoryInfoes where c.categoryId == categoryId select c;
                foreach (CategoryInfo ci in cate)
                {
                    Myheading.InnerText = ci.CategoryName;
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// // Get all Categories on page load
    /// </summary>
    private void ViewCategory()
    {
        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

        rptrCategory.DataSource = data.CategoryInfoes.ToList();
        rptrCategory.DataBind();
    }
Exemplo n.º 3
0
    /// <summary>
    ///  view portfolio images in admin
    /// </summary>
    private void ViewImages()
    {
        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

        rptrGallery.DataSource = data.ImageInfoes.ToList();
        rptrGallery.DataBind();
    }
Exemplo n.º 4
0
    /// <summary>
    /// Add New Category
    /// </summary>
    protected void btnAddCategory_Click(object sender, EventArgs e)
    {
        try
        {
            string category = txtCategory.Text.Trim();
            if (Checks.Empty(category))
            {
                lblmsg.Text = "*Category Name is Required!!";
            }
            else
            {
                // give data to class
                CategoryInfo ci = new CategoryInfo();
                ci.CategoryName = category;

                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                // save data to database
                data.CategoryInfoes.Add(ci);
                data.SaveChanges();

                ViewCategory();        // bind categories
                lblmsg.Text      = "*New Category Saved!!";
                txtCategory.Text = ""; // clear textbox text
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 5
0
    // Bind images on page load
    private void ViewBanner()
    {
        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

        rptrBanner.DataSource = data.BannerInfoes.ToList();
        rptrBanner.DataBind();
    }
Exemplo n.º 6
0
    protected void rptrGallery_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {   // delete any image from portfolio
            if (e.CommandName.Equals("del"))
            {
                int    ImageID = int.Parse(e.CommandArgument.ToString());
                string path;
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                ImageInfo bt = new ImageInfo();
                bt = data.ImageInfoes.Single(c => c.ImageID == ImageID); // lambda expression
                data.ImageInfoes.Attach(bt);
                data.ImageInfoes.Remove(bt);
                data.SaveChanges(); // remove the


                //delete the image from the path as well
                path = Server.MapPath("~/Image/Banner/" + bt.ImageSize + bt.ImageName);
                if (File.Exists(path))
                {
                    File.Delete(path);

                    lblmsg.Text = "*Image Deleted!!";
                }
                ViewImages(); // bind images after that
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 7
0
    protected void lnkvideo_Click(object sender, EventArgs e)
    {   // save the videos to the database
        try
        {
            if (Checks.Empty(txtsrc.Text.Trim()))
            {
                lblmsg.Text = "*Video Source is Required!!";
            }
            else
            {
                // give data to class
                videoYoutube vy = new videoYoutube();
                vy.VideoSource = txtsrc.Text.Trim();

                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();
                data.videoYoutubes.Add(vy); // Add the video code to database
                data.SaveChanges();
                ViewVideo();                // method calling to bind videos
                lblmsg.Text = "*New Video Saved!!";
                txtsrc.Text = "";
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 8
0
    /// <summary>
    /// Get all videos for the page
    /// </summary>
    private void ViewVideo()
    {
        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

        rptrvideo.DataSource = data.videoYoutubes.ToList();
        rptrvideo.DataBind();
    }
Exemplo n.º 9
0
    /// <summary>
    /// add portfolio data
    /// </summary>
    protected void lnkaddImage_Click(object sender, EventArgs e)
    {
        try
        {
            string ImageDescription = txtdescription.Text.Trim();
            string caption          = txtCaption.Text.Trim();
            string CategoryId       = ddlCategory.SelectedValue;
            if (CategoryId.Contains("-1"))
            {
                lblmsg.Text = "*Category is required!!";
            }

            else if (fufImage.HasFiles == false)
            {
                lblmsg.Text = " *Please select image to upload!!";
            }
            else
            {
                foreach (var file in fufImage.PostedFiles)
                {
                    //add image data
                    ImageInfo data = new ImageInfo();
                    data.ImageName        = file.FileName;
                    data.ImageExtension   = file.FileName.Substring(file.FileName.LastIndexOf('.'));
                    data.ImageSize        = file.ContentLength;
                    data.ImageType        = file.ContentType;
                    data.ImageDescription = ImageDescription;
                    data.Imagecaption     = caption;
                    data.CategoryId       = int.Parse(CategoryId);
                    if (file.ContentType == "image/jpeg" || file.ContentType == "image/png")
                    {
                        AmanpreetPortEntities1 apData = new AmanpreetPortEntities1();
                        apData.ImageInfoes.Add(data);
                        apData.SaveChanges();

                        //save image at given path
                        string path = Server.MapPath("~/Image/Gallery/" + file.ContentLength + file.FileName);
                        file.SaveAs(path);

                        txtdescription.Text       = ""; // clear textbox text
                        txtCaption.Text           = "";
                        ddlCategory.SelectedIndex = 0;  // reset dropdown index


                        ViewImages(); //method calling: bind images
                        lblmsg.Text = "*New Item Saved!!";
                    }
                    else
                    {
                        lblmsg.Text = "Please choose a .JPEG or .PNG image only";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 10
0
    //Bind Categories to menubar (portfolio)
    private void BindMenuCategory()
    {
        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();
        var cate = from c in data.CategoryInfoes select c;

        repCategories.DataSource = cate.ToList();
        repCategories.DataBind();
    }
Exemplo n.º 11
0
    //bind categories to menuber item(portfolio)
    private void BindDDLcategory()
    {
        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

        ddlCategory.DataSource = data.CategoryInfoes.ToList();

        ddlCategory.DataValueField = "categoryId";
        ddlCategory.DataTextField  = "CategoryName";
        ddlCategory.DataBind();
        ddlCategory.Items.Insert(0, new ListItem("Select Category", "-1"));
    }
Exemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         // Bind all the home images to home page
         AmanpreetPortEntities1 data = new AmanpreetPortEntities1();
         var ban = from b in data.BannerInfoes select b;
         rptrHomeImages.DataSource = ban.ToList();
         rptrHomeImages.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 13
0
    //Add images to database
    protected void lnkaddBanner_Click(object sender, EventArgs e)
    {
        try
        {
            if (fufBanner.HasFiles == false)
            {
                lblmsg.Text = " *Please select a file to upload";
            }
            else
            {
                foreach (var file in fufBanner.PostedFiles)
                {
                    //put image info to class
                    BannerInfo data = new BannerInfo();
                    data.BannerName      = file.FileName;
                    data.BannerExtension = file.FileName.Substring(file.FileName.LastIndexOf('.'));
                    data.BannerSize      = file.ContentLength;
                    data.BannerType      = file.ContentType;
                    if (file.ContentType == "image/jpeg" || file.ContentType == "image/png")
                    {
                        AmanpreetPortEntities1 apData = new AmanpreetPortEntities1();
                        apData.BannerInfoes.Add(data);
                        int    ans = apData.SaveChanges();
                        string path;
                        if (ans > 0)
                        {
                            // save the image to the path
                            path = Server.MapPath("~/Image/Banner/" + file.ContentLength + file.FileName);
                            file.SaveAs(path);
                            ViewBanner();
                        }

                        lblmsg.Text = "*New Item Saved!!";
                    }
                    else
                    {
                        lblmsg.Text = "Please choose a .JPEG or .PNG image only";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         if (!IsPostBack)
         {
             // Bind all the videos to the page
             AmanpreetPortEntities1 data = new AmanpreetPortEntities1();
             var video = from v in data.videoYoutubes select v;
             rptrvid.DataSource = video.ToList();
             rptrvid.DataBind();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 15
0
    protected void rptrvideo_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            /// <summary>
            /// Delete the selected video
            /// </summary>
            if (e.CommandName.Equals("del"))
            {
                int videoId = int.Parse(e.CommandArgument.ToString()); // get video id
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                videoYoutube vid = new videoYoutube();
                vid = data.videoYoutubes.Single(v => v.VideoYoutubeID == videoId);
                data.videoYoutubes.Attach(vid);
                data.videoYoutubes.Remove(vid);
                data.SaveChanges();
                ViewVideo(); // method calling to bind videos grid after delete
            }
            else if (e.CommandName.Equals("delall"))
            {   // delete all videos
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                // get video id's for delete all operation
                var videoids = from b in data.videoYoutubes select b.VideoYoutubeID;

                foreach (var v in videoids)
                {                                                                 // iterate through each video id to delete all one by one
                    videoYoutube vybt = new videoYoutube();
                    vybt = data.videoYoutubes.Single(c => c.VideoYoutubeID == v); // lamda expression

                    data.videoYoutubes.Attach(vybt);
                    data.videoYoutubes.Remove(vybt);
                }

                data.SaveChanges();
                ViewVideo(); // method calling: to bind video grid
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                // count total number of Home Images
                var count = (from b in data.BannerInfoes select b).Count();

                if (count.ToString() != null)
                {
                    lblBanner.Text = count.ToString();
                }

                // count total number portfolio images
                var count1 = (from i in data.ImageInfoes select i).Count();
                if (count1.ToString() != null)
                {
                    lblPortfolio.Text = count1.ToString();
                }

                // count total number of Categories
                var count2 = (from c in data.CategoryInfoes select c).Count();
                if (count2.ToString() != null)
                {
                    lblCategory.Text = count2.ToString();
                }

                // count total number of videos
                var count3 = (from v in data.videoYoutubes select v).Count();
                if (count3.ToString() != null)
                {
                    lblVideo.Text = count3.ToString();
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 17
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {  // Update the category
        string categoryname = txtCategoryEdit.Text.Trim();

        int categoryID = int.Parse(lblCategoryID1.Text);

        AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

        var CategoryInfo = from c in data.CategoryInfoes where c.categoryId == categoryID select c;

        foreach (CategoryInfo c in CategoryInfo)
        {
            c.CategoryName = categoryname;
        }

        data.SaveChanges();

        ViewCategory();              // method calling: to bind categories

        pnlCategory.Visible = false; // popup will disapper after updation
    }
Exemplo n.º 18
0
    /// <summary>
    /// login the admin
    /// </summary>
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        try
        {
            /*if RememberME checkBox is check then
             * set the cookiee username and pswd for 30days */

            if (chkremeber.Checked)
            {
                Response.Cookies["UserNamecookie"].Expires  = DateTime.Now.AddDays(30);
                Response.Cookies["passwordcoookie"].Expires = DateTime.Now.AddDays(30);
            }
            else
            {
                // if not, then expire the cookiee
                Response.Cookies["UserNamecookie"].Expires  = DateTime.Now.AddDays(-1);
                Response.Cookies["passwordcoookie"].Expires = DateTime.Now.AddDays(-1);
            }

            // put textbox values to cookiee
            Response.Cookies["UserNamecookie"].Value  = txtusername.Text.Trim();
            Response.Cookies["passwordcoookie"].Value = txtpassword.Text.Trim();

            string username, password;
            username = txtusername.Text.Trim();
            password = txtpassword.Text.Trim();

            if (Checks.Empty(username) && Checks.Empty(password))
            {
                lblmsg.Text = "*Please fill all fields!!";
            }
            else if (Checks.Empty(username))
            {
                lblmsg.Text = "*Username is required!";
            }
            else if (Checks.Empty(password))
            {
                lblmsg.Text = "*Password is required!";
            }
            else if (!Checks.Empty(username) && !Checks.Empty(password))
            {
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();
                LoginInfo li = new LoginInfo();

                // linq query: to get data by user name and password
                li = (from log in data.LoginInfoes
                      where log.UserName == username & log.Password == password
                      select log).First();

                if (li != null)
                {
                    Session["Username"] = username;  // store user-name in session
                    Session["UserID"]   = li.UserID; // store user-id in session
                    Response.Redirect("Admin/Dashboard.aspx");
                }
                else
                {
                    lblmsg.Text = "*Invalid Username Or Password!!";
                }
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 19
0
    protected void rptrCategory_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            /// <summary>
            /// Delete selected Category;
            /// As the category deleted, its related portfolio data will be deleted as well
            /// as cascade delete is implemented in database.
            /// </summary>
            if (e.CommandName.Equals("del"))
            {
                int CategoryId = int.Parse(e.CommandArgument.ToString()); // get category id
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                //get the category to delete
                CategoryInfo cid = new CategoryInfo();
                cid = data.CategoryInfoes.Single(v => v.categoryId == CategoryId); // lambda expression

                // delete the category
                data.CategoryInfoes.Attach(cid);
                data.CategoryInfoes.Remove(cid);
                data.SaveChanges();

                ViewCategory();
                lblmsg.Text = "*Category Deleted!!";
            }
            else if (e.CommandName.Equals("delall"))
            { // Delete all categories here
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                var cateIds = from ct in data.CategoryInfoes select ct.categoryId;

                // delete all categories one by one
                foreach (var ctx in cateIds)
                {
                    CategoryInfo ci = new CategoryInfo();

                    ci = data.CategoryInfoes.Single(c => c.categoryId == ctx); // lamda expression

                    data.CategoryInfoes.Attach(ci);
                    data.CategoryInfoes.Remove(ci);
                }

                data.SaveChanges();
                ViewCategory(); // method calling- to bind the categories
            }
            else if (e.CommandName.Equals("edit"))
            {                                                             // edit the selected category
                pnlCategory.Visible = true;                               // show popup to bind edit record
                int CategoryId = int.Parse(e.CommandArgument.ToString()); // get category id
                lblCategoryID1.Text = CategoryId.ToString();

                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                // get category info for the selected category
                var cid = from c in data.CategoryInfoes
                          where c.categoryId == CategoryId select c;


                foreach (CategoryInfo c in cid)
                {
                    txtCategoryEdit.Text = c.CategoryName; // set the category name in popup textbox
                }
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 20
0
    protected void rptrBanner_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            // to delete selected image
            if (e.CommandName.Equals("del"))
            {
                string path;
                int    BannerID             = int.Parse(e.CommandArgument.ToString());
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                BannerInfo bt = new BannerInfo();
                bt = data.BannerInfoes.Single(c => c.BannerID == BannerID);
                // lamda expression to get image info

                if (bt != null)
                {
                    //remove image
                    data.BannerInfoes.Attach(bt);
                    data.BannerInfoes.Remove(bt);
                    data.SaveChanges();

                    //delete image from the path
                    path = Server.MapPath("~/Image/Banner/" + bt.BannerName);
                    if (File.Exists(path))
                    {
                        File.Delete(path);

                        lblmsg.Text = "*Image Deleted!!";
                    }
                }
                ViewBanner(); //method calling to bind image after delete
            }
            else if (e.CommandName.Equals("delall"))
            {   // delete all images
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();

                //get all image info data to delete
                var dbBannerId = from b in data.BannerInfoes select b.BannerID;

                string path;
                foreach (var bid in dbBannerId)
                {
                    BannerInfo bt = new BannerInfo();
                    bt = data.BannerInfoes.Single(c => c.BannerID == bid); // lamda expression


                    path = Server.MapPath("~/Image/Banner/" + bt.BannerName);
                    if (File.Exists(path))
                    {
                        // delete images from the path
                        File.Delete(path);
                    }

                    data.BannerInfoes.Attach(bt);
                    data.BannerInfoes.Remove(bt); // remove image data
                }

                data.SaveChanges();
                ViewBanner(); // method calling to bind images
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
Exemplo n.º 21
0
    /// <summary>
    /// // Change the login password
    /// </summary>
    protected void lnkaddchnge_Click(object sender, EventArgs e)
    {
        try
        {
            string oldpassword, newpassword, confirmpassword;
            oldpassword     = txtoldpswd.Text.Trim(); // enter old pswd
            newpassword     = txtnewpswd.Text.Trim(); // enter new pswd
            confirmpassword = txtnewpswd.Text.Trim(); // confirm new pswd
            if (Checks.Empty(oldpassword) && Checks.Empty(newpassword) && Checks.Empty(confirmpassword))
            {
                lblmsg.Text = "*Please Fill all Fields!!";
            }
            else if (Checks.Empty(oldpassword))
            {
                lblmsg.Text = "*Please Enter Old Password!!";
            }
            else if (Checks.Empty(newpassword))
            {
                lblmsg.Text = "*Please Enter New Password!!";
            }
            else if (Checks.Empty(confirmpassword))
            {
                lblmsg.Text = "*Please Enter confirm Password!!";
            }
            else if (newpassword != confirmpassword)
            {
                lblmsg.Text = "*Password Doesn't matched!!";
            }
            else if (newpassword == confirmpassword && !Checks.Empty(oldpassword) && !Checks.Empty(newpassword) && !Checks.Empty(confirmpassword))
            {
                int user = int.Parse(Session["UserID"].ToString()); //get user id from session
                AmanpreetPortEntities1 data = new AmanpreetPortEntities1();


                LoginInfo li = new LoginInfo();

                // get user info from password
                li = (from l in data.LoginInfoes where l.UserID == user
                      where l.Password == oldpassword select l).FirstOrDefault();

                if (li != null)
                {
                    var dt = from l in data.LoginInfoes
                             where l.UserID == user
                             select l;

                    foreach (LoginInfo li1 in dt)
                    {
                        li1.Password = newpassword; // give new password to class
                        lblmsg.Text  = "! Password Changed Successfully";
                    }
                }
                else if (li == null)
                {
                    lblmsg.Text = "!Old Password Incorrect";
                }
                data.SaveChanges(); // password updated!
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }