예제 #1
0
        protected void Save_Click(object sender, EventArgs e)
        {
            string     Id    = Selection.Text;
            string     brand = Brand.Text;
            string     name  = Name.Text;
            string     type  = Type.SelectedValue;
            SqlDecimal price = SqlDecimal.Parse(Price.Text);
            string     desc  = Desc.Text;

            string file = Path.GetFileName(Image.FileName);
            string img  = "Images/" + file;

            if (img == ImageText.Text || file == "")
            {
                img = ImageText.Text;
            }
            else
            {
                Image.SaveAs(Server.MapPath("~/Images/") + file);
            }

            Choco choco = new Choco(brand, name, type, price, desc, img);

            DatabasePull.EditChoco(choco, Id);
            FillPage();
            ClearTextView();
            update.Text = "Updated Sucessfully";
        }
예제 #2
0
        public static ArrayList GetDetails(string type)
        {
            ArrayList Details = new ArrayList();
            string    sql     = string.Format("SELECT * FROM Inventory1 WHERE Type LIKE '{0}%'", type);
            string    fail    = string.Format("SELECT * FROM Inventory1");

            try
            {
                con.Open();
                text.CommandText = sql;
                SqlDataReader pull = text.ExecuteReader();

                while (pull.Read())
                {
                    int        Id    = pull.GetInt32(0);
                    string     brand = pull.GetString(1);
                    string     name  = pull.GetString(2);
                    SqlDecimal price = pull.GetSqlDecimal(4);
                    string     desc  = pull.GetString(5);
                    string     img   = pull.GetString(6);

                    Choco choco = new Choco(Id, brand, name, price, desc, img);
                    Details.Add(choco);
                }
            }



            finally
            {
                con.Close();
            }
            return(Details);
        }
예제 #3
0
        protected void Save_Click(object sender, EventArgs e)
        {
            try
            {
                string file = Path.GetFileName(Upload.FileName);
                Upload.SaveAs(Server.MapPath("~/Images/") + file);


                string     brand = Brand.Text;
                string     name  = Name.Text;
                string     type  = Type.SelectedValue;
                SqlDecimal price = SqlDecimal.Parse(Price.Text);
                string     desc  = Desc.Text;
                string     image = "Images/" + file;

                Choco choco = new Choco(brand, name, type, price, desc, image);

                DatabasePull.AddChoco(choco);
                FillPage();
                Result.Text = "Upload Success";
                ClearTextField();
            }


            catch (Exception)
            {
                Result.Text = "Upload Failed!";
            }
        }
예제 #4
0
        public static void AddChoco(Choco choco)
        {
            con.Open();
            string query = string.Format("INSERT INTO Inventory1 VALUES('{0}','{1}','{2}','{3}','{4}','{5}')", choco.brand, choco.name, choco.type, choco.price, choco.desc, choco.img);

            text.CommandText = query;
            try
            {
                text.ExecuteNonQuery();
            }
            finally
            {
                con.Close();
                text.Parameters.Clear();
            }
        }
예제 #5
0
        public static void EditChoco(Choco choco, string Id)
        {
            con.Open();
            string query = string.Format("UPDATE Inventory1 SET brand = '{0}',name = '{1}',type = '{2}',price = '{3}',description = '{4}',image = '{6}' WHERE Id LIKE '{5}'", choco.brand, choco.name, choco.type, choco.price, choco.desc, Id, choco.img);

            text.CommandText = query;
            try
            {
                text.ExecuteNonQuery();
            }
            finally
            {
                con.Close();
                text.Parameters.Clear();
            }
        }