public void ToPort(CommBase port) { port.PortName = PortName; port.BaudRate = BaudRate; port.Parity = Parity; port.DataBits = DataBits; port.StopBits = StopBits; port.TxFlowCTS = TxFlowCTS; port.TxFlowDSR = TxFlowDSR; port.TxFlowX = TxFlowX; port.TxWhenRxXoff = TxWhenRxXoff; port.RxGateDSR = RxGateDSR; port.RxFlowX = RxFlowX; port.UseRTS = UseRTS; port.UseDTR = UseDTR; port.XonChar = XonChar; port.XoffChar = XoffChar; port.RxHighWater = RxHighWater; port.RxLowWater = RxLowWater; port.SendTimeoutMultiplier = SendTimeoutMultiplier; port.SendTimeoutConstant = SendTimeoutConstant; port.RxQueue = RxQueue; port.TxQueue = TxQueue; port.CheckAllSends = CheckAllSends; }
public void FromPort(CommBase port) { PortName = port.PortName; BaudRate = port.BaudRate; Parity = port.Parity; DataBits = port.DataBits; StopBits = port.StopBits; TxFlowCTS = port.TxFlowCTS; TxFlowDSR = port.TxFlowDSR; TxFlowX = port.TxFlowX; TxWhenRxXoff = port.TxWhenRxXoff; RxGateDSR = port.RxGateDSR; RxFlowX = port.RxFlowX; UseRTS = port.UseRTS; UseDTR = port.UseDTR; XonChar = port.XonChar; XoffChar = port.XoffChar; RxHighWater = port.RxHighWater; RxLowWater = port.RxLowWater; SendTimeoutMultiplier = port.SendTimeoutMultiplier; SendTimeoutConstant = port.SendTimeoutConstant; RxQueue = port.RxQueue; TxQueue = port.TxQueue; CheckAllSends = port.CheckAllSends; }
private void SettingsForm_Load(object sender, EventArgs e) { try { string[] serialPorts = SerialPort.GetPortNames(); foreach (string serialPort in serialPorts) { comboPorts.Items.Add(serialPort); cmbBoxScannerPort.Items.Add(serialPort); } if (CommBase.IsPortAvailable(_dllSettings.ComPort)) { comboPorts.SelectedItem = _dllSettings.ComPortName; } else if (comboPorts.Items.Count > 0) { comboPorts.SelectedIndex = 0; } // 打开设置窗口时扫码枪串口已经被打开了,故无需判断串口是否可用 cmbBoxScannerPort.SelectedItem = _mainSettings.ScannerPortName; comboHardware.SelectedIndex = _dllSettings.HardwareIndexInt; comboBaud.SelectedIndex = _dllSettings.BaudRateIndex; cmbBoxScannerBaud.SelectedIndex = _mainSettings.ScannerBaudRateIndex; chkBoxUseSerialScanner.Checked = _mainSettings.UseSerialScanner; cmbBoxScannerPort.Enabled = chkBoxUseSerialScanner.Checked; cmbBoxScannerBaud.Enabled = chkBoxUseSerialScanner.Checked; foreach (string item in DllSettings.ProtocolNames) { comboProtocol.Items.Add(item); } comboProtocol.SelectedIndex = _dllSettings.ProtocolIndexInt; comboInitialize.SelectedIndex = !_dllSettings.DoInitialization ? 1 : 0; foreach (string item in DllSettings.StandardNames) { comboStandard.Items.Add(item); } comboStandard.SelectedIndex = _dllSettings.StandardIndexInt; if (_dllSettings.AutoDetect) { checkBoxAutoDetect.Checked = true; } else { checkBoxAutoDetect.Checked = false; } txtTesterName.Text = _mainSettings.TesterName; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void RemoveButton_Click(object sender, EventArgs e) { CommBase.ExecuteNoReturn("DELETE FROM Product WHERE name = '" + item.name + "';"); SuspendLayout(); ParentForm.CleanUp(); ParentForm.ListItems(); ResumeLayout(); Close(); }
private void EditButton_Click(object sender, EventArgs e) { CommBase.ExecuteNoReturn("UPDATE Product SET name = '" + NameTxT.Text + "' , price = " + PriceTxT.Text + " , quantity = " + QuantityTxT.Text + " , type = '" + TypeTxT.Text + "' WHERE id = " + item.ID + ";"); SuspendLayout(); ParentForm.CleanUp(); ParentForm.ListItems(); ResumeLayout(); Close(); }
private int GetOrdersCount(bool CountDelieverd) { object[] arr; if (CountDelieverd) { arr = CommBase.ReadFromTable("SELECT * FROM Orders", CommBase.TableType.Orders) as object[]; } else { arr = CommBase.ReadFromTable("SELECT * FROM Orders WHERE delievered <> 2", CommBase.TableType.Orders) as object[]; } return(arr.Length); }
public TCPComm(IPAddress server) { if (server.GetAddressBytes().SequenceEqual(IPAddress.Any.GetAddressBytes())) { tcpBase = new TCPServer(portTCP); } else { tcpBase = new TCPClient(server, portTCP); } tcpBase.ReceivedPackage += (sender, args) => ReceivePackage((CommandPackage)args); }
public void ListOrder(bool CountDelieverd) { object[] arr; if (CountDelieverd) { arr = CommBase.ReadFromTable("SELECT * FROM Orders", CommBase.TableType.Orders) as object[]; } else { arr = CommBase.ReadFromTable("SELECT * FROM Orders WHERE delievered <> 2", CommBase.TableType.Orders) as object[]; } foreach (object o in arr) { OrderView x = new OrderView((ItemDisc)o, panel1); OrderList.Add(x); } }
private void button3_Click(object sender, EventArgs e) { if (!int.TryParse(Product_Quantity.Text, out int x) || x == 0) { MessageBox.Show("Please Enter a number that is bigger than zero ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (x > ActiveItem.Quantity) { MessageBox.Show("Quantity bigger than stock", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CommBase.ExecuteNoReturn("UPDATE Product SET quantity = quantity - " + x.ToString() + " WHERE name = '" + ActiveItem.name + "';"); ActiveItem.Quantity = ActiveItem.Quantity - x; Transmitter.PlaceOrders(User.ActiveUser, ActiveItem); SuspendLayout(); CleanUp(); ListItems(Receiver.ReadFromProduct("SELECT * FROM Product;")); ResumeLayout(); show_home(); }