public TulleOrder(Tulle formOwner) { InitializeComponent(); owner = formOwner; currentLblPointY = 70; currentInputPointY = 66; currentAddBtnY = 100; itemOrderQty = 1; no.PopulateColors(cbColor0); no.PopulateOrderStatus(cbOrderStatus); cbOrderStatus.SelectedIndex = 0; }
public ReceiveTulleOrder(Tulle formOwner) { InitializeComponent(); owner = formOwner; SerialPort mySerialPort = new SerialPort("COM1"); mySerialPort.BaudRate = 9600; mySerialPort.Parity = Parity.None; mySerialPort.StopBits = StopBits.One; mySerialPort.DataBits = 8; mySerialPort.Handshake = Handshake.None; mySerialPort.RtsEnable = true; try { mySerialPort.Open(); } catch (Exception) { MessageBox.Show("Receiving window already open."); this.Close(); } }
/* Constructor with orderID **********************************/ public EditOrder(string orderID, Tulle formOwner) { InitializeComponent(); owner = formOwner; Order o = new Order(); o.PopulateOrderStatus(cbOrderStatus); string query = "SELECT * FROM TULLE_ORDERS WHERE orderID = @orderID LIMIT 1"; MySqlCommand cmd = new MySqlCommand(query, db.conn); cmd.Parameters.AddWithValue("@orderID", orderID); // Set location of color fields currentLblPointY = 72; currentInputPointY = 68; currentAddBtnY = 102; int item = 0; int originalItemCount = 1; if (db.ExecuteCommand(cmd)) { db.OpenConnection(); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) // Set Values { dtpOrderDate.Value = Convert.ToDateTime(dr["orderDate"]); dtpDeliveryDate.Value = Convert.ToDateTime(dr["deliveryDate"]); cbOrderStatus.SelectedIndex = cbOrderStatus.FindString(dr["orderStatus"].ToString()); tbOrderID.Text = dr["orderID"].ToString(); tbTotal.Text = dr["total"].ToString(); } db.CloseConnection(); // Get color data MySqlCommand colors = new MySqlCommand("SELECT * FROM ORDER_ITEMS WHERE orderID = @orderID", db.conn); colors.Parameters.AddWithValue("@orderID", orderID); if (db.ExecuteCommand(colors)) { db.OpenConnection(); MySqlDataReader c = colors.ExecuteReader(); while (c.Read()) { try { string cbColorInputName = "cbColor" + item; string tbQty = "tbQty" + item; if (item != 0) { CalculateNewCoordinates(ref currentLblPointY, ref currentInputPointY, ref currentAddBtnY); this.Controls.Remove(btnAddItem); // New "Color:" Label Label color = new Label() { Text = "Color:", Location = new Point(colorLblPointX, currentLblPointY) }; this.Controls.Add(color); // New Color ComboBox ComboBox colorList = new ComboBox() { Name = cbColorInputName, Location = new Point(colorPointX, currentInputPointY) }; o.PopulateColors(colorList); colorList.Width = 134; colorList.SelectedValue = colorList.FindString(c["color"].ToString()); this.Controls.Add(colorList); // New Quantity Label Label lblQty = new Label() { Text = "Quantity:", Location = new Point(qtyLblPointX, currentLblPointY) }; this.Controls.Add(lblQty); // New Quantity TextBox TextBox qty = new TextBox() { Name = tbQty, Location = new Point(qtyPointX, currentInputPointY), Text = c["itemQty"].ToString() }; qty.Width = 51; this.Controls.Add(qty); // Move "New Item" Button btnAddItem.Location = new Point(579, currentAddBtnY); this.Controls.Add(btnAddItem); } else { o.PopulateColors(cbColor0); cbColor0.SelectedIndex = cbColor0.FindString(c["color"].ToString()); tbQty0.Text = c["itemQty"].ToString(); } IncreaseItemCount(ref item); // Increment item count SetOriginalItemCount(ref originalItemCount, item); } catch (Exception e) { MessageBox.Show(e.ToString()); } } db.CloseConnection(); } } }