Exemple #1
0
        private static Collection <Zamestnanec> Read(SqlDataReader reader, bool sPoctemRezervaci = false)
        {
            Collection <Zamestnanec> zamestnanecs = new Collection <Zamestnanec>();

            while (reader.Read())
            {
                int         i           = -1;
                Zamestnanec zamestnanec = new Zamestnanec();
                zamestnanec.id_zamestnance   = reader.GetString(++i);
                zamestnanec.id_Pozice        = reader.GetInt32(++i);
                zamestnanec.pozice           = new Pozice();
                zamestnanec.pozice.id_pozice = zamestnanec.id_Pozice;
                zamestnanec.jmeno            = reader.GetString(++i);
                zamestnanec.prijmeni         = reader.GetString(++i);
                zamestnanec.email            = reader.GetString(++i);
                if (sPoctemRezervaci)
                {
                    if (!reader.IsDBNull(++i))
                    {
                        zamestnanec.pocetRezervaci = reader.GetInt32(i);
                    }
                }

                zamestnanecs.Add(zamestnanec);
            }

            return(zamestnanecs);
        }
Exemple #2
0
        public int SaveZam(Zamestnanec zamestnanec)
        {
            SqlConnectionStringBuilder builder = DBConnector.GetBuilder();

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Clear();
                sb.Append("INSERT INTO vis.zamestnanec (id_zamestnance,jmeno,prijmeni,email, pozice)");
                sb.Append("VALUES (@id, @jmeno, @prijmeni,@email,@pozice);");
                //sb.Append("SELECT CAST(scope_identity() AS int)");
                string sql = sb.ToString();
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.Parameters.AddWithValue("@id", zamestnanec.ID);
                    command.Parameters.AddWithValue("@jmeno", zamestnanec.Jmeno);
                    command.Parameters.AddWithValue("@prijmeni", zamestnanec.Prijmeni);
                    command.Parameters.AddWithValue("@email", zamestnanec.Email);
                    command.Parameters.AddWithValue("@pozice", zamestnanec.Pozice);
                }
            }

            return(0);
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ZamestnanecFactory zamestnanecFactory = new ZamestnanecFactory();
            ZamestnanecGateway <Zamestnanec> zg   = (ZamestnanecGateway <Zamestnanec>)zamestnanecFactory.GetZamestnanec();



            if (Session["ID"] == null)
            {
                Response.Redirect("~/Login.aspx");
            }
            zamestnanec    = zg.Select_id(int.Parse((Session["ID"].ToString())));
            newZamestnanec = zamestnanec;

            nameElement.Attributes.Add("placeholder", zamestnanec.Name);
            surnameElement.Attributes.Add("placeholder", zamestnanec.LastName);
            perIdNumElement.Attributes.Add("placeholder", zamestnanec.PerIdNum.ToString());
            adressElement.Attributes.Add("placeholder", zamestnanec.Adress);
            sexElement.Attributes.Add("placeholder", zamestnanec.Sex);
            workGroupElement.Attributes.Add("placeholder", zamestnanec.WorkGroup.ToString());
            projectElement.Attributes.Add("placeholder", zamestnanec.IdProject.ToString());
            positionElemnt.Attributes.Add("placeholder", zamestnanec.Group.ToString());
            mailElement.Attributes.Add("placeholder", zamestnanec.Mail);
            password1.Attributes.Add("placeholder", "********");
            password2.Attributes.Add("placeholder", "********");
            oldPasswordElement.Attributes.Add("placeholder", "********");
        }
