private void Order_delete_btn_Click(object sender, EventArgs e) { if (label1.Text == "") { MessageBox.Show("尚未選取要刪除的項目"); } else { Order ord = new Order() { OrderID = Convert.ToInt32(label1.Text), Orderdate = Convert.ToDateTime(label2.Text), OrderProductName = label3.Text, OrderTotalPrice = Convert.ToInt32(label4.Text) }; OrderUtility.DeleteOrder(ord); MessageBox.Show("刪除成功"); int ordtotalprice = 0; List <Order> ordList = OrderUtility.GetOrderPriceByOrderID(Convert.ToInt32(OrderID_lab.Text)); foreach (Order item in ordList) { ordtotalprice += item.OrderTotalPrice; } dataGridView2.DataSource = OrderUtility.GetAllOrder(Convert.ToInt32(OrderID_lab.Text)); dataGridView2.Refresh(); TotalPrice_txt.Text = ordtotalprice.ToString(); } }
private void ProductConfirm_btn_Click(object sender, EventArgs e) { //int datecheck = OrderUtility.getDate(); //if (datecheck != null) //{ //} if (ProductName_lab.Text == "無" || ProductName_lab.Text == "無" || ProductCount_lab.Text == "" || ProductCount_lab.Text == 0.ToString()) { MessageBox.Show("輸入錯誤"); } else { Order ord = new Order() { OrderID = Convert.ToInt32(OrderID_lab.Text), Ordershortdate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), Orderdate = Convert.ToDateTime(DateTime.Now.ToString("yyyy - MM - dd")), OrderProductName = ProductName_lab.Text, //Orderdate = Convert.ToDateTime(DateTime.Now), OrderPrice = Convert.ToInt32(ProductPrice_lab.Text), OrderCount = Convert.ToInt32(ProductCount_lab.Text), OrderTotalPrice = Convert.ToInt32(ProductCount_lab.Text) * Convert.ToInt32(ProductPrice_lab.Text) }; OrderUtility.OrderAdd(ord); //Console.WriteLine(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"))); dataGridView2.DataSource = OrderUtility.GetAllOrder(Convert.ToInt32(OrderID_lab.Text)); dataGridView2.Refresh(); //dataGridView2.Columns[1].Visible = false; //int op = Convert.ToInt32(ProductCount_lab.Text) * Convert.ToInt32(ProductPrice_lab.Text); //OrderTotalPriceAdd(ref op); //TotalPrice_txt.Text = OrderTotalPrice.ToString(); int ordtotalprice = 0; List <Order> ordList = OrderUtility.GetOrderPriceByOrderID(Convert.ToInt32(OrderID_lab.Text)); foreach (Order item in ordList) { ordtotalprice += item.OrderTotalPrice; } TotalPrice_txt.Text = ordtotalprice.ToString(); } ProductCount_lab.Text = ""; }