private void ListProducts() { infoControls.comType = commandType.read; infoControls.requestDataType = RequestDataType.products; DataTypeComStatus allowProtocol = dataExchange.DataExchangeProtocol(infoControls); if (allowProtocol == DataTypeComStatus.readableProducts) { Product product = new Product(); dataCollection = dataExchange.GetData <Product>(); if (dataCollection != null) { foreach (KeyValuePair <int, Product> KeyValuePairProduct in dataCollection) { productData = KeyValuePairProduct.Value; string[] row = { productData.ProductName.Value, productData.LabelName.Value, productData.Cable1Color.Value, productData.Cable2Color.Value, productData.Quantity.Value, productData.CableSection.Value, productData.CableDiameter.Value, productData.CableDirection.Value }; var lvi = new ListViewItem(row); listView_Products.Items.Add(lvi); } } } }
private void btn_AddProduct_Click(object sender, EventArgs e) { Parameters parameters; var allNud = Tools.GetAllChildControl(this, typeof(NumericUpDown)); PropertyInfo[] properties = typeof(Product).GetProperties(); foreach (NumericUpDown nud in allNud) { foreach (var prop in properties) { if (nud.Name.Contains(prop.Name)) { parameters = (Parameters)prop.GetValue(product); parameters.Value = nud.Value.ToString(); break; } } } infoControls.comType = commandType.write; infoControls.requestDataType = RequestDataType.products; DataTypeComStatus protocolAllow = dataExchange.DataExchangeProtocol(infoControls); if (protocolAllow == DataTypeComStatus.writeableProducts) { dataExchange.SendData <Product>(product); } }
private void btn_AddAccount_Click(object sender, EventArgs e) { infoControls.comType = commandType.write; infoControls.requestDataType = RequestDataType.users; DataTypeComStatus protocolAllow = dataExchange.DataExchangeProtocol(infoControls); if (protocolAllow == DataTypeComStatus.writeableAccounts) { account.UserName.Value = txt_userName.Text; account.Pin.Value = txt_Pin.Text; account.BarcodPin.Value = txt_BarcodPin.Text; account.Level.Value = cb_Level.Text; account.ProtectInfo.Value = cb_ProtecInfo.Text; dataExchange.SendData <Account>(account); MessageBox.Show("Kullanıcı başarlı bir şekilde eklendi."); } else { MessageBox.Show("Haberleşme protokolünde hata oluştu!"); } }