Exemple #4
0
 private void Form_ZapísaťOdpracovanýDeň_Shown(object sender, EventArgs e)
 {
     //Vybranie zoznamu celých mien zamestnancov z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxMeno(comboBox_Zamestnanci);
     // Získanie NazovZakazky pomocou kódu zákazky
     Zakazka.FillComboBoxNazov(comboBox_Zakazka);
 }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Meno,Priezvisko,Január,Február,Marec,Apríl,Máj,Jún,Júl,August,September,Október,November,December")] Zamestnanec zamestnanec)
        {
            if (id != zamestnanec.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(zamestnanec);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ZamestnanecExists(zamestnanec.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(zamestnanec));
        }
Exemple #6
0
        /// <summary>
        /// Update the record.
        /// </summary>
        public static int update(Zamestnanec zamestnanec, Database pDb = null)
        {
            Database db;

            if (pDb == null)
            {
                db = new Database();
                db.Connect();
            }
            else
            {
                db = (Database)pDb;
            }

            SqlCommand command = db.CreateCommand(SQL_UPDATE);

            PrepareCommand(command, zamestnanec);
            int ret = db.ExecuteNonQuery(command);

            if (pDb == null)
            {
                db.Close();
            }

            return(ret);
        }
Exemple #7
0
        protected void uploadButton_Click1(object sender, EventArgs e)
        {
            ZamestnanecFactory zamestnanecFactory           = new ZamestnanecFactory();
            ZamestnanecGateway <Zamestnanec> zg             = (ZamestnanecGateway <Zamestnanec>)zamestnanecFactory.GetZamestnanec();
            Zamestnanec         zamestnanec                 = zg.Select_id(int.Parse((Session["ID"].ToString())));
            NepritomnostFactory nepritomnostFactory         = new NepritomnostFactory();
            NepritomnostGateway <Nepritomnost> ng           = (NepritomnostGateway <Nepritomnost>)nepritomnostFactory.GetNepritomnost();
            Collection <Nepritomnost>          nepritomnost = ng.Select_id_zam(zamestnanec.RecordId);

            foreach (Nepritomnost h in nepritomnost)
            {
                if (h.Datum.ToString() == DropDownList1.SelectedItem.ToString())
                {
                    nesch.Nepritomnost = h.RecordId;
                }
            }
            NeschopenkaFactory neschopenkaFactory = new NeschopenkaFactory();
            NeschopenkaGateway <Neschopenka> ne   = (NeschopenkaGateway <Neschopenka>)neschopenkaFactory.GetNeschopenka();
            Collection <Neschopenka>         za   = ne.Select();

            int id = 0;

            foreach (var nep in za)
            {
                if (nep.RecordId > id)
                {
                    id = nep.RecordId;
                }
            }
            id++;

            nesch.Text  = TextBox1.Text.ToString();
            nesch.Datum = DateTime.Now;
            ne.Insert(nesch);
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ZamestnanecFactory zamestnanecFactory = new ZamestnanecFactory();
            ZamestnanecGateway <Zamestnanec> zg   = (ZamestnanecGateway <Zamestnanec>)zamestnanecFactory.GetZamestnanec();

            Zamestnanec zamestnanec = zg.Select_id(int.Parse((Session["ID"].ToString())));

            NepritomnostFactory nepritomnostFactory         = new NepritomnostFactory();
            NepritomnostGateway <Nepritomnost> ng           = (NepritomnostGateway <Nepritomnost>)nepritomnostFactory.GetNepritomnost();
            Collection <Nepritomnost>          nepritomnost = ng.Select_id_zam(zamestnanec.RecordId);


            datasick = new Collection <SickNote>();
            NeschopenkaFactory neschopenkaFactory = new NeschopenkaFactory();
            NeschopenkaGateway <Neschopenka> ne   = (NeschopenkaGateway <Neschopenka>)neschopenkaFactory.GetNeschopenka();
            Collection <Neschopenka>         za   = ne.Select();

            foreach (var i in nepritomnost)
            {
                foreach (var a in za)
                {
                    if (a.Nepritomnost == i.RecordId)
                    {
                        datasick.Add(new SickNote(i.Datum, a.Datum, a.Text));
                    }
                }
            }
            if (!IsPostBack)
            {
                GridView2.DataSource = datasick;
                GridView2.DataBind();
            }
        }
Exemple #9
0
        public static int Insert(Zamestnanec pozice, MyDatabase pDB = null)
        {
            MyDatabase db;

            if (pDB == null)
            {
                db = new MyDatabase();
                db.Connect();
            }
            else
            {
                db = (MyDatabase)pDB;
            }
            SqlCommand command = db.CreateCommand(SQL_INSERT);

            PrepareCommand(command, pozice);
            int ret = db.ExecuteNonQuery(command);

            if (pDB == null)
            {
                db.Close();
            }

            return(ret);
        }
Exemple #10
0
        /*
         * /// <summary>
         * /// Select the records.
         * /// </summary>
         * public Collection<Zamestnanec> select(Database pDb = null)
         * {
         *  Database db;
         *  if (pDb == null)
         *  {
         *      db = new Database();
         *      db.Connect();
         *  }
         *  else
         *  {
         *      db = (Database)pDb;
         *  }
         *
         *  SqlCommand command = db.CreateCommand(SQL_SELECT);
         *  SqlDataReader reader = db.Select(command);
         *
         *  Collection<Zamestnanec> zamestnanecs = Read(reader);
         *  reader.Close();
         *
         *  if (pDb == null)
         *  {
         *      db.Close();
         *  }
         *
         *  return zamestnanecs;
         * }
         */
        /// <summary>
        /// Select the record.
        /// </summary>
        /// <param name="id">zamestnanec id</param>
        public Zamestnanec select(string id_zamestnance, Database pDb = null)
        {
            Database db;

            if (pDb == null)
            {
                db = new Database();
                db.Connect();
            }
            else
            {
                db = (Database)pDb;
            }

            SqlCommand command = db.CreateCommand(SQL_SELECT_ID);

            command.Parameters.AddWithValue("@id_zamestnance", id_zamestnance);
            SqlDataReader reader = db.Select(command);

            Collection <Zamestnanec> zamestnanecs = Read(reader);
            Zamestnanec zamestnanec = null;

            if (zamestnanecs.Count == 1)
            {
                zamestnanec = zamestnanecs[0];
            }
            reader.Close();

            if (pDb == null)
            {
                db.Close();
            }

            return(zamestnanec);
        }
Exemple #11
0
        protected void GetData()
        {
            Collection <Zamestnanec>  zamestnanci = Zamestnanec.SelectAll();
            BindingList <Zamestnanec> bindingList = new BindingList <Zamestnanec>(zamestnanci);

            dataGridView1.DataSource = bindingList;
        }
Exemple #12
0
 private static void PrepareCommand(SqlCommand command, Zamestnanec zamestnanec)
 {
     command.Parameters.AddWithValue("@id_zamestnance", zamestnanec.id_zamestnance);
     command.Parameters.AddWithValue("@pozice", zamestnanec.id_Pozice);
     command.Parameters.AddWithValue("@jmeno", zamestnanec.jmeno);
     command.Parameters.AddWithValue("@prijmeni", zamestnanec.prijmeni);
     command.Parameters.AddWithValue("@email", zamestnanec.email);
 }
Exemple #13
0
 protected void DeleteRecord()
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         Zamestnanec zamestnanec = dataGridView1.SelectedRows[0].DataBoundItem as Zamestnanec;
         Zamestnanec.delete(zamestnanec);
         GetData();
     }
 }
        private void buttonPotvrdit_Click(object sender, EventArgs e)
        {
            bool open = false, admin = false;;


            if (textBoxMeno.Text == "admin" && textBoxHeslo.Text == "admin")
            {
                admin                      = true;
                open                       = true;
                prihlas_zamenst            = new Zamestnanec();
                prihlas_zamenst.Id         = 0;
                prihlas_zamenst.Meno       = "admin";
                prihlas_zamenst.Priezvisko = "admin";
            }
            else
            {
                sql_cmd.CommandText = "Select * from Zamestnanec";
                using (DbDataReader dataReader = sql_cmd.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        Zamestnanec zamestnanec = new Zamestnanec();
                        zamestnanec.Id         = int.Parse($"{dataReader["zamestnanec_Id"]}");
                        zamestnanec.Meno       = $"{dataReader["zamestnanec_Meno"]}";
                        zamestnanec.Priezvisko = $"{dataReader["zamestnanec_Priezvisko"]}";
                        zamestnanci.Add(zamestnanec);
                    }
                }
                foreach (var zam in zamestnanci)
                {
                    if (textBoxMeno.Text == $"{zam.Meno}.{zam.Priezvisko}")
                    {
                        if (textBoxHeslo.Text == $"{zam.Priezvisko}{zam.Id}")
                        {
                            prihlas_zamenst            = new Zamestnanec();
                            prihlas_zamenst.Id         = zam.Id;
                            prihlas_zamenst.Meno       = zam.Meno;
                            prihlas_zamenst.Priezvisko = zam.Priezvisko;
                            open = true;
                            break;
                        }
                    }
                }
            }
            if (open)
            {
                HomePage homePage = new HomePage(sql_cmd, this);
                homePage.Prihlas_zamest = prihlas_zamenst;
                homePage.Admin          = admin;
                homePage.Show();
                this.Visible = false;
            }
            else
            {
                MessageBox.Show("Zadali ste zle prihlasovacie udaje");
            }
        }
