Example #1
0
    //Get all enquries in view
    private void BindRepEnquiry()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();

        repEnquiry.DataSource = data.EnquiryInfoes.ToList();
        repEnquiry.DataBind();
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            /// <summary>
            /// //Dashbord section counter, get the number of slider images,
            /// categories, products, enquiries
            /// </summary>
            BakersLoungeEntities data = new BakersLoungeEntities();

            var count1 = (from i in data.CategoryInfoes select i).Count(); // categories count
            if (count1.ToString() != null)
            {
                lblCategoryCount.Text = count1.ToString();
            }
            var count2 = (from c in data.ProductInfoes select c).Count(); // total products count
            if (count2.ToString() != null)
            {
                lblProductCount.Text = count2.ToString();
            }
            var count3 = (from v in data.EnquiryInfoes select v).Count(); // total enquiries
            if (count3.ToString() != null)
            {
                lblEnquiryCount.Text = count3.ToString();
            }
        }
    }
    //Bind all Category
    private void BindRepCategories()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();

        repCategories.DataSource = data.CategoryInfoes.ToList();
        repCategories.DataBind();
    }
    private void BindGridProductsCategoryWise(int CategoryId) //bind product category wise.
    {
        BakersLoungeEntities data = new BakersLoungeEntities();
        var pro = from p in data.ProductInfoes join c in data.CategoryInfoes on p.CategoryId equals c.CategoryId where p.CategoryId == CategoryId select new { p.ProductId, p.ProductTitle, p.PhotoType, p.PhotoSize, p.PhotoName, p.ExtName, c.CategoryName };

        gvProducts.DataSource = pro.ToList();
        gvProducts.DataBind();
    }
Example #5
0
    // Get Featured products on page load
    private void BindFeaturedProducts()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();
        var pro = from p in data.ProductInfoes select p;

        repFeaturedProducts.DataSource = pro.ToList();
        repFeaturedProducts.DataBind();
    }
    //Get All Ice-cream Categories in Footer
    private void BindRepCategories()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();
        var cate = from c in data.CategoryInfoes select c;

        repCategories.DataSource = cate.ToList();
        repCategories.DataBind();
    }
Example #7
0
    //Get all Products on page load
    private void BindRepAllProducts()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();
        var pro = from p in data.ProductInfoes select p;

        repProductsOfCategory.DataSource = pro.ToList();
        repProductsOfCategory.DataBind();
    }
    //Bind all the categories to select
    private void BindDdlCategory()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();

        ddlCategory.DataSource     = data.CategoryInfoes.ToList();
        ddlCategory.DataTextField  = "CategoryName";
        ddlCategory.DataValueField = "CategoryID";
        ddlCategory.DataBind();
    }
