private void btnCreate_Click(object sender, EventArgs e)
        {
            NewProductClass NewP = new NewProductClass();

            NewP.name  = ProName.Text;
            NewP.disc  = ProDis.Text;
            NewP.price = ProPrice.Value;
            ProductContainer con = new ProductContainer(NewP);
        }
Exemplo n.º 2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         StoragePro = new LinkedList <ProductContainer>();
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load("products.xml");
         XmlNodeList nodes = xmlDoc.DocumentElement.ChildNodes;
         foreach (XmlNode node in nodes)
         {
             ProductContainer pro = new ProductContainer();
             pro.name = node["Product_Name"].InnerText;
             pro.disc = node["Product_Disc"].InnerText;
             //pro.price = node["product_Price"].InnerXml;
             StoragePro.AddLast(pro);
         }
         foreach (ProductContainer p in StoragePro)
         {
             ProductContainer pro = new ProductContainer();
             pro.name  = p.name;
             pro.disc  = p.disc;
             pro.price = 200;
             flowLayoutPanel1.Controls.Add(pro);
         }
     }catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
     //LinkedList<object> Link = new LinkedList<object>();
     //NewProductClass P = new NewProductClass();
     //P.name = "Mobile";
     //File.AppendAllText("File.txt", P.name);
     //P.price = 2000;
     //File.AppendAllText("File.txt", P.price.ToString());
     //P.disc = "Eslam mamdouh mohamed";
     //File.AppendAllText("File.txt", P.disc);
     ////Link.AddLast(P);
     ////object[] data = Link.ToArray();
     //////string data = P.ToString();
     ////File.WriteAllText("File.txt", data.ToString());
     //test.Text = File.ReadAllText("File.txt");
 }
Exemplo n.º 3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("Product_Name", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("Product_Disc", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("product_Price", Type.GetType("System.Int32")));
                ds.Tables.Add(dt);
                ds.Tables[0].TableName = "products";

                int count = 0;
                while (count < AmountOfPro.Value)
                {
                    ProductContainer NPro = new ProductContainer();
                    NPro.name  = ProName.Text;
                    NPro.disc  = ProDis.Text;
                    NPro.price = ProPrice.Value;
                    StoragePro.AddLast(NPro);

                    count++;
                }

                foreach (var pro in StoragePro)
                {
                    DataRow dr;
                    dr = dt.NewRow();
                    dr["Product_Name"]  = pro.name;
                    dr["Product_Disc"]  = pro.disc;
                    dr["product_Price"] = pro.price;
                    dt.Rows.Add(dr);
                    ds.WriteXml("Products.xml");
                }

                MessageBox.Show("Product Created Successfully ");
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 4
0
 //ProductContainer Npro = new ProductContainer();
 public Form1(ProductContainer NPro)
 {
     InitializeComponent();
     // TODO: Complete member
     flowLayoutPanel1.Controls.Add(NPro);
 }