Пример #1
0
        public Customer Select(int id)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_SELECT_BY_ID);
            command.Parameters.Add(new SqlParameter("@p_id", SqlDbType.Int));
            command.Parameters["@p_id"].Value = id;
            SqlDataReader reader = db.Select(command);
            try
            {

            reader.Read();
            Customer cust = new Customer();
            cust.id = reader.GetInt32(0);
            cust.email = reader.GetString(1);
            cust.fname = reader.GetString(2);
            cust.lname = reader.GetString(3);
            cust.phone = reader.GetString(4);
            cust.adress = reader.GetString(5);
            cust.city = reader.GetString(6);
            cust.postaCode = reader.GetInt32(7);
            reader.Close();
            db.Close();
                return cust;
            }
            catch
            {
                return null;
            }
        }
Пример #2
0
        public NamesForm()
        {
            InitializeComponent();

            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["sl"];

            _schoolDatabase = new SchoolDatabase(connectionStringSettings.ConnectionString);
        }
Пример #3
0
        public void Setup()
        {
            schoolDatabase = new SchoolDatabase();

            studentMock = new Mock <Student>();

            student = studentMock.Object;
        }
Пример #4
0
        public void studentPutFact()
        {
            SchoolDatabase schoolDatabase = new SchoolDatabase();

            Student student = new Student(10, "Krystian", "Dab", 5);

            Assert.True(schoolDatabase.PutStudent(student));
        }
Пример #5
0
        public void studentListCheckFact()
        {
            SchoolDatabase schoolDatabase = new SchoolDatabase();

            List <Student> listOfStudents = schoolDatabase.GetStudents();

            Assert.NotEmpty(listOfStudents);
        }
Пример #6
0
        public void SaveCourse(CourseDTO trab)
        {
            string query = "INSERT INTO TB_CURSO (nm_nome, nm_endereco, nm_celular, nr_data, nr_telefone) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}' )";

            query = string.Format(query, trab.Name, trab.Phone, trab.Address, trab.CellPhone, trab.renewal);
            SchoolDatabase d = new SchoolDatabase();

            d.ExecuteInsert(query);
        }
Пример #7
0
 public int Insert(StoredWheels st)
 {
     SchoolDatabase db = new SchoolDatabase();
     db.Connect();
     SqlCommand command = db.CreateCommand(SQL_INSERT);
     PrepareCommand(command, st);
     int ret = db.ExecuteNonQuery(command);
     db.Close();
     return ret;
 }
Пример #8
0
 public int Insert(OkPneuTire tire)
 {
     SchoolDatabase db = new SchoolDatabase();
     db.Connect();
     SqlCommand command = db.CreateCommand(SQL_INSERT);
     PrepareCommand(command, tire);
     int ret = db.ExecuteNonQuery(command);
     db.Close();
     return ret;
 }
Пример #9
0
        static void Main(string[] args)
        {
            int x = Properties.Settings.Default.Interval;
            ConnectionStringSettings cxnstring = ConfigurationManager.ConnectionStrings["sl"];

            SchoolDatabase td = new SchoolDatabase(cxnstring.ConnectionString);

            foreach (string s in td.Students("Lower 8"))
            {
                Console.WriteLine(s);
            }

            Console.ReadKey();
        }
Пример #10
0
 //public int Delete(int id)
 //{
 //    Database db = new Database(connectionString);
 //    db.Connect();
 //    SqlCommand command = db.CreateCommand(SQL_DELETE);
 //    command.Parameters.Add(new SqlParameter("@p_id", SqlDbType.Int));
 //    command.Parameters["@p_id"].Value = id;
 //    int ret = db.ExecuteNonQuery(command);
 //    db.Close();
 //    return ret;
 //}
 public int Insert(Customer cust)
 {
     if (!FindCustomerByEmail(cust.email))
     {
         SchoolDatabase db = new SchoolDatabase();
         db.Connect();
         SqlCommand command = db.CreateCommand(SQL_INSERT);
         PrepareCommand(command, cust);
         int ret = db.ExecuteNonQuery(command);
         db.Close();
         return ret;
     }
     else return -2;
 }
