//Load all the order details placed - with Order ID private void OrderDetails_Load(object sender, EventArgs e) { SqlConnection connection = null; DataTable table = new DataTable(); try { DaoLayer.CustomerDBLayer dbLayer = new DaoLayer.CustomerDBLayer(); connection = dbLayer.GetConnection(); string sql = "SELECT * FROM CUSTOMER_ORDER WHERE Order_ID = @orderID"; SqlDataReader reader = dbLayer.GetUserDetails(sql, orderID); // SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); table.Load(reader); reader.Close(); // Append details to summary grid SummaryGridView.DataSource = table; SummaryGridView.ReadOnly = true; } catch (Exception exception) { MessageBox.Show(exception.Message); } finally { //close connection connection.Close(); } }
private void MyOrders_Load(object sender, EventArgs e) { Entities.UserDetails orderDetails = new Entities.UserDetails(); SqlConnection connection = null; DataTable table = new DataTable(); try { DaoLayer.CustomerDBLayer dbLayer = new DaoLayer.CustomerDBLayer(); connection = dbLayer.GetConnection(); string name = UserDetailsForm.loginID_Myorders; string sql = "SELECT * FROM CUSTOMER_ORDER WHERE Login_ID = @loginId"; SqlDataReader reader = dbLayer.GetAllCustOrders(sql, name); // SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); table.Load(reader); reader.Close(); dataGridView1.DataSource = table; dataGridView1.ReadOnly = true; } catch (Exception exception) { MessageBox.Show(exception.Message); } finally { connection.Close(); } }
private void PlaceOrderButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(FirstNameTextBox.Text)) { errorProvider1.SetError(FirstNameTextBox, "First Name is required!"); return; } else if (string.IsNullOrEmpty(PhoneNumbertextBox.Text)) { errorProvider1.SetError(PhoneNumbertextBox, "Phone Number is required!"); return; } else if (string.IsNullOrEmpty(AddressTextBox.Text)) { errorProvider1.SetError(AddressTextBox, "Address is required!"); return; } if (FirstNameTextBox.Text.Length > 10) { errorProvider1.SetError(FirstNameTextBox, "Name cannot me more than 10 !"); return; } else if (PhoneNumbertextBox.Text.Length != 10) { errorProvider1.SetError(PhoneNumbertextBox, "PhoneNumber must be 10 digit !"); return; } else if (AddressTextBox.Text.Length > 50) { errorProvider1.SetError(AddressTextBox, "AddressNumber cannot me more than 10 !"); return; } else if (TotalAmount.Text == "0") { errorProvider1.SetError(TotalAmount, "Total Amount cannot be zero !"); return; } // validate phone Number string num = PhoneNumbertextBox.Text; string firstName = FirstNameTextBox.Text; string address = AddressTextBox.Text; List <int> list = new List <int>(); try { Service.CustomerService service = new Service.CustomerService(); DaoLayer.CustomerDBLayer dbLayer = new DaoLayer.CustomerDBLayer(); orderDetails.Address = AddressTextBox.Text; orderDetails.FullName = FirstNameTextBox.Text; orderDetails.LoginID = userName; orderDetails.PhoneNumber = Int32.Parse(PhoneNumbertextBox.Text); service.IsCustomerInputValid(num, firstName, address); list = dbLayer.InsertOrderDetails(orderDetails); if (list[1] != 0) { OrderDetailsForm orderDetail = new OrderDetailsForm(); orderDetail.OrderID = list[0]; orderDetails.OrderID = list[0]; orderDetail.MdiParent = this.MdiParent; //TODO: need to pull data from inserted data from table orderDetail.Show(); } double totalVal = System.Convert.ToDouble(TotalAmount.Text); int onionCount = Convert.ToInt32(OnionComboBoxQuantity.Text); int tomatoCount = Convert.ToInt32(TomatoComboBoxQuantity.Text); int letuceCount = Convert.ToInt32(LettuceQtyComboBox.Text); int chickenCount = Convert.ToInt32(chickenComboBoxQuantity.Text); string shipping = "standard"; if (twentyFourHrRadio.Checked) { shipping = "24"; } if (twelveHrRadio.Checked) { shipping = "12"; } if (OneHourRadio.Checked) { shipping = "1"; } } catch (Exception exception) { ErrorMessageLabel.Text = exception.Message; return; } }