public static CancellationReason GetCancellationReasonByReason(string reas)
        {
            CancellationReason result = null;
            Hashtable          pars   = new Hashtable();

            pars.Add("причина", reas);
            try
            {
                using (DBManager db = new DBManager())
                {
                    db.Open();
                    using (SqlDataReader reader = db.ExecuteQuery(GetReasonQueryByReason, pars))
                    {
                        result = GetReasonFromDataReader(reader);
                        reader.Close();
                    }
                    db.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            Passenger          p = new Passenger();
            Station            s = new Station();
            Driver             d = new Driver();
            Train              t = new Train();
            CancellationReason c = new CancellationReason();

            if (TableType.Equals(p.GetType()))
            {
                UpdatePassenger(tbNewValue.Text);
            }
            if (TableType.Equals(s.GetType()))
            {
                UpdateStation(tbNewValue.Text);
            }
            if (TableType.Equals(d.GetType()))
            {
                UpdateDriver(tbNewValue.Text);
            }
            if (TableType.Equals(t.GetType()))
            {
                TrainDAL.UpdateTrainNum(tbNewValue.Text, Id);
            }
            if (TableType.Equals(c.GetType()))
            {
                CancellationReasonDAL.UpdateCancellationReason(tbNewValue.Text, Id);
            }
        }
        private static CancellationReason GetReasonFromDataReader(SqlDataReader reader)
        {
            reader.Read();
            CancellationReason t = new CancellationReason()
            {
                Id_Reason = reader.GetInt32(0),
                Reason    = reader.GetString(1)
            };

            return(t);
        }
        private static List <CancellationReason> GetReasonsListFromDataReader(SqlDataReader reader)
        {
            List <CancellationReason> result = new List <CancellationReason>();

            while (reader.Read())
            {
                CancellationReason t = new CancellationReason()
                {
                    Id_Reason = reader.GetInt32(0),
                    Reason    = reader.GetString(1)
                };
                result.Add(t);
            }
            return(result);
        }