// when user clicks 'add to cart' button private void button1_Click(object sender, EventArgs e) { // if user chooses '-- Select Book --' option if (comboBox1.SelectedIndex == 0 || AuthorTextBox.Text == "") { MessageBox.Show("Please, choose a book from the list.", "Missing order details", MessageBoxButtons.OK, MessageBoxIcon.Warning); comboBox1.Focus(); } // if quantity box value starts with 0 or is empty else if (QuantityTextBox.Text == "" || QuantityTextBox.Text.StartsWith("0")) { MessageBox.Show("Please, enter the valid number of books.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); QuantityTextBox.Focus(); } // if user chooses '-- Select Customer --" option else if (CustomerComboBox.SelectedIndex == 0) { MessageBox.Show("Please, choose the customer", "Missing Order Details", MessageBoxButtons.OK, MessageBoxIcon.Error); CustomerComboBox.Focus(); } else { string BookID = IsbnTextBox.Text.ToString(); var index = this.DataList.Rows.Add(); // add new row and get index of this row var lineTotal = decimal.Parse(PriceTextBox.Text.TrimStart('$')) * decimal.Parse(QuantityTextBox.Text); this.DataList.Rows[index].Cells[0].Value = comboBox1.SelectedValue.ToString(); this.DataList.Rows[index].Cells[1].Value = decimal.Parse(PriceTextBox.Text.TrimStart('$')).ToString("C2"); this.DataList.Rows[index].Cells[2].Value = QuantityTextBox.Text; this.DataList.Rows[index].Cells[3].Value = lineTotal.ToString("C2"); orderDetailsList.Add(new OrderDetails(BookID, int.Parse(QuantityTextBox.Text), lineTotal)); this.Lines.Add(lineTotal); // store Line Total values in the list when book is added to the DataGridView CalculateTotalAmount(); // calculate total amount for user to pay } }
public void FillCustomerComboBox() { //Session["CustomerNames"]; DataTable dt = CustomerServiceBL.CustomerDetails.Ins.GetAllCustomerData(); CustomerComboBox.DataSource = dt; CustomerComboBox.TextField = "Name"; CustomerComboBox.ValueField = "ID"; CustomerComboBox.DataBind(); }
public OrderCheckoutDialog(Order order) { _order = order; _orderHandler = new OrderHandler(); _orderPaymentHandler = new OrderPaymentHandler(); InitializeComponent(); TotalTextBox.Text = _order.Amount.ToString(CultureInfo.InvariantCulture); CustomerComboBox.ItemsSource = new CustomerHandler().GetCustomers(); CustomerComboBox.GetBindingExpression(PersonComboBox.ItemsSourceProperty)?.UpdateTarget(); }
public void FillCustomerComboBox() { DataTable dt = CustomerServiceBL.CustomerDetails.Ins.GetAllCustomerData(); DevExpress.Web.ASPxEditors.ListEditItem item = new DevExpress.Web.ASPxEditors.ListEditItem("Select All", 0); CustomerComboBox.DataSource = dt; CustomerComboBox.TextField = "Name"; CustomerComboBox.ValueField = "ID"; CustomerComboBox.DataBind(); CustomerComboBox.Items.Insert(0, item); CustomerComboBox.SelectedIndex = 0; }