private void requireOrderToolStripMenuItem_Click(object sender, EventArgs e) { Product temp = layoutViewProducts.GetRow(layoutViewProducts.FocusedRowHandle) as Product; if (proList.Contains(temp)) { MessageBox.Show("This product had been exited in your card!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } proList.Add(temp); proNew = new OrderDetailProduct { ID = temp.ID, Name = temp.Name, Image = temp.Image, Price = temp.Price, Type = temp.Type, Description = temp.Description, UnitPrice = temp.UnitPrice, Unit = 1 }; proListOrder.Add(proNew); //btnNewOrderDetail.PerformClick(); layoutViewOrderDetails.RefreshData(); layoutViewOrderDetails_View(); layoutViewOrderDetails.RefreshData(); }
private void btnOrder_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (layoutViewOrderDetails.DataRowCount <= 0) { MessageBox.Show("This order is empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_orderCurrent == null) { DefualtOrder(); } string message = _orderManager.InsertOrUpdate(_orderCurrent).GetErrorMessages(); if (message.Length > 0) { MessageBox.Show(message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (_orderCurrent.ID > 0) { message = _orderDetailManager.Delete(_orderCurrent.ID).GetErrorMessages(); if (message.Length > 0) { MessageBox.Show(message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } _orderCurrent.ID = _orderManager.Find(od => od.CusID == _orderCurrent.CusID && od.Deleted == false).Result.Last().ID; for (int i = 0; i < layoutViewOrderDetails.DataRowCount; i++) { OrderDetailProduct temp = layoutViewOrderDetails.GetRow(i) as OrderDetailProduct; for (int j = 1; j <= temp.Unit; j++) { OrderDetail newElement = new OrderDetail { ProID = temp.ID, OrderID = _orderCurrent.ID }; message = _orderDetailManager.Insert(newElement).GetErrorMessages(); if (message.Length > 0) { MessageBox.Show(message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } btnRefreshPro.PerformClick(); }
private void btnDeleteFromCard_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { OrderDetailProduct element = layoutViewOrderDetails.GetRow(layoutViewOrderDetails.FocusedRowHandle) as OrderDetailProduct; layoutViewOrderDetails.DeleteRow(layoutViewOrderDetails.FocusedRowHandle); for (int i = 0; i < proList.Count; i++) { if (proList[i].ID == element.ID) { proList.RemoveAt(i); break; } } for (int i = 0; i < proListOrder.Count; i++) { if (proList[i].ID == element.ID) { proListOrder.RemoveAt(i); break; } } }