| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.ComponentModel;
|
|---|
| 4 | using System.Data;
|
|---|
| 5 | using System.Data.SqlClient;
|
|---|
| 6 | using System.Drawing;
|
|---|
| 7 | using System.Text;
|
|---|
| 8 | using System.Windows.Forms;
|
|---|
| 9 | using System.Globalization;
|
|---|
| 10 |
|
|---|
| 11 | namespace Baza_Reklam
|
|---|
| 12 | {
|
|---|
| 13 | public partial class InfoForm : Form
|
|---|
| 14 | {
|
|---|
| 15 | private static InfoForm infoform;
|
|---|
| 16 |
|
|---|
| 17 | public static InfoForm getInfoForm(MDIBazaReklam parent)
|
|---|
| 18 | {
|
|---|
| 19 | if (infoform == null) {
|
|---|
| 20 | infoform = new InfoForm(parent);
|
|---|
| 21 | }
|
|---|
| 22 | return infoform;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | private int ostRok = DateTime.Today.Year;
|
|---|
| 26 | private int ostMs = DateTime.Today.Month;
|
|---|
| 27 |
|
|---|
| 28 | private InfoForm(MDIBazaReklam parent)
|
|---|
| 29 | {
|
|---|
| 30 | InitializeComponent();
|
|---|
| 31 |
|
|---|
| 32 | this.MdiParent = parent;
|
|---|
| 33 |
|
|---|
| 34 | //podmiana connstringa
|
|---|
| 35 | nAZWY_MODULOWTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 36 | aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 37 | gRZBIETYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 38 | koszty_BiuraTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 39 | bUDZET_BIURTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 40 | nRTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 41 | daty_publikacjiTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 42 | pLANY_PROWIZJITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 43 | kONTATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 44 | aGENCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 45 | lISTA_TYTULOWTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 46 | pROMOCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 47 | kursy_WalutTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 48 |
|
|---|
| 49 | ImageList imageList = new ImageList();
|
|---|
| 50 | imageList.Images.Add(Baza_Reklam.Properties.Resources.bullet_ball_glass_green);
|
|---|
| 51 | imageList.Images.Add(Baza_Reklam.Properties.Resources.bullet_ball_glass_red);
|
|---|
| 52 | datyPubTreeView.ImageList = imageList;
|
|---|
| 53 | datyPubTreeView.ImageIndex = 0;
|
|---|
| 54 | datyPubTreeView.SelectedImageIndex = 1;
|
|---|
| 55 |
|
|---|
| 56 | treeView3.ImageList = imageList;
|
|---|
| 57 | treeView3.ImageIndex = 0;
|
|---|
| 58 | treeView3.SelectedImageIndex = 1;
|
|---|
| 59 |
|
|---|
| 60 | treeView4.ImageList = imageList;
|
|---|
| 61 | treeView4.ImageIndex = 0;
|
|---|
| 62 | treeView4.SelectedImageIndex = 1;
|
|---|
| 63 |
|
|---|
| 64 | bindingNavigator3.Visible = true;
|
|---|
| 65 | bindingNavigator4.Visible = true;
|
|---|
| 66 | bindingNavigator6.Visible = true;
|
|---|
| 67 | bindingNavigator7.Visible = true;
|
|---|
| 68 | bindingNavigator8.Visible = true;
|
|---|
| 69 | bindingNavigator9.Visible = true;
|
|---|
| 70 | bindingNavigator10.Visible = true;
|
|---|
| 71 | bindingNavigator11.Visible = true;
|
|---|
| 72 |
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | private void InfoForm_Load(object sender, EventArgs e)
|
|---|
| 76 | {
|
|---|
| 77 | // this.aGENCJETableAdapter.FillByALL(this.sLOWNIKDataSet.AGENCJE);
|
|---|
| 78 |
|
|---|
| 79 | this.agencjeListBox.DataSource = this.aGENCJETableAdapter.GetDataByALL();
|
|---|
| 80 | this.agencjeListBox.DisplayMember = "Symbol";
|
|---|
| 81 | this.agencjeListBox.ValueMember = "Id_agencji";
|
|---|
| 82 |
|
|---|
| 83 | this.aGENCJETableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCJE, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 84 | this.aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 85 |
|
|---|
| 86 | this.nowyAgentComboBox.DataSource = this.aGENCITableAdapter.GetDataByIdAgencjiAktywni(Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 87 | this.nowyAgentComboBox.DisplayMember = "Symbol";
|
|---|
| 88 | this.nowyAgentComboBox.ValueMember = "Symbol";
|
|---|
| 89 |
|
|---|
| 90 | this.staryAgentComboBox.DataSource = this.aGENCITableAdapter.GetDataByNieaktywniIDAgencji(Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 91 | this.staryAgentComboBox.DisplayMember = "Symbol";
|
|---|
| 92 | this.staryAgentComboBox.ValueMember = "Symbol";
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 | this.iDBIURADataGridViewTextBoxColumn.DataSource = this.aGENCJETableAdapter.GetData();
|
|---|
| 96 | this.iDBIURADataGridViewTextBoxColumn.DisplayMember = "Symbol";
|
|---|
| 97 | this.iDBIURADataGridViewTextBoxColumn.ValueMember = "Id_agencji";
|
|---|
| 98 |
|
|---|
| 99 | this.WindowState = FormWindowState.Maximized;
|
|---|
| 100 |
|
|---|
| 101 | this.nAZWY_MODULOWTableAdapter.FillByAll(this.sLOWNIKDataSet.NAZWY_MODULOW);
|
|---|
| 102 |
|
|---|
| 103 | generateNodes();
|
|---|
| 104 | generujTytuly();
|
|---|
| 105 | uprawnienia();
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
|---|
| 109 | {
|
|---|
| 110 | if (e.Node != null)
|
|---|
| 111 | {
|
|---|
| 112 | this.nRBindingSource.Filter = "[tyt]='" + e.Node.Text + "'";
|
|---|
| 113 | }
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 117 | {
|
|---|
| 118 | switch (infoTabControl.SelectedTab.Name)
|
|---|
| 119 | {
|
|---|
| 120 | case "naWydanTab":
|
|---|
| 121 | this.sLOWNIKDataSet.NAZWY_MODULOW.Clear();
|
|---|
| 122 | this.nRTableAdapter.Fill(this.sLOWNIKDataSet.NR);
|
|---|
| 123 | // this.nrWydanDataGridView.Sort(dATAWDataGridViewTextBoxColumn, ListSortDirection.Descending);
|
|---|
| 124 | treeView1.SelectedNode = treeView1.Nodes["AMTNode"];
|
|---|
| 125 | pozycjaAktualnegoWydania("AMT");
|
|---|
| 126 | uzupelnijKalendarz();
|
|---|
| 127 | break;
|
|---|
| 128 | case "modulyTab":
|
|---|
| 129 | this.sLOWNIKDataSet.NR.Clear();
|
|---|
| 130 | this.nAZWY_MODULOWTableAdapter.FillByAll(this.sLOWNIKDataSet.NAZWY_MODULOW);
|
|---|
| 131 | break;
|
|---|
| 132 | case "oddzialyTab":
|
|---|
| 133 | this.sLOWNIKDataSet.NAZWY_MODULOW.Clear();
|
|---|
| 134 | this.sLOWNIKDataSet.NR.Clear();
|
|---|
| 135 | this.pLANY_PROWIZJITableAdapter.Fill(this.sLOWNIKDataSet.PLANY_PROWIZJI);
|
|---|
| 136 | if (aGENCJEBindingSource.Current != null) {
|
|---|
| 137 | DataRowView row = (DataRowView)aGENCJEBindingSource.Current;
|
|---|
| 138 | int idAgencji = Convert.ToInt32(row["Id_agencji"]);
|
|---|
| 139 | this.kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA,idAgencji);
|
|---|
| 140 | this.aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI,idAgencji);
|
|---|
| 141 | }
|
|---|
| 142 | break;
|
|---|
| 143 | case "kursyWalutTabPage":
|
|---|
| 144 | this.daty_publikacjiTableAdapter.Fill(this.sLOWNIKDataSet.Daty_publikacji);
|
|---|
| 145 |
|
|---|
| 146 | TreeNode node;
|
|---|
| 147 | foreach (DataRowView row in datypublikacjiBindingSource.List) {
|
|---|
| 148 | node = new TreeNode();
|
|---|
| 149 | node.Text = (Convert.ToDateTime(row["Data_Publikacji"])).ToShortDateString();
|
|---|
| 150 | node.Name = row["Numer_Tabeli"].ToString();
|
|---|
| 151 | datyPubTreeView.Nodes.Add(node);
|
|---|
| 152 | }
|
|---|
| 153 | uprawnienia();
|
|---|
| 154 | break;
|
|---|
| 155 | case "grzbietyTabPage":
|
|---|
| 156 | this.lISTA_TYTULOWTableAdapter.FillAll(this.sLOWNIKDataSet.LISTA_TYTULOW);
|
|---|
| 157 | this.pROMOCJETableAdapter.Fill(this.sLOWNIKDataSet.PROMOCJE);
|
|---|
| 158 | this.gRZBIETYTableAdapter.Fill(this.sLOWNIKDataSet.GRZBIETY);
|
|---|
| 159 | break;
|
|---|
| 160 | case "planyProwizyjneTabPage":
|
|---|
| 161 | this.pLANY_PROWIZJITableAdapter.Fill(this.sLOWNIKDataSet.PLANY_PROWIZJI);
|
|---|
| 162 | break;
|
|---|
| 163 | case "kosztyBiurTabPage":
|
|---|
| 164 | treeView3.SelectedNode = treeView3.Nodes[User.getUser().IdAgencji.ToString()];
|
|---|
| 165 | break;
|
|---|
| 166 | case "budzetTabPage":
|
|---|
| 167 | treeView4.SelectedNode = treeView4.Nodes[User.getUser().IdAgencji.ToString()];
|
|---|
| 168 | break;
|
|---|
| 169 | default:
|
|---|
| 170 | break;
|
|---|
| 171 | }
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | private void treeView2_AfterSelect(object sender, TreeViewEventArgs e)
|
|---|
| 175 | {
|
|---|
| 176 | if (e.Node != null)
|
|---|
| 177 | {
|
|---|
| 178 | switch (e.Node.Level)
|
|---|
| 179 | {
|
|---|
| 180 | case 0:
|
|---|
| 181 | switch (e.Node.Name)
|
|---|
| 182 | {
|
|---|
| 183 | case "wszystkieNode":
|
|---|
| 184 | this.nAZWYMODULOWBindingSource.Filter = "";
|
|---|
| 185 | break;
|
|---|
| 186 | case "TylkoAktywne":
|
|---|
| 187 | this.nAZWYMODULOWBindingSource.Filter = "St_aktywny=1";
|
|---|
| 188 | break;
|
|---|
| 189 | }
|
|---|
| 190 | break;
|
|---|
| 191 | case 1:
|
|---|
| 192 | switch (e.Node.Parent.Name)
|
|---|
| 193 | {
|
|---|
| 194 | case "wszystkieNode":
|
|---|
| 195 | this.nAZWYMODULOWBindingSource.Filter = "[tytul]='" + e.Node.Text + "'";
|
|---|
| 196 | break;
|
|---|
| 197 | case "TylkoAktywne":
|
|---|
| 198 | this.nAZWYMODULOWBindingSource.Filter = "St_aktywny=1 AND [tytul]='" + e.Node.Text + "'";
|
|---|
| 199 | break;
|
|---|
| 200 | }
|
|---|
| 201 | break;
|
|---|
| 202 | default:
|
|---|
| 203 | this.nAZWYMODULOWBindingSource.Filter = "";
|
|---|
| 204 | break;
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 | private void InfoForm_Shown(object sender, EventArgs e)
|
|---|
| 209 | {
|
|---|
| 210 | uzupelnijKalendarz();
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | private void nRBindingSource_ListChanged(object sender, ListChangedEventArgs e)
|
|---|
| 214 | {
|
|---|
| 215 | uzupelnijKalendarz();
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | private void naWydanTab_Enter(object sender, EventArgs e)
|
|---|
| 219 | {
|
|---|
| 220 | uzupelnijKalendarz();
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | private void nrWydanDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 224 | {
|
|---|
| 225 | MessageBox.Show("Wprowadz poprawne dane");
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | private void saveToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 229 | {
|
|---|
| 230 | Validate();
|
|---|
| 231 | nRBindingSource.EndEdit();
|
|---|
| 232 | nRTableAdapter.Update(sLOWNIKDataSet.NR);
|
|---|
| 233 | MessageBox.Show("Dane zapisane");
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | private void modulySaveToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 237 | {
|
|---|
| 238 | Validate();
|
|---|
| 239 | nAZWYMODULOWBindingSource.EndEdit();
|
|---|
| 240 | nAZWY_MODULOWTableAdapter.Update(sLOWNIKDataSet.NAZWY_MODULOW);
|
|---|
| 241 | MessageBox.Show("Dane zapisane");
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | private void modulyDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 245 | {
|
|---|
| 246 | MessageBox.Show("Wprowadz poprawne dane");
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 | private void zapiszAgencjeToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 251 | {
|
|---|
| 252 | Validate();
|
|---|
| 253 | aGENCJEBindingSource.EndEdit();
|
|---|
| 254 | aGENCJETableAdapter.Update(this.sLOWNIKDataSet.AGENCJE);
|
|---|
| 255 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | private void zapiszAgentToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 259 | {
|
|---|
| 260 | Validate();
|
|---|
| 261 | aGENCIBindingSource.EndEdit();
|
|---|
| 262 | aGENCITableAdapter.Update(this.sLOWNIKDataSet.AGENCI);
|
|---|
| 263 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | private void zapiszGrzbietyToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 267 | {
|
|---|
| 268 | Validate();
|
|---|
| 269 | gRZBIETYBindingSource.EndEdit();
|
|---|
| 270 | gRZBIETYTableAdapter.Update(this.sLOWNIKDataSet.GRZBIETY);
|
|---|
| 271 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | private void zapiszTytultoolStripButton_Click(object sender, EventArgs e)
|
|---|
| 275 | {
|
|---|
| 276 | Validate();
|
|---|
| 277 | lISTA_TYTULOWBindingSource.EndEdit();
|
|---|
| 278 | lISTA_TYTULOWTableAdapter.Update(this.sLOWNIKDataSet.LISTA_TYTULOW);
|
|---|
| 279 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | private void zapiszPromocjeToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 283 | {
|
|---|
| 284 | Validate();
|
|---|
| 285 | pROMOCJEBindingSource.EndEdit();
|
|---|
| 286 | pROMOCJETableAdapter.Update(this.sLOWNIKDataSet.PROMOCJE);
|
|---|
| 287 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | private void zapiszPlanProwToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 291 | {
|
|---|
| 292 | Validate();
|
|---|
| 293 | pLANYPROWIZJIBindingSource.EndEdit();
|
|---|
| 294 | pLANY_PROWIZJITableAdapter.Update(this.sLOWNIKDataSet.PLANY_PROWIZJI);
|
|---|
| 295 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | private void zapiszKosztyBiuraToolStripButton_Click_1(object sender, EventArgs e)
|
|---|
| 299 | {
|
|---|
| 300 | if (rokTextBox.Text == "")
|
|---|
| 301 | {
|
|---|
| 302 | MessageBox.Show("Podaj rok");
|
|---|
| 303 | return;
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | if (miesiacTextBox.Text == "")
|
|---|
| 307 | {
|
|---|
| 308 | MessageBox.Show("Podaj miesiac");
|
|---|
| 309 | return;
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | Validate();
|
|---|
| 313 |
|
|---|
| 314 | if (koszty_BiuraBindingSource.Current != null)
|
|---|
| 315 | {
|
|---|
| 316 | DataRowView row = (DataRowView)koszty_BiuraBindingSource.Current;
|
|---|
| 317 | row["id_Agencji"] = treeView3.SelectedNode.Name;
|
|---|
| 318 | }
|
|---|
| 319 | koszty_BiuraBindingSource.EndEdit();
|
|---|
| 320 | koszty_BiuraTableAdapter.Update(this.sLOWNIKDataSet.Koszty_Biura);
|
|---|
| 321 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 322 |
|
|---|
| 323 | podsumujKosztyBiura();
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | private void zapiszBudzetToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 327 | {
|
|---|
| 328 | budzetyDataGridView.EndEdit();
|
|---|
| 329 | Validate();
|
|---|
| 330 | bUDZETBIURBindingSource.EndEdit();
|
|---|
| 331 | bUDZET_BIURTableAdapter.Update(this.sLOWNIKDataSet.BUDZET_BIUR);
|
|---|
| 332 | MessageBox.Show("Zmiany zapisane.");
|
|---|
| 333 |
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | private void pROMOCJEDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 337 | {
|
|---|
| 338 | MessageBox.Show("Wprowadz poprawne dane.");
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | private void gRZBIETYDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 342 | {
|
|---|
| 343 | MessageBox.Show("Wprowadz poprawne dane.");
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | private void pLANY_PROWIZJIDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 347 | {
|
|---|
| 348 | MessageBox.Show("Wprowadz poprawne dane.");
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | private void treeView3_AfterSelect(object sender, TreeViewEventArgs e)
|
|---|
| 352 | {
|
|---|
| 353 | if (e.Node != null)
|
|---|
| 354 | {
|
|---|
| 355 | this.sLOWNIKDataSet.Koszty_Biura.Clear();
|
|---|
| 356 | this.koszty_BiuraTableAdapter.FillBy(this.sLOWNIKDataSet.Koszty_Biura, e.Node.Name);
|
|---|
| 357 | this.koszty_BiuraBindingSource.MoveLast();
|
|---|
| 358 |
|
|---|
| 359 | if (koszty_BiuraBindingSource.Current != null)
|
|---|
| 360 | {
|
|---|
| 361 | DataRowView row = (DataRowView)koszty_BiuraBindingSource.Current;
|
|---|
| 362 | this.ostRok = Convert.ToInt32(row["rok"]);
|
|---|
| 363 | this.ostMs = Convert.ToInt32(row["miesiac"]);
|
|---|
| 364 | }
|
|---|
| 365 | }
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | private void treeView4_AfterSelect(object sender, TreeViewEventArgs e)
|
|---|
| 369 | {
|
|---|
| 370 | if (e.Node != null)
|
|---|
| 371 | {
|
|---|
| 372 | this.sLOWNIKDataSet.BUDZET_BIUR.Clear();
|
|---|
| 373 | this.bUDZET_BIURTableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.BUDZET_BIUR, Convert.ToInt32(e.Node.Name));
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | private void budzetyDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 378 | {
|
|---|
| 379 | MessageBox.Show("Wprowadz poprawne dane");
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | private void modulyDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 383 | {
|
|---|
| 384 | ukrytyLabel.Select();
|
|---|
| 385 | // modulyDataGridView.EndEdit();
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | private void kursy_WalutDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 389 | {
|
|---|
| 390 | ukrytyLabel.Select();
|
|---|
| 391 | // kursy_WalutDataGridView.EndEdit();
|
|---|
| 392 | }
|
|---|
| 393 |
|
|---|
| 394 | private void nrWydanDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 395 | {
|
|---|
| 396 | ukrytyLabel.Select();
|
|---|
| 397 | //nrWydanDataGridView.EndEdit();
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | private void dataGridView1_Leave(object sender, EventArgs e)
|
|---|
| 401 | {
|
|---|
| 402 | ukrytyLabel.Select();
|
|---|
| 403 | //dataGridView1.EndEdit();
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | private void kONTADataGridView_Leave(object sender, EventArgs e)
|
|---|
| 407 | {
|
|---|
| 408 | ukrytyLabel.Select();
|
|---|
| 409 | //kONTADataGridView.EndEdit();
|
|---|
| 410 | }
|
|---|
| 411 |
|
|---|
| 412 | private void gRZBIETYDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 413 | {
|
|---|
| 414 | ukrytyLabel.Select();
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | private void pROMOCJEDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 418 | {
|
|---|
| 419 | ukrytyLabel.Select();
|
|---|
| 420 | //pROMOCJEDataGridView.EndEdit();
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | private void pLANY_PROWIZJIDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 424 | {
|
|---|
| 425 | ukrytyLabel.Select();
|
|---|
| 426 | //pLANY_PROWIZJIDataGridView.EndEdit();
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | private void budzetyDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 430 | {
|
|---|
| 431 | ukrytyLabel.Select();
|
|---|
| 432 | //budzetyDataGridView.EndEdit();
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | private void pLANY_PROWIZJIDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
|
|---|
| 436 | {
|
|---|
| 437 | ukrytyLabel.Select();
|
|---|
| 438 | if (pLANY_PROWIZJIDataGridView.Columns[e.ColumnIndex].Name != "dataGridViewTextBoxColumn15")
|
|---|
| 439 | {
|
|---|
| 440 | pLANY_PROWIZJIDataGridView.EndEdit();
|
|---|
| 441 | if (Convert.ToDecimal(pLANY_PROWIZJIDataGridView[e.ColumnIndex, e.RowIndex].Value) >= 1)
|
|---|
| 442 | {
|
|---|
| 443 | pLANY_PROWIZJIDataGridView[e.ColumnIndex, e.RowIndex].Value = Convert.ToDecimal(pLANY_PROWIZJIDataGridView[e.ColumnIndex, e.RowIndex].Value) / 100;
|
|---|
| 444 | }
|
|---|
| 445 | }
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | private void datyPubTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
|---|
| 449 | {
|
|---|
| 450 | this.kursy_WalutTableAdapter.ClearBeforeFill = true;
|
|---|
| 451 | if (datyPubTreeView.SelectedNode != null)
|
|---|
| 452 | {
|
|---|
| 453 | this.kursy_WalutTableAdapter.FillByNrTabeli(this.sLOWNIKDataSet.Kursy_Walut, datyPubTreeView.SelectedNode.Name);
|
|---|
| 454 | }
|
|---|
| 455 | kursy_WalutDataGridView.Refresh();
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | private int pozycjaAktualnegoWydania(string tytul)
|
|---|
| 459 | {
|
|---|
| 460 | int position = 0;
|
|---|
| 461 | return position;
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | // wpisuje dni tygodnia i nr tygodnia w roku
|
|---|
| 465 | private void uzupelnijKalendarz()
|
|---|
| 466 | {
|
|---|
| 467 | DateTime dzien;
|
|---|
| 468 | CultureInfo myCI = new CultureInfo("pl-PL");
|
|---|
| 469 | Calendar myCal = myCI.Calendar;
|
|---|
| 470 |
|
|---|
| 471 | foreach (DataGridViewRow r in nrWydanDataGridView.Rows)
|
|---|
| 472 | {
|
|---|
| 473 | dzien = Convert.ToDateTime(r.Cells["dATAWDataGridViewTextBoxColumn"].Value);
|
|---|
| 474 | r.Cells["dzienTygodniaColumn"].Value =
|
|---|
| 475 | CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)dzien.DayOfWeek];
|
|---|
| 476 | r.Cells["nrTygodniaColumn"].Value = myCal.GetWeekOfYear(dzien, CalendarWeekRule.FirstDay, DayOfWeek.Monday).ToString();
|
|---|
| 477 | }
|
|---|
| 478 | }
|
|---|
| 479 |
|
|---|
| 480 | private void generateNodes()
|
|---|
| 481 | {
|
|---|
| 482 | SqlCommand command = new SqlCommand();
|
|---|
| 483 |
|
|---|
| 484 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 485 |
|
|---|
| 486 | command.CommandText = "select ID_AGENCJI,Symbol from dbo.AGENCJE where aktywna = 1";
|
|---|
| 487 |
|
|---|
| 488 | command.Connection.Open();
|
|---|
| 489 |
|
|---|
| 490 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 491 |
|
|---|
| 492 | TreeNode node;
|
|---|
| 493 | TreeNode node1;
|
|---|
| 494 |
|
|---|
| 495 | while (reader.Read())
|
|---|
| 496 | {
|
|---|
| 497 | node = new TreeNode(reader.GetValue(1).ToString());
|
|---|
| 498 | node1 = new TreeNode(reader.GetValue(1).ToString());
|
|---|
| 499 | node.Name = reader.GetValue(0).ToString();
|
|---|
| 500 | node1.Name = reader.GetValue(0).ToString();
|
|---|
| 501 | treeView3.Nodes.Add(node);
|
|---|
| 502 | treeView4.Nodes.Add(node1);
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | command.Connection.Close();
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | private void uprawnienia()
|
|---|
| 509 | {
|
|---|
| 510 |
|
|---|
| 511 | if (!User.getUser().St_kierownik)
|
|---|
| 512 | {
|
|---|
| 513 | infoTabControl.TabPages.Remove(grzbietyTabPage);
|
|---|
| 514 | infoTabControl.TabPages.Remove(planyProwizyjneTabPage);
|
|---|
| 515 | infoTabControl.TabPages.Remove(kosztyBiurTabPage);
|
|---|
| 516 | infoTabControl.TabPages.Remove(budzetTabPage);
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | if (!(User.getUser().St_kierownik | User.getUser().St_handlowiec | User.getUser().St_subhandlowiec | User.getUser().St_sekretarka)){
|
|---|
| 520 | infoTabControl.TabPages.Remove(kursyWalutTabPage);
|
|---|
| 521 | infoTabControl.TabPages.Remove(naWydanTab);
|
|---|
| 522 | infoTabControl.TabPages.Remove(agencjeTabPage);
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 | dodajAgencjeButton.Enabled = User.getUser().St_kierownik;
|
|---|
| 528 | edytujAgencjeButton.Enabled = User.getUser().St_kierownik;
|
|---|
| 529 | dodajAgentaButton.Enabled = User.getUser().St_kierownik;
|
|---|
| 530 | edytujAgentaButton.Enabled = User.getUser().St_kierownik;
|
|---|
| 531 | dodajKontoButton.Enabled = User.getUser().St_kierownik;
|
|---|
| 532 | edytujKontoButton.Enabled = User.getUser().St_kierownik;
|
|---|
| 533 |
|
|---|
| 534 | nrWydanDataGridView.AllowUserToAddRows = User.getUser().St_kierownik;
|
|---|
| 535 | modulyDataGridView.AllowUserToAddRows = User.getUser().St_kierownik;
|
|---|
| 536 |
|
|---|
| 537 | bindingNavigatorAddNewItem2.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 538 | bindingNavigatorAddNewItem3.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 539 | bindingNavigatorAddNewItem5.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 540 | bindingNavigatorAddNewItem6.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 541 | bindingNavigatorAddNewItem7.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 542 | bindingNavigatorAddNewItem8.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 543 | bindingNavigatorAddNewItem9.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 544 | bindingNavigatorAddNewItem10.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 545 |
|
|---|
| 546 | zapiszGrzbietyToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 547 | zapiszNrWydToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 548 | zapiszTytultoolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 549 | zapiszPromocjeToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 550 | modulySaveToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 551 | zapiszPlanProwToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 552 | zapiszBudzetToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 553 | zapiszKosztyBiuraToolStripButton.Visible = User.getUser().St_kierownik | User.getUser().St_admin;
|
|---|
| 554 |
|
|---|
| 555 | bindingNavigatorDeleteItem2.Visible = User.getUser().St_admin;
|
|---|
| 556 | bindingNavigatorDeleteItem3.Visible = User.getUser().St_admin;
|
|---|
| 557 | bindingNavigatorDeleteItem5.Visible = User.getUser().St_admin;
|
|---|
| 558 | bindingNavigatorDeleteItem6.Visible = User.getUser().St_admin;
|
|---|
| 559 | bindingNavigatorDeleteItem7.Visible = User.getUser().St_admin;
|
|---|
| 560 | bindingNavigatorDeleteItem8.Visible = User.getUser().St_admin;
|
|---|
| 561 | bindingNavigatorDeleteItem9.Visible = User.getUser().St_admin;
|
|---|
| 562 | bindingNavigatorDeleteItem10.Visible = User.getUser().St_admin;
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 | private void koszty_BiuraBindingSource_AddingNew(object sender, AddingNewEventArgs e)
|
|---|
| 567 | {
|
|---|
| 568 | if (treeView3.SelectedNode != null)
|
|---|
| 569 | {
|
|---|
| 570 | DataView dataTableView = koszty_BiuraBindingSource.List as DataView;
|
|---|
| 571 |
|
|---|
| 572 | DataRowView rowView = dataTableView.AddNew();
|
|---|
| 573 |
|
|---|
| 574 | rowView["id_Agencji"] = treeView3.SelectedNode.Name;
|
|---|
| 575 | // rowView["rok"] = DateTime.Today.Year;
|
|---|
| 576 | // rowView["miesiac"] = DateTime.Today.Month;
|
|---|
| 577 |
|
|---|
| 578 | if (this.ostMs == 12)
|
|---|
| 579 | {
|
|---|
| 580 | rowView["rok"] = ++this.ostRok;
|
|---|
| 581 | rowView["miesiac"] = this.ostMs = 1;
|
|---|
| 582 | }
|
|---|
| 583 | else
|
|---|
| 584 | {
|
|---|
| 585 | rowView["rok"] = this.ostRok;
|
|---|
| 586 | rowView["miesiac"] = ++this.ostMs;
|
|---|
| 587 | }
|
|---|
| 588 | e.NewObject = rowView;
|
|---|
| 589 |
|
|---|
| 590 | koszty_BiuraBindingSource.MoveLast();
|
|---|
| 591 | }
|
|---|
| 592 | }
|
|---|
| 593 |
|
|---|
| 594 | private void bUDZETBIURBindingSource_AddingNew(object sender, AddingNewEventArgs e)
|
|---|
| 595 | {
|
|---|
| 596 | if (treeView4.SelectedNode != null)
|
|---|
| 597 | {
|
|---|
| 598 | DataView dataTableView = bUDZETBIURBindingSource.List as DataView;
|
|---|
| 599 |
|
|---|
| 600 | DataRowView rowView = dataTableView.AddNew();
|
|---|
| 601 |
|
|---|
| 602 | rowView["ID_BIURA"] = treeView4.SelectedNode.Name;
|
|---|
| 603 | rowView["rok"] = DateTime.Today.Year;
|
|---|
| 604 | rowView["ms"] = DateTime.Today.Month;
|
|---|
| 605 |
|
|---|
| 606 | e.NewObject = rowView;
|
|---|
| 607 |
|
|---|
| 608 | bUDZETBIURBindingSource.MoveLast();
|
|---|
| 609 | }
|
|---|
| 610 | }
|
|---|
| 611 |
|
|---|
| 612 | private void podsumujKosztyBiura(){
|
|---|
| 613 | if (koszty_BiuraBindingSource.Current != null)
|
|---|
| 614 | {
|
|---|
| 615 | decimal suma = 0;
|
|---|
| 616 | decimal ksiegowosc = 0 ;
|
|---|
| 617 | decimal roznica = 0 ;
|
|---|
| 618 |
|
|---|
| 619 | DataRowView r = (DataRowView)koszty_BiuraBindingSource.Current;
|
|---|
| 620 |
|
|---|
| 621 | suma += r["czynsz"] == DBNull.Value ? 0 : Convert.ToDecimal(r["czynsz"]);
|
|---|
| 622 | suma += r["energia"] == DBNull.Value ? 0 : Convert.ToDecimal(r["energia"]);
|
|---|
| 623 | suma += r["telefony"] == DBNull.Value ? 0 : Convert.ToDecimal(r["telefony"]);
|
|---|
| 624 | suma += r["internet"] == DBNull.Value ? 0 : Convert.ToDecimal(r["internet"]);
|
|---|
| 625 | suma += r["parkingi"] == DBNull.Value ? 0 : Convert.ToDecimal(r["parkingi"]);
|
|---|
| 626 | suma += r["paliwo"] == DBNull.Value ? 0 : Convert.ToDecimal(r["paliwo"]);
|
|---|
| 627 | suma += r["place"] == DBNull.Value ? 0 : Convert.ToDecimal(r["place"]);
|
|---|
| 628 | suma += r["inne"] == DBNull.Value ? 0 : Convert.ToDecimal(r["inne"]);
|
|---|
| 629 |
|
|---|
| 630 | ksiegowosc = r["ksiegowosc"] == DBNull.Value ? 0 : Convert.ToDecimal(r["ksiegowosc"]);
|
|---|
| 631 |
|
|---|
| 632 | roznica = ksiegowosc - suma;
|
|---|
| 633 |
|
|---|
| 634 | razemLabel.Text = String.Format("{0:C}", suma);
|
|---|
| 635 | roznicaLabel.Text = String.Format("{0:C}", roznica);
|
|---|
| 636 | }
|
|---|
| 637 | }
|
|---|
| 638 |
|
|---|
| 639 | private void koszty_BiuraBindingSource_CurrentChanged(object sender, EventArgs e)
|
|---|
| 640 | {
|
|---|
| 641 | podsumujKosztyBiura();
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 |
|
|---|
| 645 | private void agencjeListBox_SelectedValueChanged(object sender, EventArgs e)
|
|---|
| 646 | {
|
|---|
| 647 | if (agencjeListBox.SelectedValue != null)
|
|---|
| 648 | {
|
|---|
| 649 | int idAgencji = Convert.ToInt32(agencjeListBox.SelectedValue);
|
|---|
| 650 | this.aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI, idAgencji);
|
|---|
| 651 | this.kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA, idAgencji);
|
|---|
| 652 | this.aGENCJETableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCJE, idAgencji);
|
|---|
| 653 | this.nowyAgentComboBox.DataSource = this.aGENCITableAdapter.GetDataByIdAgencjiAktywni(idAgencji);
|
|---|
| 654 | this.staryAgentComboBox.DataSource = this.aGENCITableAdapter.GetDataByNieaktywniIDAgencji(idAgencji);
|
|---|
| 655 |
|
|---|
| 656 | groupBox1.Enabled = User.getUser().St_kierownik & (idAgencji == User.getUser().IdAgencji);
|
|---|
| 657 | }
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | private void button3_Click(object sender, EventArgs e)
|
|---|
| 661 | {
|
|---|
| 662 | if ((this.aGENCIBindingSource.Filter==null) || (this.aGENCIBindingSource.Filter == ""))
|
|---|
| 663 | {
|
|---|
| 664 | this.aGENCIBindingSource.Filter = "aktywny=1";
|
|---|
| 665 | }
|
|---|
| 666 | else
|
|---|
| 667 | {
|
|---|
| 668 | this.aGENCIBindingSource.Filter = "";
|
|---|
| 669 | }
|
|---|
| 670 | }
|
|---|
| 671 |
|
|---|
| 672 | private void dodajAgencjeButton_Click(object sender, EventArgs e)
|
|---|
| 673 | {
|
|---|
| 674 | AgencjaAddForm aaf = new AgencjaAddForm(0);
|
|---|
| 675 |
|
|---|
| 676 | if (aaf.ShowDialog() == DialogResult.OK)
|
|---|
| 677 | {
|
|---|
| 678 | agencjeListBox.DataSource = aGENCJETableAdapter.GetDataByALL();
|
|---|
| 679 | }
|
|---|
| 680 | }
|
|---|
| 681 |
|
|---|
| 682 | private void edytujAgencjeButton_Click(object sender, EventArgs e)
|
|---|
| 683 | {
|
|---|
| 684 | if (agencjeListBox.SelectedValue != null)
|
|---|
| 685 | {
|
|---|
| 686 | AgencjaAddForm aaf = new AgencjaAddForm((int)agencjeListBox.SelectedValue);
|
|---|
| 687 | if (aaf.ShowDialog() == DialogResult.OK)
|
|---|
| 688 | {
|
|---|
| 689 | agencjeListBox.DataSource = aGENCJETableAdapter.GetDataByALL();
|
|---|
| 690 | }
|
|---|
| 691 | }
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | private void dodajAgentaButton_Click(object sender, EventArgs e)
|
|---|
| 695 | {
|
|---|
| 696 | AgentAddForm aaf = new AgentAddForm(0, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 697 |
|
|---|
| 698 | if (aaf.ShowDialog() == DialogResult.OK)
|
|---|
| 699 | {
|
|---|
| 700 | aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 701 | //agencjeListBox.DataSource = aGENCJETableAdapter.GetDataByALL();
|
|---|
| 702 | }
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 | private void edytujAgentaButton_Click(object sender, EventArgs e)
|
|---|
| 706 | {
|
|---|
| 707 | if (aGENCIBindingSource.Current != null)
|
|---|
| 708 | {
|
|---|
| 709 | DataRowView row = (DataRowView)aGENCIBindingSource.Current;
|
|---|
| 710 |
|
|---|
| 711 | int id = Convert.ToInt32(row["ID_AGENTA"]);
|
|---|
| 712 | AgentAddForm aaf = new AgentAddForm(id, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 713 | if (aaf.ShowDialog() == DialogResult.OK)
|
|---|
| 714 | {
|
|---|
| 715 | aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 716 | }
|
|---|
| 717 | }
|
|---|
| 718 | }
|
|---|
| 719 |
|
|---|
| 720 | private void dodajKontoButton_Click(object sender, EventArgs e)
|
|---|
| 721 | {
|
|---|
| 722 | AddKontoForm aaf = new AddKontoForm(0, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 723 |
|
|---|
| 724 | if (aaf.ShowDialog() == DialogResult.OK)
|
|---|
| 725 | {
|
|---|
| 726 |
|
|---|
| 727 | kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 728 | //agencjeListBox.DataSource = aGENCJETableAdapter.GetDataByALL();
|
|---|
| 729 | }
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | private void edytujKontoButton_Click(object sender, EventArgs e)
|
|---|
| 733 | {
|
|---|
| 734 | if (kONTABindingSource.Current != null)
|
|---|
| 735 | {
|
|---|
| 736 | DataRowView row = (DataRowView)kONTABindingSource.Current;
|
|---|
| 737 |
|
|---|
| 738 | int id = Convert.ToInt32(row["ID"]);
|
|---|
| 739 | AddKontoForm aaf = new AddKontoForm(id, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 740 | if (aaf.ShowDialog() == DialogResult.OK)
|
|---|
| 741 | {
|
|---|
| 742 | kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA, Convert.ToInt32(agencjeListBox.SelectedValue));
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 | }
|
|---|
| 746 |
|
|---|
| 747 | private void przepiszButton_Click(object sender, EventArgs e)
|
|---|
| 748 | {
|
|---|
| 749 | if ((staryAgentComboBox.SelectedValue == null) || (nowyAgentComboBox.SelectedValue == null))
|
|---|
| 750 | {
|
|---|
| 751 | MessageBox.Show("Wybierz symbole agentów");
|
|---|
| 752 | return;
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 756 |
|
|---|
| 757 | SqlCommand command = new SqlCommand();
|
|---|
| 758 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 759 |
|
|---|
| 760 | command.CommandType = CommandType.StoredProcedure;
|
|---|
| 761 | command.CommandText = "przepiszKlientow";
|
|---|
| 762 |
|
|---|
| 763 | command.Parameters.AddWithValue("@staryUserName", staryAgentComboBox.SelectedValue);
|
|---|
| 764 | command.Parameters.AddWithValue("@nowyUserName", nowyAgentComboBox.SelectedValue);
|
|---|
| 765 |
|
|---|
| 766 | command.Connection.Open();
|
|---|
| 767 |
|
|---|
| 768 | SqlTransaction transaction = command.Connection.BeginTransaction();
|
|---|
| 769 | command.Transaction = transaction;
|
|---|
| 770 |
|
|---|
| 771 | try
|
|---|
| 772 | {
|
|---|
| 773 | command.ExecuteNonQuery();
|
|---|
| 774 | transaction.Commit();
|
|---|
| 775 | MessageBox.Show("Klienci zostali przepisani.");
|
|---|
| 776 | }
|
|---|
| 777 | catch (Exception ex)
|
|---|
| 778 | {
|
|---|
| 779 | MessageBox.Show(ex.GetType() + ex.Message);
|
|---|
| 780 |
|
|---|
| 781 | try
|
|---|
| 782 | {
|
|---|
| 783 | transaction.Rollback();
|
|---|
| 784 | }
|
|---|
| 785 | catch (Exception ex2)
|
|---|
| 786 | {
|
|---|
| 787 | MessageBox.Show("ROLLBACK:" + ex2.GetType() + ex.Message);
|
|---|
| 788 | }
|
|---|
| 789 | }
|
|---|
| 790 |
|
|---|
| 791 | command.Connection.Close();
|
|---|
| 792 |
|
|---|
| 793 | this.Cursor = Cursors.Default;
|
|---|
| 794 |
|
|---|
| 795 | }
|
|---|
| 796 |
|
|---|
| 797 | private void generujTytuly(){
|
|---|
| 798 |
|
|---|
| 799 | SLOWNIKDataSet.LISTA_TYTULOWDataTable dt = lISTA_TYTULOWTableAdapter.GetData()
|
|---|
| 800 | as SLOWNIKDataSet.LISTA_TYTULOWDataTable;
|
|---|
| 801 |
|
|---|
| 802 | foreach (SLOWNIKDataSet.LISTA_TYTULOWRow r in dt) {
|
|---|
| 803 | treeView1.Nodes.Add(new TreeNode(r.SYMB));
|
|---|
| 804 | treeView2.Nodes["wszystkieNode"].Nodes.Add(new TreeNode(r.SYMB));
|
|---|
| 805 | treeView2.Nodes["TylkoAktywne"].Nodes.Add(new TreeNode(r.SYMB));
|
|---|
| 806 | }
|
|---|
| 807 | }
|
|---|
| 808 |
|
|---|
| 809 | private void kursy_WalutDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
|
|---|
| 810 | {
|
|---|
| 811 | if (User.getUser().IdAgencji == 6)
|
|---|
| 812 | {
|
|---|
| 813 | if (e.ColumnIndex == 5 && e.RowIndex != -1)
|
|---|
| 814 | {
|
|---|
| 815 | decimal poprzedniKurs = Convert.ToDecimal(
|
|---|
| 816 | kursy_WalutDataGridView[e.ColumnIndex, e.RowIndex].Value);
|
|---|
| 817 |
|
|---|
| 818 | KursyWalutPoznan kwp = new KursyWalutPoznan(poprzedniKurs);
|
|---|
| 819 |
|
|---|
| 820 | if (kwp.ShowDialog() == DialogResult.OK)
|
|---|
| 821 | {
|
|---|
| 822 | kursy_WalutDataGridView[e.ColumnIndex, e.RowIndex].Value = kwp.KursSredni;
|
|---|
| 823 | kursy_WalutDataGridView.EndEdit();
|
|---|
| 824 | kursy_WalutBindingSource.EndEdit();
|
|---|
| 825 | kursy_WalutTableAdapter.Update(this.sLOWNIKDataSet.Kursy_Walut);
|
|---|
| 826 | }
|
|---|
| 827 | }
|
|---|
| 828 | }
|
|---|
| 829 |
|
|---|
| 830 | }
|
|---|
| 831 |
|
|---|
| 832 |
|
|---|
| 833 |
|
|---|
| 834 | }
|
|---|
| 835 | } |
|---|