Пример #1
0
        public void InsertDisabilityInfo(PersonDisability disability)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connStr))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("insert into hr.disabledEmployees  (emplid, series, serialNumber, " +
                                                    "msecDateFrom, timeIssued, disabilityDateFrom, disabilityDateTo, disabilityGroup, reason, scancopy) " +
                                                    "values (@emplid, @series, @serialNumber, @msecDateFrom, @timeIssued, @disabilityDateFrom, @disabilityDateTo, " +
                                                    "@disabilityGroup, @reason, @scancopy);", conn);

                    cmd.Parameters.Add(@"emplId", System.Data.SqlDbType.SmallInt); cmd.Parameters[@"emplId"].Value = Convert.ToInt16(disability.emplId);
                    cmd.Parameters.AddWithValue(@"series", Convert.ToString(disability.disabSeries));
                    cmd.Parameters.AddWithValue(@"serialNumber", Convert.ToString(disability.disabNumber));
                    cmd.Parameters.AddWithValue(@"msecDateFrom", Convert.ToString(disability.msecDateFrom));
                    cmd.Parameters.AddWithValue(@"timeIssued", Convert.ToString(disability.timeIssued));
                    cmd.Parameters.AddWithValue(@"disabilityDateFrom", Convert.ToString(disability.disabilityDateFrom));
                    cmd.Parameters.AddWithValue(@"disabilityDateTo", Convert.ToString(disability.disabilityDateTo));
                    cmd.Parameters.AddWithValue(@"disabilityGroup", Convert.ToChar(disability.disabilityGroup));
                    cmd.Parameters.AddWithValue(@"reason", Convert.ToString(disability.reason));
                    cmd.Parameters.AddWithValue(@"scancopy", (byte[])disability.scancopy);
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    conn.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("помилка при відправці даних даних (інв.).");
            }
        }
Пример #2
0
        //disability info about employee
        public async Task <PersonDisability> GetPersonDisabilityInfo(short emplid)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connStr))
                {
                    PersonDisability employee = new PersonDisability();
                    await conn.OpenAsync();

                    SqlCommand    cmd    = new SqlCommand("EXECUTE hr.GetDisabilityInfo " + emplid.ToString(), conn);
                    SqlDataReader reader = await cmd.ExecuteReaderAsync();

                    while (await reader.ReadAsync())
                    {
                        employee.emplId             = reader.GetInt16(0);
                        employee.disabSeries        = reader.GetString(1);
                        employee.disabNumber        = reader.GetString(2);
                        employee.msecDateFrom       = reader.GetString(3);
                        employee.timeIssued         = reader.GetString(4);
                        employee.disabilityDateFrom = reader.GetString(5);
                        employee.disabilityDateTo   = reader.GetString(6);
                        employee.disabilityGroup    = reader.GetString(7);
                        employee.reason             = reader.GetString(8);
                        if (reader.GetValue(9) == (object)0)
                        {
                            employee.scancopy = null;
                        }
                        else
                        {
                            employee.scancopy = (byte[])reader.GetValue(9);
                        }
                    }
                    reader.Close();
                    return(employee);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Помилка при завантаженні даних (інв.).");
                return(null);
            }
        }