Пример #11
0
        public List<StoredWheels> Select(int id)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_SELECT);
            command.Parameters.Add(new SqlParameter("@p_Customers_id", SqlDbType.VarChar, 20));
            command.Parameters["@p_Customers_id"].Value = id;

            SqlDataReader reader = db.Select(command);

            List<StoredWheels> cust = Read(reader);
            reader.Close();
            db.Close();
            return cust;
        }
Пример #12
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DoUpdate)
            {
                strBuilCommand.Append(" where @p_id = id");

                SchoolDatabase db = new SchoolDatabase();
                db.Connect();
                string tmp = strBuilCommand.ToString();
                SqlCommand command = db.CreateCommand(tmp);
                PrepareCommand(command, emp);
                int ret = db.ExecuteNonQuery(command);
                db.Close();
            }
            Response.Redirect("~/Employees/ListEmployee.aspx");
        }
Пример #13
0
        public bool IsGarageEmpty(int gar)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();
            SqlCommand command = db.CreateCommand(SQL_IS_GARAGE_EMPTY);
            command.Parameters.Add(new SqlParameter("@p_gar", SqlDbType.Int));
            command.Parameters["@p_gar"].Value = gar;
            SqlDataReader reader = db.Select(command);

            reader.Read();
            int tmp = reader.GetInt32(0);
            reader.Close();
            db.Close();
            if (tmp == 0) return true;
            else return false;
        }
Пример #14
0
 public List<ListItem> FindManufacturers()
 {
     SchoolDatabase db = new SchoolDatabase();
     db.Connect();
     SqlCommand command = db.CreateCommand(SQL_FIND_MANUFACTURER);
     SqlDataReader reader = db.Select(command);
     List<ListItem> tires = new List<ListItem>();
     tires.Add(new ListItem("Všichni výrobci", "x", true));
     while (reader.Read())
     {
         ListItem l1 = new ListItem(reader.GetString(0), "x", true);
         tires.Add(l1);
     }
     db.Close();
     return tires;
 }
Пример #15
0
        public bool UnstoreCheck(int id)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();
            SqlCommand command = db.CreateCommand(SQL_UNSTORE_CHECK);

            command.Parameters.Add(new SqlParameter("@p_id", SqlDbType.Int));
            command.Parameters["@p_id"].Value = id;
            SqlDataReader reader = db.Select(command);
            reader.Read();
            int ret = reader.GetInt32(0);

            db.Close();
            if (ret == 1) return true;
            else return false;
        }
Пример #16
0
        public int Exit(Contract con)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();
            SqlCommand command = db.CreateCommand(SQL_EXIT);

            command.Parameters.Add(new SqlParameter("@p_GarageNumber", SqlDbType.SmallInt));
            command.Parameters["@p_GarageNumber"].Value = con.GarageNumber;
            command.Parameters.Add(new SqlParameter("@p_Payment", SqlDbType.SmallInt));
            command.Parameters["@p_Payment"].Value = con.Payment;
            command.Parameters.Add(new SqlParameter("@p_VAT", SqlDbType.Bit));
            command.Parameters["@p_VAT"].Value = con.VAT;

            int ret = db.ExecuteNonQuery(command);
            db.Close();
            return ret;
        }
Пример #17
0
        public int Arrival(Contract con)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_ARRIVAL);

            command.Parameters.Add(new SqlParameter("@p_CustomerID", SqlDbType.Int));
            command.Parameters["@p_CustomerID"].Value = con.CustomerId;
            command.Parameters.Add(new SqlParameter("@p_EmployeesID", SqlDbType.Int));
            command.Parameters["@p_EmployeesID"].Value = con.EmployeesId;
            command.Parameters.Add(new SqlParameter("@p_GarageNumber", SqlDbType.SmallInt));
            command.Parameters["@p_GarageNumber"].Value = con.GarageNumber;
            int ret = db.ExecuteNonQuery(command);
            db.Close();
            return ret;
        }