Exemple #15
0
        private static Zamestnanec MapZamToObj(SqlDataReader reader)
        {
            Zamestnanec zamestnanec = new Zamestnanec();

            zamestnanec.ID       = reader.GetInt32(0);
            zamestnanec.Jmeno    = reader.GetString(1);
            zamestnanec.Prijmeni = reader.GetString(2);
            zamestnanec.Email    = reader.GetString(3);
            return(zamestnanec);
        }
 private void Form_ZobraziťZamestnancov_Shown(object sender, EventArgs e)
 {
     //Vybranie zoznamu celých mien zamestnancov z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxMeno(comboBox_MenoZamestannca);
     //Vybranie zoznamu ID zamestnancov z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxID(comboBox_IDzamestannca);
     //Vybranie zoznamu už vložených pracovných pozícií z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxPracovnaPozicia(comboBox_pracovnaPozicia);
     //Vybranie zoznamu už vložených pracovných pozícií z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxPracovnaPozicia(comboBox_PracovnaPozicia2);
 }
        public async Task <IActionResult> Create([Bind("ID,Meno,Priezvisko,Január,Február,Marec,Apríl,Máj,Jún,Júl,August,September,Október,November,December")] Zamestnanec zamestnanec)
        {
            if (ModelState.IsValid)
            {
                _context.Add(zamestnanec);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(zamestnanec));
        }
