Esempio n. 1
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            BillingOperation b      = new BillingOperation(Convert.ToDouble(priceTextBox.Text), Convert.ToInt32(quantityTextBox.Text), menuComboBox.Text);
            BillingService   bs     = new BillingService();
            String           query  = "select ORDERID,CATEGORYNAME, QUANTITY, PRICE from Orders where CATEGORYNAME = '" + menuComboBox.Text + "'";
            SqlDataReader    reader = DataAccess.GetData(query);

            if (reader.HasRows)
            {
                reader.Read();
                if (reader.GetString(1).Equals(menuComboBox.Text))
                {
                    MessageBox.Show(reader.GetString(0));
                    b.Quantity   = b.Quantity + reader.GetInt32(2);
                    b.OrderPrice = Convert.ToDouble(priceTextBox.Text) * b.Quantity;
                    bs.Edit(b, reader.GetString(0));
                }
            }

            else
            {
                //MessageBox.Show(reader.GetString(0));
                bs.AddOrder(b);
            }

            LoadData();
        }
Esempio n. 2
0
        public ActionResult Edit(BillingItemViewModel item)
        {
            //定位在當初輸入資料的那個值
            ViewBag.BillTypes = new SelectList(GlobalCodeMappings.BillTypes, "Key", "Value", item.BillType);

            #region Model 檢查

            if (!ModelState.IsValid)
            {
                return(View(item));
            }

            #endregion

            #region 呼叫服務層

            try
            {
                _billingSvc.Edit(item);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View(item));
            }

            #endregion
        }