Пример #18
0
        public bool UnstoreTires(int id, int EmployeeID)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();
            SqlCommand command = db.CreateCommand(SQL_UNSTORE);

            command.Parameters.Add(new SqlParameter("@p_id", SqlDbType.Int));
            command.Parameters["@p_id"].Value = id;

            command.Parameters.Add(new SqlParameter("@p_Unstore_id", SqlDbType.Int));
            command.Parameters["@p_Unstore_id"].Value = EmployeeID;

            int ret = db.ExecuteNonQuery(command);

            db.Close();
            if (ret == 1) return true;
            else return false;
        }
Пример #19
0
        public OkPneuTire Select(string EAN)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();
            SqlCommand command = db.CreateCommand(SQL_FIND_BY_EAN);

            command.Parameters.Add(new SqlParameter("@p_EAN", SqlDbType.VarChar, 14));
            command.Parameters["@p_EAN"].Value = EAN;

            SqlDataReader reader = db.Select(command);
            reader.Read();
            OkPneuTire tire = new OkPneuTire();
            tire.Name = reader.GetString(0);
            tire.ProdejniCena = reader.GetDecimal(1);

            reader.Close();
            db.Close();
            return tire;
        }
Пример #20
0
        public List <CourseDTO> listAllCourses()
        {
            string          query = "Select * from tb_Curso";
            SchoolDatabase  d     = new SchoolDatabase();
            MySqlDataReader r     = d.ExecuteSelect(query);

            List <CourseDTO> itens = new List <CourseDTO>();

            while (r.Read())
            {
                CourseDTO t = new CourseDTO();
                t.ID        = r.GetInt32("id_trab");
                t.Name      = r.GetString("nm_nome");
                t.Phone     = r.GetString("nr_telefone");
                t.Address   = r.GetString("nm_endereco");
                t.CellPhone = r.GetString("nm_celular");
                t.Renewal   = r.GetInt32("nr_data");

                itens.Add(t);
            }
            return(itens);
        }
Пример #21
0
 public SubjectsController(SchoolDatabase db)
 {
     _db = db;
 }
Пример #22
0
        public List<OkPneuTire> Select(int size)
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_SELECT_BY_DETAIL);

            command.Parameters.Add(new SqlParameter("@p_Size", SqlDbType.Int));
            command.Parameters["@p_Size"].Value = size;

            SqlDataReader reader = db.Select(command);

            List<OkPneuTire> tires = Read(reader);
            reader.Close();
            db.Close();
            return tires;
        }
Пример #23
0
        public void deleteCheck(int id)
        {
            SchoolDatabase schoolDatabase = new SchoolDatabase();

            Assert.False(schoolDatabase.DeleteStudent(id));
        }
Пример #24
0
 public PersonController(SchoolDatabase dbContext)
 {
     _dbContext = dbContext;
 }
Пример #25
0
        public void deleteCheckFact()
        {
            SchoolDatabase schoolDatabase = new SchoolDatabase();

            Assert.False(schoolDatabase.DeleteStudent(99990));
        }