Example #9
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        try
        {
            //change password for admin login
            string OldPswd, NewPswd, ConfirmPswd;
            OldPswd     = txtOldPswd.Text.Trim();
            NewPswd     = txtNewPswd.Text.Trim();
            ConfirmPswd = txtCpswd.Text.Trim();
            string userid = Session["userid"].ToString();

            if (Checks.Empty(OldPswd) && Checks.Empty(NewPswd) && Checks.Empty(ConfirmPswd))
            {
                lblMsg.Text = "All fields required!";
            }
            else if (Checks.Empty(OldPswd))
            {
                lblMsg.Text = "Old password is required!";
            }
            else if (Checks.Empty(NewPswd))
            {
                lblMsg.Text = "New password is required!";
            }
            else if (Checks.Empty(ConfirmPswd))
            {
                lblMsg.Text = "Confirm-password is required!";
            }
            else
            {
                int user = int.Parse(Session["UserID"].ToString());
                BakersLoungeEntities data = new BakersLoungeEntities();
                loginInfo            li   = new loginInfo();
                li = (from l in data.loginInfoes where l.LoginInfoId == user where l.Password == OldPswd select l).FirstOrDefault(); //Linq query
                if (li != null)
                {
                    var image = from l in data.loginInfoes
                                where l.LoginInfoId == user
                                select l;
                    foreach (loginInfo li1 in image)
                    {
                        li1.Password = NewPswd;
                        lblMsg.Text  = "!Password Changed Successfully";
                    }
                }
                else if (li == null)
                {
                    lblMsg.Text = "!Old Password Incorrect";
                }
                data.SaveChanges();
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
    // Add new category
    protected void btnAddCategory_Click(object sender, EventArgs e)
    {
        try
        {
            string CategoryName = txtCategoryName.Text.Trim();

            if (Checks.Empty(CategoryName))
            {
                lblMsg.Text = "Please enter Category name";
            }
            else
            {
                // if category name already filled in textbox then update the name else add new category

                if (btnAddCategory.Text == "Update Category")   //Update Category.....
                {
                    int          Id = int.Parse(hfCatId.Value);
                    CategoryInfo ci = new CategoryInfo();
                    ci.CategoryName = CategoryName;
                    ci.CategoryId   = Id;
                    BakersLoungeEntities data = new BakersLoungeEntities();
                    var CategoryInfo          = from c in data.CategoryInfoes where c.CategoryId == Id select c;
                    foreach (CategoryInfo c in CategoryInfo)
                    {
                        c.CategoryName = CategoryName;
                    }
                    data.SaveChanges();
                    BindRepCategories();
                    lblMsg.Text = "Category name has been updated";
                }
                else
                {
                    //Add new category
                    CategoryInfo ci1 = new CategoryInfo();
                    ci1.CategoryName = CategoryName;
                    BakersLoungeEntities data1 = new BakersLoungeEntities();
                    data1.CategoryInfoes.Add(ci1);
                    data1.SaveChanges();
                    BindRepCategories();
                    lblMsg.Text          = "*New Category Added!!";
                    txtCategoryName.Text = "";
                }
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("UNIQUE"))
            {
                lblMsg.Text = "This category name already exists";
            }
            else
            {
                lblMsg.Text = ex.Message;
            }
        }
    }
Example #11
0
    //bind categories for subject to enquiry
    private void BindDdlSubjectCategory()
    {
        BakersLoungeEntities data = new BakersLoungeEntities();
        var cate = from c in data.CategoryInfoes select c;

        ddlSubject.DataSource     = cate.ToList();
        ddlSubject.DataTextField  = "CategoryName";
        ddlSubject.DataValueField = "CategoryID";
        ddlSubject.DataBind();
    }
Example #12
0
 // Add products for the selected category
 protected void btnAddProduct_Click(object sender, EventArgs e)
 {
     try
     {
         string ProductTitle = txtProductTitle.Text.Trim();
         string CategoryId   = ddlCategory.SelectedValue;
         if (CategoryId.Contains("-1"))
         {
             lblMsg.Text = "Please select a category";
         }
         else if (!Checks.checkNumber(CategoryId))
         {
             lblMsg.Text = "Category id must be a number";
         }
         else if (Checks.Empty(ProductTitle))
         {
             lblMsg.Text = "Please enter product title";
         }
         else if (fuFile.HasFile)  //add new product
         {
             ProductInfo data = new ProductInfo();
             data.CategoryId   = int.Parse(CategoryId);
             data.ProductTitle = ProductTitle;
             data.PhotoName    = fuFile.PostedFile.FileName;
             data.ExtName      = fuFile.PostedFile.FileName.Substring(fuFile.PostedFile.FileName.LastIndexOf('.'));
             data.PhotoSize    = fuFile.PostedFile.ContentLength;
             data.PhotoType    = fuFile.PostedFile.ContentType;
             if (fuFile.PostedFile.ContentType == "image/jpeg" || fuFile.PostedFile.ContentType == "image/png")
             {
                 BakersLoungeEntities apData = new BakersLoungeEntities();
                 apData.ProductInfoes.Add(data);
                 apData.SaveChanges();
                 string path1 = Server.MapPath("../ProductImages/" + fuFile.PostedFile.ContentLength + fuFile.PostedFile.FileName);
                 fuFile.PostedFile.SaveAs(path1); // save product image on the specififed path
                 txtProductTitle.Text = "";
                 lblMsg.Text          = "Product Saved!";
                 pnlProducts.Visible  = true;
                 BindddlAllCategories();
                 BindGridAllProducts();
             }
             else
             {
                 lblMsg.Text = "Please choose a .JPEG or .PNG image only";
             }
         }
         else
         {
             lblMsg.Text = "Please choose a product image";
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
    protected void repCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName.Equals("del"))  //delete Category
            {
                int CategoryId            = int.Parse(e.CommandArgument.ToString());
                BakersLoungeEntities data = new BakersLoungeEntities();
                CategoryInfo         cid  = new CategoryInfo();
                cid = data.CategoryInfoes.Single(v => v.CategoryId == CategoryId);
                data.CategoryInfoes.Attach(cid);
                data.CategoryInfoes.Remove(cid);
                data.SaveChanges();
                BindRepCategories();
                lblMsg.Text = "*Category Deleted!!";
            }
            else if (e.CommandName.Equals("ed")) //Edit Category
            {
                int CategoryId            = int.Parse(e.CommandArgument.ToString());
                BakersLoungeEntities data = new BakersLoungeEntities();
                var cid = from c in data.CategoryInfoes where c.CategoryId == CategoryId select c;
                foreach (CategoryInfo c in cid)
                {
                    txtCategoryName.Text = c.CategoryName;
                    hfCatId.Value        = c.CategoryId.ToString();
                    txtCategoryName.Focus();
                }
                btnAddCategory.Text = "Update Category"; // set the button text on edit command
            }
            else if (e.CommandName.Equals("delall"))     //delete all category
            {
                BakersLoungeEntities data = new BakersLoungeEntities();

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

                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();
                BindRepCategories();
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
Example #14
0
 protected void repEnquiry_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("del"))  //delete enquiry
     {
         int id = int.Parse(e.CommandArgument.ToString());
         BakersLoungeEntities data = new BakersLoungeEntities();
         EnquiryInfo          cid  = new EnquiryInfo();
         cid = data.EnquiryInfoes.Single(v => v.EnquiryId == id); // get "enquiry id" to delete!
         data.EnquiryInfoes.Attach(cid);
         data.EnquiryInfoes.Remove(cid);
         data.SaveChanges();
         BindRepEnquiry();
         lblMsg.Text = "*Enquiry Deleted!!";
     }
 }
Example #15
0
    /// <summary>
    ///  //Login admin panel
    ///  //Enter username and password to login
    /// </summary>

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string userName, pswd;
            userName = txtUserName.Text.Trim();
            pswd     = txtPswd.Text.Trim();

            if (Checks.Empty(userName) && Checks.Empty(pswd))
            {
                lblMsg.Text = "User name and password are required!";
            }
            else if (Checks.Empty(userName))
            {
                lblMsg.Text = "User name is required!";
            }
            else if (Checks.Empty(pswd))
            {
                lblMsg.Text = "Password is required!";
            }
            else
            {
                BakersLoungeEntities data = new BakersLoungeEntities();
                loginInfo            li   = new loginInfo();

                // linq query
                li = (from log in data.loginInfoes
                      where log.UserName == userName & log.Password == pswd
                      select log).First();
                if (li != null)
                {
                    // create session for the user
                    Session["Username"] = userName;
                    Session["UserID"]   = li.LoginInfoId;
                    Response.Redirect("admin/Dashboard.aspx");
                }
                else
                {
                    lblMsg.Text = "*Invalid Username Or Password!!";
                }
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
Example #16
0
 protected void repCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     try
     {
         if (e.CommandName.Equals("vw"))
         {
             //bind product category wise
             int Id = int.Parse(e.CommandArgument.ToString());
             BakersLoungeEntities data = new BakersLoungeEntities();
             var pro = from p in data.ProductInfoes join c in data.CategoryInfoes on p.CategoryId equals c.CategoryId where p.CategoryId == Id select new { p.ProductId, p.ProductTitle, p.PhotoType, p.PhotoSize, p.PhotoName, p.ExtName, c.CategoryName };
             repProductsOfCategory.DataSource = pro.ToList();
             repProductsOfCategory.DataBind();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #17
0
 //bind all products on page load
 private void BindGridAllProducts()
 {
     try
     {
         BakersLoungeEntities data = new BakersLoungeEntities();
         if (data == null)
         {
             pnlProducts.Visible = false;
         }
         else
         {
             pnlProducts.Visible = true;
             var pro = from p in data.ProductInfoes join c in data.CategoryInfoes on p.CategoryId equals c.CategoryId select new { p.ProductId, p.ProductTitle, p.PhotoType, p.PhotoSize, p.PhotoName, p.ExtName, c.CategoryId, c.CategoryName };
             gvProducts.DataSource = pro.ToList();
             gvProducts.DataBind();
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Example #18
0
    //Delete the selected product
    protected void gvProducts_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //delete products
        int    Id = int.Parse(gvProducts.DataKeys[e.RowIndex].Value.ToString());
        string path;
        BakersLoungeEntities data = new BakersLoungeEntities();

        ProductInfo bt = new ProductInfo();

        bt = data.ProductInfoes.Single(c => c.ProductId == Id); // lambda expression
        data.ProductInfoes.Attach(bt);
        data.ProductInfoes.Remove(bt);
        data.SaveChanges();
        path = Server.MapPath("../ProductImages/" + bt.PhotoSize + bt.PhotoName);
        if (File.Exists(path))
        {
            File.Delete(path); // delete the product image as well

            lblMsg.Text = "*Image Deleted!!";
        }
        BindGridAllProducts();
    }
Example #19
0
    //submiting customer query
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string email, name, mobile, msg = "", subject;
            email   = txtemail.Text.Trim();
            mobile  = txtMobile.Text.Trim();
            name    = txtName.Text.Trim();
            subject = ddlSubject.SelectedItem.Text;

            msg += txtUrcomments.Text.Trim();

            if (Checks.Empty(name) || Checks.Empty(email) || Checks.Empty(mobile))
            {
                lblMsg.Text = "Please fill all the fields";
                txtName.Focus();
            }
            else if (Checks.Empty(name))
            {
                lblMsg.Text = "Please enter your name";
            }
            else if (Checks.Empty(email))
            {
                lblMsg.Text = "Please enter your email address";
            }
            else if (Checks.Empty(mobile))
            {
                lblMsg.Text = "Please enter your mobile number";
            }
            else if (!Checks.checkNumber(mobile))
            {
                lblMsg.Text = "Please enter numbers only";
            }
            else if (subject.Contains("-1"))
            {
                lblMsg.Text = "Please select an item from the list";
            }
            else
            {
                EnquiryInfo data = new EnquiryInfo();
                data.Email   = email;
                data.Mobile  = long.Parse(mobile);
                data.Message = msg;
                data.Name    = name;
                data.Subject = subject;
                BakersLoungeEntities real = new BakersLoungeEntities();
                real.EnquiryInfoes.Add(data);
                real.SaveChanges();
                txtUrcomments.Text       = "";
                txtemail.Text            = "";
                txtMobile.Text           = "";
                txtName.Text             = "";
                ddlSubject.SelectedIndex = int.Parse("-1");
                BindDdlSubjectCategory();
                lblMsg.Text = "Your response has been received!";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }