Esempio n. 1
0
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     if (IsValidData())
     {
         product = new Product(txtCode.Text,
             txtDescription.Text, Convert.ToDecimal(txtPrice.Text));
         this.Close();
     }
 }
Esempio n. 2
0
        static void Main()
        {
            // Comparison test
            Product p1 = new Product("JAVA", "Murach's Beginning Java 2", 49.50m);
            Product p2 = new Product("JAVA", "Murach's Beginning Java 2", 49.50m);
            if (p1 == p2)       // This evaluates to true. Without the overloaded
                Console.WriteLine("p1 equals p2");	// == operator, it would evaluate to false.

            Application.EnableVisualStyles();
            Application.Run(new frmProductMain());
        }
Esempio n. 3
0
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     if (IsValidData())
     {
         if (rbBook.Checked)
             product = new Book(txtCode.Text, txtDescription.Text,
                 txtAuthorOrVersion.Text, Convert.ToDecimal(txtPrice.Text));
         else
             product = new Software(txtCode.Text, txtDescription.Text,
                 txtAuthorOrVersion.Text, Convert.ToDecimal(txtPrice.Text));
         this.Close();
     }
 }
Esempio n. 4
0
        public static List<Product> GetProducts()
        {
            // create the list
            List<Product> products = new List<Product>();

            // create the XmlReaderSettings object
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;

            // create the XmlReader object
            XmlReader xmlIn = XmlReader.Create(Path, settings);

            // read past all nodes to the first Product node
            if (xmlIn.ReadToDescendant("Product"))
            {
                // create one Product object for each Product node
                do
                {
                    Product product = new Product();
                    xmlIn.ReadStartElement("Product");
                    product.Code =
                        xmlIn.ReadElementContentAsString();
                    product.Description =
                        xmlIn.ReadElementContentAsString();
                    product.Price =
                        xmlIn.ReadElementContentAsDecimal();
                    products.Add(product);
                }
                while (xmlIn.ReadToNextSibling("Product"));
            }

            // close the XmlReader object
            xmlIn.Close();

            return products;
        }
Esempio n. 5
0
 public void Remove(Product product)
 {
     products.Remove(product);
     Changed(this);
 }
Esempio n. 6
0
 public void Add(string code, string description, decimal price)
 {
     Product p = new Product(code, description, price);
     products.Add(p);
     Changed(this);
 }
Esempio n. 7
0
 public void Add(Product product)
 {
     products.Add(product);
     Changed(this);
 }
Esempio n. 8
0
 private static void ReadBase(XmlReader xmlIn, Product p)
 {
     p.Code =
         xmlIn.ReadElementContentAsString();
     p.Description =
         xmlIn.ReadElementContentAsString();
     p.Price =
         xmlIn.ReadElementContentAsDecimal();
 }
Esempio n. 9
0
 private static void WriteBase(Product product,
     XmlWriter xmlOut)
 {
     xmlOut.WriteElementString("Code",
         product.Code);
     xmlOut.WriteElementString("Description",
         product.Description);
     xmlOut.WriteElementString("Price",
         Convert.ToString(product.Price));
 }