Ejemplo n.º 1
0
        public void product_load(int idofcom = 0, int cat = 0)
        {
            con.Open();
            SqlCommand cmd;

            if (cat == 0 && idofcom != 0)
            {
                cmd = new SqlCommand("get_prod", con);
                SqlParameter paramID = new SqlParameter()
                {
                    ParameterName = "@id",
                    Value         = idofcom
                };
                cmd.Parameters.Add(paramID);
            }
            else if (cat != 0 && idofcom != 0)
            {
                cmd = new SqlCommand("get_prod;2 '" + idofcom + "' ,' " + cat + "'", con);
            }
            else if (cat == 0 && idofcom == 0)
            {
                cmd = new SqlCommand("get_prod;4", con);
            }

            else
            {
                cmd = new SqlCommand("get_prod;3 '" + cat + "'", con);
            }

            SqlDataReader red = cmd.ExecuteReader();

            while (red.Read())
            {
                dataproduct pro = new dataproduct();

                pro.pic   = (byte[])red["Product_Pic"];
                pro.price = Convert.ToDouble(red["Product_Price"]);
                pro.des   = (string)red["Descriptions"];
                pro.count = (int)red["num_of_product"];
                if (cat == 0)
                {
                    pro.cat = (int)red["Cat_ID"];
                }

                product[(string)red["Product_Name"]] = pro;
            }
            red.Close();
            con.Close();
        }
Ejemplo n.º 2
0
        public void product_load(int cat = 0)
        {
            Dictionary <string, dataproduct> companypro = new Dictionary <string, dataproduct>();
            string     name = accountName.InnerText;
            SqlCommand cmd  = new SqlCommand("select companyID from CompanyData where companyName ='" + name + "'", con);

            con.Open();
            int        id = (int)cmd.ExecuteScalar();
            SqlCommand cmd1;

            if (cat == 0)
            {
                cmd1 = new SqlCommand("get_prod '" + id + "'", con);
            }
            else
            {
                cmd1 = new SqlCommand("get_prod;2 '" + id + "' ,' " + cat + "'", con);
            }
            SqlDataReader red = cmd1.ExecuteReader();

            while (red.Read())
            {
                dataproduct pro = new dataproduct();
                pro.pic   = (byte[])red["Product_Pic"];
                pro.price = Convert.ToDouble(red["Product_Price"]);
                pro.des   = (string)red["Descriptions"];
                pro.count = (int)red["num_of_product"];
                if (cat == 0)
                {
                    pro.cat = (int)red["Cat_ID"];
                }
                companypro[(string)red["Product_Name"]] = pro;
            }

            con.Close();
            string add = "";

            foreach (var key in companypro.Keys)
            {
                if (cat == 1)
                {
                    add += @" <div class='d-inline-block bg-white bo-1' data-toggle='tooltip'  data-placement='top' title='price:" + companypro[key].price;
                }
                if (cat != 1 && companypro[key].cat == 1)
                {
                    add += @" <div class='d-inline-block bg-white bo-1 lapp' data-toggle='tooltip'  data-placement='top' title='price:" + companypro[key].price;
                }
                if (companypro[key].cat == 1 || cat == 1)
                {
                    add += @"'>
                        <img src='data:image/png;base64," + Convert.ToBase64String(companypro[key].pic) +
                           @"'  class='d-block lapt' /> <div class='d-block'>
                         <h6 class='d-inline-block align-top'>" + key + @"</h6>
                       </div> </div>";
                }
                else
                {
                    add += @" <div class='d-inline-block bg-white bo-1 'data-toggle='tooltip'  data-placement='top'  title='price:" + companypro[key].price + @"'>
                        <img src='data:image/png;base64," + Convert.ToBase64String(companypro[key].pic) +
                           @"'  class='d-block ' /> <div class='d-block'>
                         <h6 class='d-inline-block align-top'>" + key + @"</h6>
                       </div> </div>";
                }
            }
            adds.InnerHtml = add;
        }