コード例 #1
0
ファイル: ModProduct.cs プロジェクト: mrmontreal/works
 private void button3_Click(object sender, EventArgs e)
 {
     if (CheckProductBasic())
     {
         Product modProduct = null;
         string productName = textBoxProName.Text;
         string isbn = textBoxISBN.Text;
         string category = comboBoxCategory.Text;
         double price = double.Parse(textBoxPrice.Text);
         string publisher = comboBoxPublisher.Text;
         if (id.Substring(0, 1) == "B")
         {
             string productId = id;
             string yearPublished = textBoxYear.Text;
             string fn = textBoxFn.Text;
             string ln = textBoxLn.Text;
             modProduct = new Book(productId, productName, price, category, isbn, publisher, yearPublished, fn, ln);
             modProduct.UpdateInformation(newProduct, modProduct);
         }
         else if (id.Substring(0, 1) == "S")
         {
             string productId = id;
             string platform = comboBoxPlatform.Text;
             modProduct = new Software(productId, productName, price, category, isbn, publisher, platform);
             modProduct.UpdateInformation(newProduct, modProduct);
         }
         this.Close();
         CheckProductInformation.f.Show();
     }
 }
コード例 #2
0
ファイル: AddProduct.cs プロジェクト: mrmontreal/works
        private void button3_Click(object sender, EventArgs e)
        {
            if (CheckProductBasic())
            {
                 Product aProduct= null;
                string productName = textBoxProName.Text;
                string isbn = textBoxISBN.Text;
                string category = comboBoxCategory.Text;
                double price = double.Parse(textBoxPrice.Text);
                string publisher = comboBoxPublisher.Text;
                if ((radioButton1.Checked) && CheckBookInfo())
                {
                    string productId = "B"+textBoxProId.Text;
                    string yearPublished = textBoxYear.Text;
                    string fn = textBoxFn.Text;
                    string ln = textBoxLn.Text;
                    aProduct = new Book(productId,productName, price, category, isbn, publisher, yearPublished, fn, ln);
                    if (aProduct.CheckProduct(productId))
                    {
                        MessageBox.Show("This product id has already existed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        aProduct.SaveInformation(aProduct);
                        this.Close();
                        CheckProductInformation.f.Show();
                    }

                }
                else if ((radioButton2.Checked) && CheckSoftwareInfo())
                {
                    string productId = "S"+textBoxProId.Text;
                    string platform= comboBoxPlatform.Text;
                    aProduct = new Software(productId,productName, price, category, isbn, publisher,platform);
                    if (aProduct.CheckProduct(productId))
                    {
                        MessageBox.Show("This product id has already existed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        aProduct.SaveInformation(aProduct);
                        this.Close();
                        CheckProductInformation.f.Show();
                    }
                }

            }
        }
コード例 #3
0
ファイル: FormAddOrder.cs プロジェクト: mrmontreal/works
 private void FormAddOrder_Load(object sender, EventArgs e)
 {
     //create order id
     createId();
     //readonly
     itemReadOnly();
     //get client
     Client cl = new Client();
     List<Client> listOfClient = cl.ReadInformation();
     foreach (Client aClient in listOfClient)
     {
         comboBoxClient.Items.Add(aClient.ClientId + "-" + aClient.ClientName);
     }
     //get product
     List<Product> listOfProducts = null;
     Book aBook = new Book();
     listOfProducts = aBook.ReadInformation();
     foreach (Book oneBook in listOfProducts)
     {
         comboBoxProduct.Items.Add(oneBook.ProductId + "-" + oneBook.ProductName);
     }
     Software aSoftware = new Software();
     listOfProducts = aSoftware.ReadInformation();
     foreach (Software oneSoftware in listOfProducts)
     {
         comboBoxProduct.Items.Add(oneSoftware.ProductId + "-" + oneSoftware.ProductName);
     }
 }
コード例 #4
0
ファイル: FormUpdateOrder.cs プロジェクト: mrmontreal/works
        private void FormUpdateOrder_Load(object sender, EventArgs e)
        {
            //listViewNewOrder.Items.Clear();

            //load from text to listview
            if (orderIdSelected != "" && orderIdSelected != null)
            {
                //MessageBox.Show(OrderGUI.FormListOfOrder.orderIdSelected);
                labelOrderId.Text = orderIdSelected;
                Order od = new Order();
                List<Order> listOfOrder = new List<Order>();
                listOfOrder = od.ReadNewOrderDetail(orderIdSelected);
                if (listOfOrder != null)
                {
                    foreach (Order item in listOfOrder)
                    {
                        ListViewItem lvi = new ListViewItem(item.Client.ClientId);
                        lvi.SubItems.Add(item.Client.ClientName);
                        lvi.SubItems.Add(item.Product.ProductId);
                        lvi.SubItems.Add(item.Product.ProductName);
                        lvi.SubItems.Add(item.Product.UnitPrice.ToString());
                        totalPrice = totalPrice + item.Product.UnitPrice;
                        lvi.SubItems.Add(item.Qty.ToString());
                        totalQuantity = totalQuantity + item.Qty;
                        listViewNewOrder.Items.Add(lvi);
                    }
                }
                //show the total label
                labelTotalPrice.Text = totalPrice.ToString();
                labelTotalQty.Text = totalQuantity.ToString();
                //readonly
                itemReadOnly();
                //get client
                Client cl = new Client();
                List<Client> listOfClient = cl.ReadInformation();
                foreach (Client aClient in listOfClient)
                {
                    comboBoxClient.Items.Add(aClient.ClientId + "-" + aClient.ClientName);
                }
                //get product
                List<Product> listOfProducts = null;
                Book aBook = new Book();
                listOfProducts = aBook.ReadInformation();
                foreach (Book oneBook in listOfProducts)
                {
                    comboBoxProduct.Items.Add(oneBook.ProductId + "-" + oneBook.ProductName);
                }
                Software aSoftware = new Software();
                listOfProducts = aSoftware.ReadInformation();
                foreach (Software oneSoftware in listOfProducts)
                {
                    comboBoxProduct.Items.Add(oneSoftware.ProductId + "-" + oneSoftware.ProductName);
                }
            }
        }
コード例 #5
0
 private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
 {
     List<Product> listOfProducts = null;
     comboBoxName.Items.Clear();
     if (comboBoxType.Text == "Book")
     {
         Book aBook = new Book();
         listOfProducts = aBook.ReadInformation();
         foreach (Book oneBook in listOfProducts)
         {
             comboBoxName.Items.Add(oneBook.ProductName);
         }
     }
     else if (comboBoxType.Text == "Software")
     {
         Software aSoftware = new Software();
         listOfProducts = aSoftware.ReadInformation();
         foreach (Software oneSoftware in listOfProducts)
         {
             comboBoxName.Items.Add(oneSoftware.ProductName);
         }
     }
 }
コード例 #6
0
 //list all the softwares in file
 private void ListSoftwares()
 {
     Software aSoftware = new Software();
     List<Product> listOfSoftwares = aSoftware.ReadInformation();
     listViewInformation.Items.Clear();
     foreach (Software oneSoftware in listOfSoftwares)
     {
         ListViewItem listView = new ListViewItem(oneSoftware.ProductId);
         listView.SubItems.Add(oneSoftware.ProductName);
         listView.SubItems.Add(Convert.ToString(oneSoftware.UnitPrice));
         listView.SubItems.Add(oneSoftware.Category);
         listView.SubItems.Add(oneSoftware.Isbn);
         listView.SubItems.Add(oneSoftware.Publisher);
         listView.SubItems.Add(oneSoftware.Platform);
         listViewInformation.Items.Add(listView);
     }
 }