Пример #26
0
        public List<OkPneuTire> Select(string strsize, char season, bool OnExternalStore, bool OnLokalStore, string manu)
        {
            if (strsize == null) return null;
            string pattern = "[1-3][0-9][0,5][3-9][0,5][1,2][0-9]";
            Regex currencyRegex = new Regex(pattern);
            if (currencyRegex.IsMatch(strsize))
            {

                int size = Int32.Parse(strsize);
                int min;
                if (OnExternalStore) min = 4;
                else min = 0;
                int minL;
                if (OnLokalStore) minL = 4;
                else minL = 0;

                SchoolDatabase db = new SchoolDatabase();
                db.Connect();
                if (manu != "Všichni výrobci")
                {
                    SqlCommand command = db.CreateCommand(SQL_SELECT_BY_DETAIL_SIZE);
                    command.Parameters.Add(new SqlParameter("@p_Size", SqlDbType.Int));
                    command.Parameters["@p_Size"].Value = size;
                    command.Parameters.Add(new SqlParameter("@p_Season", SqlDbType.Char, 1));
                    command.Parameters["@p_Season"].Value = season;
                    command.Parameters.Add(new SqlParameter("@p_OnExternalStore", SqlDbType.Int));
                    command.Parameters["@p_OnExternalStore"].Value = min;
                    command.Parameters.Add(new SqlParameter("@p_OnLocalStore", SqlDbType.Int));
                    command.Parameters["@p_OnLocalStore"].Value = minL;
                    command.Parameters.Add(new SqlParameter("@p_manu", SqlDbType.VarChar, 10));
                    command.Parameters["@p_manu"].Value = manu;

                    SqlDataReader reader = db.Select(command);

                    List<OkPneuTire> tires = Read(reader);
                    reader.Close();
                    db.Close();
                    return tires;
                }
                else
                {

                    SqlCommand command = db.CreateCommand(SQL_SELECT_BY_DETAIL_SIZE_WITHOUT_MANU);
                    command.Parameters.Add(new SqlParameter("@p_Size", SqlDbType.Int));
                    command.Parameters["@p_Size"].Value = size;
                    command.Parameters.Add(new SqlParameter("@p_Season", SqlDbType.Char, 1));
                    command.Parameters["@p_Season"].Value = season;
                    command.Parameters.Add(new SqlParameter("@p_OnExternalStore", SqlDbType.Int));
                    command.Parameters["@p_OnExternalStore"].Value = min;
                    command.Parameters.Add(new SqlParameter("@p_OnLocalStore", SqlDbType.Int));
                    command.Parameters["@p_OnLocalStore"].Value = minL;

                    SqlDataReader reader = db.Select(command);

                    List<OkPneuTire> tires = Read(reader);
                    reader.Close();
                    db.Close();
                    return tires;
                }

            }
            else return null;
        }
Пример #27
0
 public int Update(Customer cust)
 {
     SchoolDatabase db = new SchoolDatabase();
     db.Connect();
     SqlCommand command = db.CreateCommand(SQL_UPDATE);
     PrepareCommand(command, cust);
     int ret = db.ExecuteNonQuery(command);
     db.Close();
     return ret;
 }
Пример #28
0
 public StudentsController(SchoolDatabase db)
 {
     _db = db;
 }
        public void Setup()
        {
            schoolDatabase = new SchoolDatabase();

            studentMock = Substitute.For <Student>();
        }
Пример #30
0
        public List<Contract> Select()
        {
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_SELECT);

            SqlDataReader reader = db.Select(command);

            List<Contract> emp = Read(reader);
            reader.Close();
            db.Close();
            return emp;
        }
Пример #31
0
        private bool FindCustomerByEmail(string email)
        {
            int tmp;
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_CUSTOMER_EXISTS);
            command.Parameters.Add(new SqlParameter("@p_email", SqlDbType.VarChar, 50));
            command.Parameters["@p_email"].Value = email;
            SqlDataReader reader = db.Select(command);
            reader.Read();
            tmp = reader.GetInt32(0);
            reader.Close();
            db.Close();
            if (tmp > 0) return true;
            else return false;
        }
Пример #32
0
        public List<Customer> Select(string lname)
        {
            string tmp = lname + '%';
            SchoolDatabase db = new SchoolDatabase();
            db.Connect();

            SqlCommand command = db.CreateCommand(SQL_SELECT);
            command.Parameters.Add(new SqlParameter("@p_lname", SqlDbType.VarChar, 20));
            command.Parameters["@p_lname"].Value = tmp;

            SqlDataReader reader = db.Select(command);

            List<Customer> cust = Read(reader);
            reader.Close();
            db.Close();
            return cust;
        }
Пример #33
0
 public TeacherController(SchoolDatabase db)
 {
     _db = db;
 }
 public StudentController(SchoolDatabase dbContext)
 {
     _dbContext = dbContext;
 }