| 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 |
|
|---|
| 10 | namespace Baza_Reklam
|
|---|
| 11 | {
|
|---|
| 12 | public partial class OcenaAddForm : Form
|
|---|
| 13 | {
|
|---|
| 14 | public OcenaAddForm()
|
|---|
| 15 | {
|
|---|
| 16 | InitializeComponent();
|
|---|
| 17 |
|
|---|
| 18 | this.agenciTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 19 | this.aGENCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | private void OcenaAddForm_Load(object sender, EventArgs e)
|
|---|
| 23 | {
|
|---|
| 24 | this.aGENCJETableAdapter.Fill(this.sLOWNIKDataSet.AGENCJE);
|
|---|
| 25 | comboBox1.SelectedValue = User.getUser().IdAgencji;
|
|---|
| 26 |
|
|---|
| 27 | numericUpDown1.Value = DateTime.Today.Month;
|
|---|
| 28 |
|
|---|
| 29 | numericUpDown2.Minimum = DateTime.Today.Year - 1;
|
|---|
| 30 | numericUpDown2.Maximum = DateTime.Today.Year + 2;
|
|---|
| 31 | numericUpDown2.Value = DateTime.Today.Year;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
|
|---|
| 35 | {
|
|---|
| 36 | if (comboBox1.SelectedValue != null)
|
|---|
| 37 | {
|
|---|
| 38 | checkedListBox1.DataSource = this.agenciTableAdapter1.GetDataByIdAgencjiAktywni(Convert.ToInt32(comboBox1.SelectedValue));
|
|---|
| 39 | checkedListBox1.DisplayMember = "Symbol";
|
|---|
| 40 | checkedListBox1.ValueMember = "ID_Agenta";
|
|---|
| 41 |
|
|---|
| 42 | for (int i = 0; i <= checkedListBox1.Items.Count-1; i++)
|
|---|
| 43 | {
|
|---|
| 44 | checkedListBox1.SetItemChecked(i, true);
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | private void button1_Click(object sender, EventArgs e)
|
|---|
| 50 | {
|
|---|
| 51 | for(int i=0 ; i<= checkedListBox1.Items.Count-1; i++)
|
|---|
| 52 | {
|
|---|
| 53 | if (!checkedListBox1.CheckedIndices.Contains(i))
|
|---|
| 54 | {
|
|---|
| 55 | checkedListBox1.SetItemChecked(i, true);
|
|---|
| 56 | }
|
|---|
| 57 | else
|
|---|
| 58 | {
|
|---|
| 59 | checkedListBox1.SetItemChecked(i, false);
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | private void button2_Click(object sender, EventArgs e)
|
|---|
| 65 | {
|
|---|
| 66 | if (checkedListBox1.CheckedItems.Count != 0)
|
|---|
| 67 | {
|
|---|
| 68 | SqlConnection conn = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 69 |
|
|---|
| 70 | SqlCommand command = new SqlCommand();
|
|---|
| 71 | command.Connection = conn;
|
|---|
| 72 |
|
|---|
| 73 | command.CommandText = "INSERT INTO [PLAN] (SYMBOL, ROK, MS, BUDZET, SPOTKANIA, KONTAKTY, N_KLIENCI, KLIENCI," +
|
|---|
| 74 | " REKLAMY, WIEDZA_O_FIRMIE, WIEDZA_O_PRODUKCIE, WIEDZA_O_RYNKU, WIEDZA_OGOLNO_HANDLOWA, JAKOSC_ROZMOWY_TEL," +
|
|---|
| 75 | " JAKOSC_SPOTKAN, JAKOSC_KORESPONDENCJI, JAKOSC_OFERT, W_BUDZET, W_SPOTKANIA, W_TEL, W_EMAIL, W_LIST, W_FAX, " +
|
|---|
| 76 | " W_N_KLIENCI, W_KLIENCI, W_REKLAMY, EP, ESP, EPR, EPK, ECP, ELK, QO, WH, OCENA, PR_PROWIZJI) VALUES " +
|
|---|
| 77 | " (@SYMBOL,@ROK,@MS,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) ";
|
|---|
| 78 |
|
|---|
| 79 | command.Parameters.AddWithValue("@rok", numericUpDown2.Value);
|
|---|
| 80 | command.Parameters.AddWithValue("@ms", numericUpDown1.Value);
|
|---|
| 81 |
|
|---|
| 82 | foreach (object checkedItem in checkedListBox1.CheckedItems)
|
|---|
| 83 | {
|
|---|
| 84 | command.Parameters.AddWithValue("@SYMBOL", ((DataRowView)checkedItem)["symbol"]);
|
|---|
| 85 | conn.Open();
|
|---|
| 86 | command.ExecuteNonQuery();
|
|---|
| 87 | conn.Close();
|
|---|
| 88 | command.Parameters.RemoveAt("@SYMBOL");
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | MessageBox.Show("Rekordy zosta³y dodane");
|
|---|
| 92 | }
|
|---|
| 93 | else
|
|---|
| 94 | {
|
|---|
| 95 | MessageBox.Show("Nie zaznaczono ¿adnego agenta");
|
|---|
| 96 | }
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | private void button3_Click(object sender, EventArgs e)
|
|---|
| 100 | {
|
|---|
| 101 | this.Close();
|
|---|
| 102 | }
|
|---|
| 103 | }
|
|---|
| 104 | } |
|---|