Exemple #18
0
 private Zamestnanec GetSelectedData()
 {
     if (gridZamestnanec.SelectedRows.Count == 1)
     {
         Zamestnanec t = gridZamestnanec.SelectedRows[0].DataBoundItem as Zamestnanec;
         return(t);
     }
     else
     {
         return(null);
     }
 }
 //Update vybraného riadku
 private void button_UlozitZmeny_Click(object sender, EventArgs e)
 {
     if (dataGridView_Zamestnanec.SelectedRows.Count > 0)
     {
         //uloženie  IDzamestnanca z vybraného riadku
         string ID = dataGridView_Zamestnanec.SelectedRows[0].Cells["idzamestnanci"].Value.ToString();
         // Úprava už existujúceho záznamu v tabulke zamestnanci v DB
         Zamestnanec.UpdateZamestnanca(ID, textBox_Meno.Text, textBox_Priezvisko.Text, comboBox_PracovnaPozicia2.Text, textBox_HodinovaMzda.Text);
         //Vybrať určité riadky z tabuľky zamestnanci z DB a uložiť do DataGridView pre zobrazenie updatenutých dát
         Zamestnanec.FillDGVSelectZamestnanci(dataGridView_Zamestnanec, comboBox_MenoZamestannca.Text, comboBox_IDzamestannca.Text, comboBox_pracovnaPozicia.Text);
     }
 }
