root/trunk/BazaZamowien/Zamowienia/AdminFormZamowienie.cs @ 991

Wersja 710, 5.5 KB (wprowadzona przez dorota, 18 years temu)

baza zamowien i premii 1.0.0.1

Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Data.SqlClient;
6using System.Drawing;
7using System.Text;
8using System.Windows.Forms;
9using BazaZamowien.Classes;
10
11namespace BazaZamowien
12{
13    public partial class AdminFormZamowienie : Form
14    {
15        public AdminFormZamowienie()
16        {
17            InitializeComponent();
18
19            usersTableAdapter1.Connection.ConnectionString = ConnString.getConnString().ZamowieniaConnStr;
20            dzialyTableAdapter1.Connection.ConnectionString = ConnString.getConnString().ZamowieniaConnStr;
21            usersDzialyTableAdapter1.Connection.ConnectionString = ConnString.getConnString().ZamowieniaConnStr;
22           
23        }
24
25        private void adminForm_Load(object sender, EventArgs e)
26        {
27
28            dzialyListBox.DisplayMember = "Symbol";
29            dzialyListBox.ValueMember = "IDE";
30
31            usersListBox.SelectedValueChanged += new EventHandler(usersListBox_SelectedValueChanged);
32
33            usersListBox.DisplayMember = "Symbol";
34            usersListBox.ValueMember = "IDE";
35            usersListBox.DataSource = usersTableAdapter1.GetData();
36     
37            dzialyAllListBox.DataSource = dzialyTableAdapter1.GetDataByAll();
38            dzialyAllListBox.DisplayMember = "Symbol";
39            dzialyAllListBox.ValueMember = "IDE";
40        }
41
42        private void dodajUzytkownikaButton_Click(object sender, EventArgs e)
43        {
44            UserAddFormZamowienia uaf = new UserAddFormZamowienia(0);
45            if (uaf.ShowDialog() == DialogResult.OK)
46            {
47                usersListBox.DataSource = usersTableAdapter1.GetData();
48            }
49        }
50
51        private void edytujUzytkownikaButton_Click(object sender, EventArgs e)
52        {
53            if (usersListBox.SelectedValue != null)
54            {
55                UserAddFormZamowienia uaf = new UserAddFormZamowienia(Convert.ToInt32(usersListBox.SelectedValue));
56                if (uaf.ShowDialog() == DialogResult.OK)
57                {
58                    usersListBox.DataSource = usersTableAdapter1.GetData();
59                }
60            }
61        }
62
63        private void usunUzytkownikaButton_Click(object sender, EventArgs e)
64        {
65            if (usersListBox.SelectedValue != null)
66            {
67                if (MessageBox.Show("Czy na pewno chcesz usun¹c rekord?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
68                {
69                    usersTableAdapter1.Delete(Convert.ToInt32(usersListBox.SelectedValue));
70                    usersListBox.DataSource = usersTableAdapter1.GetData();
71                }
72            }
73        }
74
75        private void usersListBox_SelectedValueChanged(object sender, EventArgs e)
76        {
77            if (usersListBox.SelectedValue != null)
78            {
79                dzialyListBox.DataSource = dzialyTableAdapter1.GetDataByIDEUser((int)usersListBox.SelectedValue);
80            }
81        }
82
83        private void dodajDzialUztkownikaButton_Click(object sender, EventArgs e)
84        {
85            if ((usersListBox.SelectedValue != null) & (dzialyAllListBox.SelectedValue != null))
86            {
87                try
88                {
89                    usersDzialyTableAdapter1.Insert(Convert.ToInt32(usersListBox.SelectedValue), Convert.ToInt32(dzialyAllListBox.SelectedValue));
90                    dzialyListBox.DataSource = dzialyTableAdapter1.GetDataByIDEUser((int)usersListBox.SelectedValue);
91                } catch (SqlException e1){
92                    if (e1.Number == 2627)
93                    {
94                        MessageBox.Show("U¿ytkownikowi ju¿ przydzielono ten dzia³");
95                    }
96                }
97            }
98        }
99
100        private void usunDzailUzytkownikaButton_Click(object sender, EventArgs e)
101        {
102            if ((usersListBox.SelectedValue != null) & (dzialyListBox.SelectedValue != null))
103            {
104                usersDzialyTableAdapter1.Delete(Convert.ToInt32(usersListBox.SelectedValue), Convert.ToInt32(dzialyListBox.SelectedValue));
105                dzialyListBox.DataSource = dzialyTableAdapter1.GetDataByIDEUser((int)usersListBox.SelectedValue);
106            }
107        }
108
109        private void usunDzialButton_Click(object sender, EventArgs e)
110        {
111
112            if (dzialyAllListBox.SelectedValue != null)
113            {
114                if (MessageBox.Show("Czy na pewno chcesz usun¹c rekord?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
115                {
116                    dzialyTableAdapter1.Delete(Convert.ToInt32(dzialyAllListBox.SelectedValue));
117                    dzialyAllListBox.DataSource = dzialyTableAdapter1.GetDataByAll();
118                }
119            }
120
121        }
122
123        private void dodajDzialButton_Click(object sender, EventArgs e)
124        {
125            DzialAddForm daf = new DzialAddForm(0);
126            if (daf.ShowDialog() == DialogResult.OK)
127            {
128                dzialyAllListBox.DataSource = dzialyTableAdapter1.GetDataByAll();               
129            }
130        }
131
132        private void edytujDzialButton_Click(object sender, EventArgs e)
133        {
134            if (dzialyAllListBox.SelectedValue != null)
135            {
136                DzialAddForm daf = new DzialAddForm(Convert.ToInt32(dzialyAllListBox.SelectedValue));
137                if (daf.ShowDialog() == DialogResult.OK)
138                {
139                  dzialyAllListBox.DataSource = dzialyTableAdapter1.GetDataByAll();
140                }
141            }
142        }
143       
144    }
145}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.