Exemple #1
0
        public void InsertPedExp(PersonExperience exp)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connStr))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("insert into hr.pedExperience ( totalExp, specializationExp, positionExp, lastChangesDate " +
                                                    "values (@totalexp, @specExp, @posExp, @lastchanges );", conn);

                    cmd.Parameters.Add(@"emplId", System.Data.SqlDbType.SmallInt); cmd.Parameters[@"emplId"].Value = Convert.ToInt16(exp.emplid);
                    cmd.Parameters.AddWithValue(@"totalexp", Convert.ToInt16(exp.totalExp));
                    cmd.Parameters.AddWithValue(@"specExp", Convert.ToInt16(exp.specializationExp));
                    cmd.Parameters.AddWithValue(@"posExp", Convert.ToInt16(exp.positionExp));
                    cmd.Parameters.AddWithValue(@"lastchanges", Convert.ToDateTime(exp.lastChangesDate));
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    conn.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("помилка при відправці даних даних (стаж).");
            }
        }
Exemple #2
0
        //Positions and experience info about employee
        public async Task <(List <PersonPosition>, PersonExperience)> GetPersonPositions(short emplid)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connStr))
                {
                    List <PersonPosition> positions = new List <PersonPosition>();
                    await conn.OpenAsync();

                    SqlCommand    cmdPositions = new SqlCommand("exec hr.GetPositions " + emplid + " ;", conn);
                    SqlDataReader reader       = await cmdPositions.ExecuteReaderAsync();

                    while (await reader.ReadAsync())
                    {
                        PersonPosition position = new PersonPosition()
                        {
                            positionId     = (short)reader.GetValue(0),
                            positionCode   = (short)reader.GetValue(1),
                            positionName   = reader.GetValue(2).ToString(),
                            positionVolume = (decimal)reader.GetValue(3),
                            isMainPosition = Convert.ToBoolean(reader.GetValue(4))
                        };
                        positions.Add(position);
                    }
                    reader.Close();
                    PersonExperience experience = new PersonExperience();
                    SqlCommand       cmdExp     = new SqlCommand("exec hr.GetExp " + emplid + " ;", conn);
                    SqlDataReader    readerExp  = await cmdExp.ExecuteReaderAsync();

                    while (await readerExp.ReadAsync())
                    {
                        experience.emplid            = (short)readerExp.GetValue(0);
                        experience.totalExp          = (short)readerExp.GetValue(1);
                        experience.specializationExp = (short)readerExp.GetValue(2);
                        experience.positionExp       = (short)readerExp.GetValue(3);
                        experience.lastChangesDate   = readerExp.GetValue(4).ToString();
                    }
                    readerExp.Close();
                    return(positions, experience);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Помилка при завантаженні даних (посади).");
                return(null, null);
            }
        }