Пример #1
0
        private void btDodajOsi_Click(object sender, RoutedEventArgs e)
        {
            Osiguranje osiguranje = new Osiguranje();

            osiguranje.ShowDialog();
            btOsiguranje_Click(sender, e);
        }
Пример #2
0
        private void btIzmeniOsi_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                izmeni = true;
                Osiguranje osiguranje = new Osiguranje();
                konekcija.Open();
                DataRowView dataRowView = (DataRowView)dgAdmin.SelectedItems[0];
                forma = dataRowView;
                string        select  = "select Type,Price from Insurance where Insurance_ID = " + dataRowView["ID"];
                SqlCommand    command = new SqlCommand(select, konekcija);
                SqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    osiguranje.txtType.Text = reader["Type"].ToString();
                    osiguranje.txtCost.Text = reader["Price"].ToString();
                }
                osiguranje.ShowDialog();
            }
            catch (ArgumentOutOfRangeException)
            {
                var msg = new CustomMaterialMessageBox
                {
                    Width                = 300,
                    Height               = 150,
                    TxtMessage           = { Text = "You didnt select a row.", Foreground = Brushes.BlueViolet },
                    TxtTitle             = { Text = "Insurance", Foreground = Brushes.White, Background = Brushes.BlueViolet },
                    BtnCopyMessage       = { Width = 0, Height = 0, Content = null },
                    BtnCancel            = { Width = 0, Height = 0, Content = null },
                    BtnOk                = { Background = Brushes.BlueViolet, },
                    TitleBackgroundPanel = { Background = Brushes.BlueViolet },
                    BorderBrush          = Brushes.BlueViolet
                };
                msg.Show();
            }
            finally
            {
                if (konekcija != null)
                {
                    konekcija.Close();
                }
                btOsiguranje_Click(sender, e);
                izmeni = false;
            }
        }