예제 #1
0
        private void EditServiceman_Load(object sender, EventArgs e)
        {
            if (_id != -1)
            {
                Serviceman name = _db.GetServiceman(_id);

                if (name == null)
                {
                    ShowErrorMessageBox("No serviceman with this ID!");
                    return;
                }
            }
        }
예제 #2
0
        public Serviceman GetServiceman(int id)
        {
            SqlCommand    command = new SqlCommand($"SELECT * FROM Servicemans WHERE Id_Serviceman = {id}", _connection);
            SqlDataReader reader  = command.ExecuteReader();
            Serviceman    result  = null;

            if (reader.Read())
            {
                result = new Serviceman()
                {
                    Id_Serviceman      = (int)reader["Id_Serviceman"],
                    Last_Name          = reader["Last_Name"].ToString(),
                    First_Name         = reader["First_Name"].ToString(),
                    Pathronymic        = reader["Pathronymic"].ToString(),
                    Age                = (int)reader["Age"],
                    Id_rank            = (int)reader["Id_rank"],
                    Branches_id_Branch = (int)reader["Branches_id_Branch"]
                };
            }

            reader.Close();
            return(result);
        }