Пример #1
0
        private void InitializeGrid()
        {
            // configurating webservice endpoints programmicaly setting binding security mode to transport to support https connection
            var binding = new BasicHttpBinding();

            binding.Security.Mode = BasicHttpSecurityMode.Transport;
            var client = new WarehouseService.WarehouseWebServiceSoapClient(binding, new EndpointAddress("https://localhost:44334/WarehouseWebService.asmx"));

            try
            {
                // filling dataGridView with database information using webservice method
                towaryGrid.DataSource = JsonConvert.DeserializeObject(client.GetTowary());
                // Adding a link column, and giving it some styling

                DataGridViewLinkColumn links = new DataGridViewLinkColumn();
                links.UseColumnTextForLinkValue = true;
                links.HeaderText                 = "Zamów";
                links.DataPropertyName           = "Zamów";
                links.ActiveLinkColor            = Color.LightBlue;
                links.LinkColor                  = SystemColors.Highlight;
                links.TrackVisitedState          = false;
                links.DefaultCellStyle.NullValue = "Zamów";
                links.Name = "Zamów";


                //removing the styling for selection
                towaryGrid.DefaultCellStyle.SelectionBackColor = Color.White;
                towaryGrid.DefaultCellStyle.SelectionForeColor = Color.Black;


                towaryGrid.Columns.Add(links);
                //setting datagrid columns names
                towaryGrid.Columns[0].HeaderText = "ID";
                towaryGrid.Columns[1].HeaderText = "Nazwa";
                towaryGrid.Columns[2].HeaderText = "Data Gwarancji";
                towaryGrid.Columns[3].HeaderText = "Ilość";
                //setting datagridview button click action
                towaryGrid.CellClick += new DataGridViewCellEventHandler(towaryGrid_CellClick);
            } catch (Exception)
            {
                MessageBox.Show("Cannot connect to the webservice.");
            }
        }
Пример #2
0
 private void SendZamowienie()
 {
     if (ValidateForm())
     {
         // configurating webservice endpoints programmicaly setting binding security mode to transport to support https connection
         var binding = new BasicHttpBinding();
         binding.Security.Mode = BasicHttpSecurityMode.Transport;
         var client = new WarehouseService.WarehouseWebServiceSoapClient(binding, new EndpointAddress("https://localhost:44334/WarehouseWebService.asmx"));
         int ilosc  = 0;
         int.TryParse(IloscBox.Text, out ilosc);
         if (client.SendZamowienie(id, ilosc, ImieBox.Text, NazwiskoBox.Text, AdresBox.Text, DostawaBox.Text))
         {
             MessageBox.Show("Zamowienie zostało wysłane.");
             ClearFields();
             this.Hide();
             podgladForm.Show();
         }
         else
         {
             MessageBox.Show("Wystąpił błąd przy składaniu zamówienia, sprawdz, czy zamawiana ilość nie przekracza dostępnej.");
         }
     }
 }