Exemple #20
0
 private static void PrepareCommand(SqlCommand command, Zamestnanec zamestnanec)
 {
     command.Parameters.AddWithValue("@ID_zamestnance", zamestnanec.ID_zamestnance);
     command.Parameters.AddWithValue("@Jmeno", zamestnanec.Jmeno);
     command.Parameters.AddWithValue("@Prijmeni", zamestnanec.Prijmeni);
     command.Parameters.AddWithValue("@Narozeniny", Convert.ToDateTime(zamestnanec.Narozeniny).ToString("yyyy-MM-dd"));
     command.Parameters.AddWithValue("@Nastupni_den", Convert.ToDateTime(zamestnanec.Nastupni_den).ToString("yyyy-MM-dd"));
     command.Parameters.AddWithValue("@Mistr", zamestnanec.Mistr);
     command.Parameters.AddWithValue("@Login", zamestnanec.Login);
     command.Parameters.AddWithValue("@Heslo", zamestnanec.Heslo);
     command.Parameters.AddWithValue("@Zbyva_dovolenych", zamestnanec.Zbyva_dovolenych);
 }
 // Odstránenie vybraného záznamu v tabulke zamestnanci v DB
 private void button_Odstrániť_Click(object sender, EventArgs e)
 {
     if (dataGridView_Zamestnanec.SelectedRows.Count > 0)
     {
         //uloženie  IDzamestnanca z vybraného riadku
         string ID = dataGridView_Zamestnanec.SelectedRows[0].Cells["idzamestnanci"].Value.ToString();
         // Odstránenie existujúceho záznamu v tabulke zamestnanaci v DB
         Zamestnanec.DeleteZamestnanec(ID);
         //Vybrať určité riadky z tabuľky zamestnanci z DB a uložiť do DataGridView pre zobrazenie dát
         Zamestnanec.FillDGVSelectZamestnanci(dataGridView_Zamestnanec, comboBox_MenoZamestannca.Text, comboBox_IDzamestannca.Text, comboBox_pracovnaPozicia.Text);
     }
 }
        public bool NacistZamestnanceZTymu(int ID)
        {
            Collection <TymZamestnance> zamestnanci = TymZamestnanceTable.SeznamZamestnancuVTymu(ID);

            TymZamestnanceLB.Items.Clear();
            foreach (TymZamestnance zamestnanec in zamestnanci)
            {
                Zamestnanec z = ZamestnanecTable.Select(zamestnanec.ID_zamestnance);
                TymZamestnanceLB.Items.Add(z.ID_zamestnance + " " + z.Jmeno + " " + z.Prijmeni);
            }
            return(true);
        }
