예제 #1
0
        public string registerSale(string idClient, string phonesQuantities, string total, string key)
        {
            EncryptionMethods em     = new EncryptionMethods();
            string            conn   = WebConfigurationManager.ConnectionStrings["KeggPhonesConnectionString"].ToString();
            ClientBusiness    cb     = new ClientBusiness(conn);
            SaleBusiness      sb     = new SaleBusiness(conn);
            PhoneSaleBusiness psb    = new PhoneSaleBusiness(conn);
            PhoneBusiness     pb     = new PhoneBusiness(conn);
            Client            client = cb.getClientById(Int32.Parse(em.decrypting(idClient, key)));
            Sale sale = new Sale(0, client, Int32.Parse(em.decrypting(total, key)), DateTime.Today.ToString());
            int  r    = sb.insertSale(sale);

            sale.IdSale = r;
            string phonesQ = em.decrypting(phonesQuantities, key);

            string[] phones = phonesQ.Split('#');
            for (int i = 0; i < phones.Length; i++)
            {
                string[]  data  = phones[i].Split(';');
                Phone     phone = pb.getPhoneById(Int32.Parse(data[0]));
                PhoneSale ps    = new PhoneSale(0, phone, sale, Int32.Parse(data[1]));
                psb.insertPhoneSale(ps);
            }
            string response = "1";

            return(em.encrypt(response, key));
        }
예제 #2
0
        public string getPhoneById(string idPhone, string key)
        {
            EncryptionMethods em   = new EncryptionMethods();
            string            conn = WebConfigurationManager.ConnectionStrings["KeggPhonesConnectionString"].ToString();
            int           t        = Int32.Parse(em.decrypting(idPhone, key));
            PhoneBusiness pb       = new PhoneBusiness(conn);
            BrandBusiness bb       = new BrandBusiness(conn);
            Phone         phone    = pb.getPhoneById(t);
            Brand         brand    = bb.getBrandById(phone.Brand.IdBrand);
            string        path     = phone.Image;
            string        response = phone.IdPhone + ";" + phone.Model + ";" + brand.Name + ";" + phone.OS + ";" + phone.NetworkMode + ";" + phone.InternalMemory + ";" + phone.ExternalMemory + ";" +
                                     phone.Pixels + ";" + phone.Flash + ";" + phone.Resolution + ";" + phone.Price + ";" + phone.Quantity + ";" + "http://25.45.62.52/CoreVises" + path.Substring(2, path.Length - 2);

            return(em.encrypt(response, key));
        }
예제 #3
0
        protected void btnAccept_Click(object sender, EventArgs e)
        {
            Phone phone = new Phone();
            Brand brand = new Brand();

            brand.IdBrand        = Int32.Parse(ddlBrand.SelectedValue);
            brand.Name           = ddlBrand.Text;
            phone.Brand          = brand;
            phone.Model          = txtModel.Text;
            phone.OS             = ddlOs.SelectedValue;
            phone.NetworkMode    = ddlNet.SelectedValue;
            phone.InternalMemory = txtInternalMemory.Text;
            phone.ExternalMemory = txtExternalMemory.Text;
            phone.Pixels         = Int32.Parse(txtPixels.Text);
            phone.Resolution     = txtResolution.Text;
            phone.Flash          = Int32.Parse(ddlFlash.SelectedValue);
            phone.Price          = Int32.Parse(txtPrice.Text);
            phone.Quantity       = Int32.Parse(txtQuantity.Text);
            phone.Image          = "../Images/Phones/" + fileImage.FileName;
            try
            {
                fileImage.SaveAs(Server.MapPath("~/Images/Phones/") + fileImage.FileName);
            }
            catch
            {
            }

            string        conn   = WebConfigurationManager.ConnectionStrings["KeggPhonesConnectionString"].ToString();
            PhoneBusiness phoneB = new PhoneBusiness(conn);
            int           exists = phoneB.insertPhone(phone);

            if (exists == -1)
            {
                Response.Cookies["message"].Value   = "Somenthing is wrong, sorry.";
                Response.Cookies["message"].Expires = DateTime.Now.AddSeconds(5);
                Response.Redirect("./InsertPhone.aspx");
            }
            else
            {
                Response.Cookies["message"].Value   = "The phone was correctly added.";
                Response.Cookies["message"].Expires = DateTime.Now.AddSeconds(5);
                Response.Redirect("./InsertPhone.aspx");
            }
        }
예제 #4
0
        public string getPhones(string key)
        {
            string            response          = "";
            string            conn              = WebConfigurationManager.ConnectionStrings["KeggPhonesConnectionString"].ToString();
            PhoneBusiness     pb                = new PhoneBusiness(conn);
            EncryptionMethods em                = new EncryptionMethods();
            DataSet           dsPhone           = pb.getPhones();
            DataRowCollection dataRowCollection = dsPhone.Tables["TPhone"].Rows;
            BrandBusiness     bb                = new BrandBusiness(conn);
            string            path              = "";

            foreach (DataRow currentRow in dataRowCollection)
            {
                Brand brand = bb.getBrandById(Int32.Parse(currentRow["idBrand"].ToString()));
                path      = currentRow["imagePhone"].ToString();
                response += currentRow["idPhone"].ToString() + ";" + currentRow["model"].ToString() + ";" + brand.Name + ";" + currentRow["OS"].ToString()
                            + ";" + currentRow["networkMode"].ToString() + ";" + currentRow["internalMemory"].ToString() + ";" + currentRow["externalMemory"].ToString() + ";" + currentRow["pixels"].ToString() + ";" +
                            currentRow["flash"].ToString() + ";" + currentRow["resolution"].ToString() + ";" + currentRow["price"].ToString() + ";" + currentRow["quantity"].ToString() + ";" + "http://25.45.62.52/CoreVises" + path.Substring(2, path.Length - 2) + "#";
            }

            return(em.encrypt(response, key));
        }