public void AddStorage(DocumentStorage Storage) { StorageService.AddStorage(Storage); using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName)) { (clientChannel as IServiceDocumentStorage).InitializeStorage(Storage); } }
private void addButton_Click(object sender, EventArgs e) { da = new DataAccess(); string sql = "SELECT Quantity,ProductId,Price FROM Storages WHERE ProductName='" + StorageComboBox.SelectedItem.ToString() + "'"; SqlDataReader reader = da.GetData(sql); Storage i = new Storage(); while (reader.Read()) { i.ProductId = (int)reader["ProductId"]; i.Quantity = (int)reader["Quantity"]; i.Price = (int)reader["Price"]; } int cal = i.Quantity + Convert.ToInt32(amountTextBox.Text); int p = ((i.Price / i.Quantity) * Convert.ToInt32(amountTextBox.Text)) + i.Price; s = new StorageService(); int result = s.AddStorage(i.ProductId, cal, p); dataGridView1.DataSource = s.GetStorageData(); MessageBox.Show("Amount added!"); StorageComboBox.SelectedItem = null; amountTextBox.Clear(); }