Exemple #23
0
 private void button1_Click(object sender, EventArgs e)
 {
     _loggedUser = _dataManager.AuthorizeNamePass(NameText.Text, PassText.Text);
     if (_loggedUser == null)
     {
         MessageBox.Show("Nesprávne meno alebo heslo!", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         Close();
     }
 }
Exemple #24
0
 private Zamestnanec GetSelectedZam()
 {
     // The "SelectionMode" property of the data grid view must be set to "FullRowSelect".
     if (dataGridView1.SelectedRows.Count == 1)
     {
         Zamestnanec zamestnanec = dataGridView1.SelectedRows[0].DataBoundItem as Zamestnanec;
         return(zamestnanec);
     }
     else
     {
         return(null);
     }
 }
Exemple #25
0
        protected void EditRecord()
        {
            Zamestnanec selectedZam = GetSelectedZam();

            if (selectedZam != null)
            {
                DetailZamestnanec form = new DetailZamestnanec();
                if (form.OpenRecord(selectedZam.idZam))
                {
                    form.ShowDialog();
                    GetData();
                }
            }
        }
Exemple #26
0
 private void Form_ZobraziťOdpracovanéDni_Shown(object sender, EventArgs e)
 {
     comboBox_mesiac.SelectedIndex = 0;
     //Vybranie zoznamu IDOdpracovaneDni z DB a uloženie ich do ComboBoxu
     OdpracovanyDen.FillComboBoxIDodpracovaneDni(comboBox_IDodpracovanyDen);
     //Vybranie zoznamu celých mien zamestnancov z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxMeno(comboBox_Zamestnanec);
     //Vybranie zoznamu názvov zákaziek z DB a uloženie ich do ComboBoxu
     Zakazka.FillComboBoxNazov(comboBox_Zakazka);
     //Vybranie zoznamu celých mien zamestnancov z DB a uloženie ich do ComboBoxu
     Zamestnanec.FillComboBoxMeno(comboBox_Zamestnanec2);
     //Vybranie zoznamu názvov zákaziek z DB a uloženie ich do ComboBoxu
     Zakazka.FillComboBoxNazov(comboBox_Zakazka2);
 }
Exemple #27
0
 public void OpenRecord(object primaryKey)
 {
     if (primaryKey != null)
     {
         int idZamestnanca = (int)primaryKey;
         ZamestnanecFactory zamestnanecFactory = new ZamestnanecFactory();
         ZamestnanecGateway <Zamestnanec> zg   = (ZamestnanecGateway <Zamestnanec>)zamestnanecFactory.GetZamestnanec();
         zamestnanec = zg.Select_id(idZamestnanca);
     }
     else
     {
         zamestnanec = new Zamestnanec();
     }
 }
Exemple #28
0
        private void BindData()
        {
            comboBox1.Items.Clear();
            comboBox2.Items.Clear();
            comboBox3.Items.Clear();
            comboBox4.Items.Clear();

            Collection <Prostor>     prostory    = Prostor.SelectAll();
            Collection <Zbran>       zbrane      = Zbran.SelectAvailable(strelba.Zacatek, strelba.Zacatek.AddMinutes(double.Parse(txtMin.Text)));
            Collection <Zakaznik>    zakaznici   = Zakaznik.SelectAll();
            Collection <Zamestnanec> zamestnanci = Zamestnanec.SelectAll();

            foreach (Prostor prostor in prostory)
            {
                comboBox1.Items.Add(prostor.Id.ToString() + " " + prostor.Vzdalenost.ToString() + "m");
                if (prostor.Id == strelba.Prostor.Id)
                {
                    comboBox1.SelectedIndex = comboBox1.Items.Count - 1;
                }
            }


            foreach (Zbran zbran in zbrane)
            {
                comboBox2.Items.Add(zbran.Nazev);
                if (zbran.Id == strelba.Zbran.Id)
                {
                    comboBox2.SelectedIndex = comboBox2.Items.Count - 1;
                }
            }

            foreach (Zakaznik zakaznik in zakaznici)
            {
                comboBox3.Items.Add(zakaznik.Email);
                if (zakaznik.Id == strelba.Zakaznik.Id)
                {
                    comboBox3.SelectedIndex = comboBox3.Items.Count - 1;
                }
            }

            foreach (Zamestnanec zamestnanec in zamestnanci)
            {
                comboBox4.Items.Add(zamestnanec.Email);
                if (zamestnanec.Id == strelba.Zamestnanec.Id)
                {
                    comboBox4.SelectedIndex = comboBox4.Items.Count - 1;
                }
            }
        }
 public MainWindow(string meno, string heslo)
 {
     InitializeComponent();
     CoreApp.Register(meno, heslo);
     TypyVoznov = NacitajTypyVoznovZDB();
     Vlastnici  = NacitajVlastnikovZDB();
     Stanice    = NacitajStaniceZDB();
     TypyVlakov = NacitajTypyVlakovZDB();
     Vozen      = new Vozen()
     {
         AktualnaPoloha = new Poloha()
     };
     ZamestnanecNovy = new Zamestnanec();
     DataContext     = this;
 }
Exemple #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (new ZamestnanecTable().select(idZam.Text) != null)
            {
                zamestnanec = new ZamestnanecTable().select(idZam.Text);
                MenuF menu = new MenuF();
                menu.Show();
                this.Close();
            }

            else
            {
                MessageBox.Show("Takový zaměstnanec neexistuje");
            }
        }