Example #1
0
        public void UpgradeRate(int id, int cRate, string Username)
        {
            db = new Db();
            course.Business_Layer.productBU productBU = new Business_Layer.productBU();
            Business_Layer.product          p         = productBU.GetProductbyID(id.ToString());

            double rate = Math.Round(p.rate, 2);

            if (p.votes != 0)
            {
                rate = Math.Round(p.rate * p.votes, 2);
            }
            if (ExistVote(id, Username))
            {
                double brate = double.Parse(productBU.Rate_cart(Username, id));
                rate -= brate; p.votes--;
            }
            p.votes++;
            double result = (Math.Round(rate, 2) + cRate) / p.votes;

            p.rate = Math.Round(result, 2);
            string sql = "update [product] set product_Rate='" + p.rate.ToString() + "', product_votes='" + p.votes.ToString() + "'  where Id='" + id.ToString() + "'";

            db.executecommand(sql);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            db            = new DataAccess.Db();
            SqlConnection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\course\course\App_Data\Library.mdf;Integrated Security=True");
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("items.aspx");
            }
            else
            {
                id = Convert.ToInt32(Request.QueryString["id"].ToString());

                string         sql = "select * from product where Id='" + id + "'";
                SqlCommand     cmd = db.executecommand(sql);
                DataTable      dt  = new DataTable();
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                da.Fill(dt);
                d1.DataSource = dt;
                d1.DataBind();
            }

            course.Business_Layer.productBU productBU = new Business_Layer.productBU();
            Business_Layer.product          p         = productBU.GetProductbyID(id.ToString());
            Rating.Text = p.rate.ToString();
        }
Example #3
0
        protected void b1_Click(object sender, EventArgs e)
        {
            a = course.Business_Layer.Randomizer.GetRandomPassword(15);
            b = "images/default.png";
            string pdf = "";

            if (f1.FileName != "")
            {
                f1.SaveAs(Request.PhysicalApplicationPath + "./images/" + a + f1.FileName.ToString());
                b = "images/" + a + f1.FileName.ToString();
            }
            if (f2.FileName != "")
            {
                f2.SaveAs(Request.PhysicalApplicationPath + "./user/pdfs/" + a + f1.FileName.ToString() + ".pdf");
                pdf = "pdfs/" + a + f1.FileName.ToString() + ".pdf";
            }

            string category = "Foreign literature";

            if (Radio2.Checked)
            {
                category = "native literature";
            }
            Business_Layer.product product = new Business_Layer.product(t1.Text, t4.Text, t3.Text, (t5.Text), b.ToString(), t2.Text, t6.Text, category, pdf.ToString(), 1, Session["admin"].ToString());
            if (product.error == "")
            {
                DataAccess.ProductDAO productDAO = new DataAccess.ProductDAO();
                productDAO.InsertProduct(product);
                Response.Redirect("add_product.aspx");
            }

            else
            {
                Error.Text = product.error;
            }
        }