Exemplo n.º 1
0
 public Car(string _code, string _model, SqlDate _creation_date, string _driver_id)
 {
     code          = _code;
     model         = _model;
     creation_date = _creation_date;
     driver_id     = _driver_id;
 }
Exemplo n.º 2
0
 public Track(ATM[] atms_c, bool idDone_c, SqlDate date_C, string carID_c, string empID_c, string mgrID_c)
 {
     atms        = atms_c;
     is_done     = idDone_c;
     date        = date_C;
     car_id      = carID_c;
     employee_id = empID_c;
     manager_id  = mgrID_c;
 }
Exemplo n.º 3
0
        public void makeWithdrawal(string atmID, SqlDate date, int amount)
        {
            connect();

            int avilableMoney = getAvilableMoney(atmID);

            if (amount < avilableMoney)
            {
                string createWithdrawal = $"INSERT INTO Withdrawals (amount, date, Atms_id) VALUES({ amount }, '{ date.ToString() }', { atmID })";
                string updateATMRecord  = $"UPDATE atms SET live_money_avilable = { avilableMoney } - { amount } WHERE id = { atmID }";

                MySqlCommand createWithdrawalCmd = new MySqlCommand(createWithdrawal, conn);
                MySqlCommand updateAtmCmd        = new MySqlCommand(updateATMRecord, conn);

                createWithdrawalCmd.CommandType = CommandType.Text;
                updateAtmCmd.CommandType        = CommandType.Text;

                if (conn != null)
                {
                    try {
                        conn.Open();

                        createWithdrawalCmd.ExecuteNonQuery();
                        updateAtmCmd.ExecuteNonQuery();

                        conn.Close();
                    } catch (MySqlException ex) {
                        conn.Close();
                        throw ex;
                    }
                }
                else
                {
                    throw new Exception("Connection with database didn't established, Please try again");
                }
            }
            else
            {
                Console.WriteLine("Sorry but you can't withdrawal from this Atm this amount of money");
            }
        }
Exemplo n.º 4
0
        public Employee(string _id, string _name, SqlDate _birthDate, string _role, string _username, string _phone_number, string _gender, Address _address)
        {
            if (_id.Length == 9)
            {
                id = _id;
            }
            else
            {
                throw new Exception("Inserted id is not vaild");
            }

            name         = _name;
            birthDate    = _birthDate;
            role         = _role;
            username     = _username;
            password     = "******";
            phone_number = _phone_number;
            email        = $"{username}@nsec.com";
            gender       = _gender;
            address      = _address;
        }
Exemplo n.º 5
0
 public Employee(
     string _id,
     string _name,
     SqlDate _birthDate,
     string _role,
     string _username,
     string _password,
     string _phone_number,
     string _gender,
     Address _address
     )
 {
     id           = _id;
     name         = _name;
     birthDate    = _birthDate;
     role         = _role;
     username     = _username;
     password     = password;
     phone_number = _phone_number;
     email        = $"{username}@nsec.com";
     gender       = _gender;
     address      = _address;
 }
Exemplo n.º 6
0
        public Track[] getTracksByDate(SqlDate date)
        {
            connect();

            string       allTracksAtDateQuery = $"SELECT * FROM Tracks WHERE date = '{ date.ToString() }'";
            MySqlCommand allTracksCmd         = new MySqlCommand(allTracksAtDateQuery, conn);

            allTracksCmd.CommandType = CommandType.Text;

            if (conn != null)
            {
                try {
                    conn.Open();

                    // Find all Tracks at specific date
                    DataTable dataTable = new DataTable();
                    dataTable.Load(allTracksCmd.ExecuteReader());
                    var rows = dataTable.AsEnumerable().ToArray();

                    List <Track> allTracks = new List <Track>();

                    for (int i = 0; i < rows.Length; i++)
                    {
                        allTracks.Add(getTrackByID(rows[i]["id"].ToString()));
                    }

                    conn.Close();
                    return(allTracks.ToArray());
                } catch (MySqlException ex) {
                    conn.Close();
                    throw ex;
                }
            }

            throw new Exception("Connection with database didn't established, Please try again");
        }