コード例 #1
0
        public IEnumerable <Semester> Handle()
        {
            string query = "sp_GetActiveStudentDetails";
            IEnumerable <Semester> students = sqlQueryExecutor.Execute(query, GetDetails);

            return(students);
        }
コード例 #2
0
        public Professor Handle(ProfessorByIdQuery query)
        {
            string spQuery = "sp_GetProfessorDetails";

            professorIdParameter = new SqlParameter("@professorId", query.Id);

            Professor professor = sqlQueryExecutor.Execute(spQuery, Get);

            return(professor);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: cuongls/PSTNReadLog
        public DataTable GetDMVeTinh(string dlu, string host)
        {
            string sql = String.Format("SELECT * FROM QuanLyVT WHERE UR = '{0}' AND Host = '{1}'", dlu, host);

            sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass);
            DataTable lsAlarm = new DataTable();

            lsAlarm = sqlQueryExecutor.Execute(sql);
            return(lsAlarm);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: cuongls/PSTNReadLog
        public DataTable GetMaxTimeEvent(string host)
        {
            string sql = "SELECT MAX(DateEvent) AS MAXDATE FROM ALARM WHERE HOST = '" + host + "'";

            sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass);
            DataTable result = new DataTable();

            result = sqlQueryExecutor.Execute(sql);
            return(result);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: cuongls/PSTNReadLog
        public DataTable GetDMAlarm(string maAlarm, string host, string loai)
        {
            string sql = String.Format("SELECT * FROM DM_ALARM WHERE MaAlarm = '{0}' AND HOST = '{1}' AND Loai = '{2}'",
                                       maAlarm, host, loai);

            sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass);
            DataTable lsAlarm = new DataTable();

            lsAlarm = sqlQueryExecutor.Execute(sql);
            return(lsAlarm);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: cuongls/PSTNReadLog
        public DataTable GetAlarmBeginCCSM(ALARM alarm)
        {
            string sql = String.Format("SELECT * FROM PSTNAlarmTapTrung WHERE NAlarm like '{0}%' AND TrangThaiEnd = 0 ORDER BY MaSend desc",
                                       alarm.HOST + "_" + alarm.DLU + "_" + alarm.ERL + "_");

            sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass);
            DataTable lsAlarm = new DataTable();

            lsAlarm = sqlQueryExecutor.Execute(sql);
            return(lsAlarm);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: cuongls/PSTNReadLog
        public DataTable GetAlarmBegin(ALARM alarm)
        {
            string sql = String.Format("SELECT * FROM ALARM WHERE DLU = '{0}' AND ERL = '{1}' AND HOST = '{2}' AND IsSuccess = 0 ORDER BY ID desc",
                                       alarm.DLU, alarm.ERL, alarm.HOST);

            sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass);
            DataTable lsAlarm = new DataTable();

            lsAlarm = sqlQueryExecutor.Execute(sql);
            return(lsAlarm);
        }
コード例 #8
0
        public IEnumerable <TEntity> Handle(AllEntitiesQuery <TEntity> query)
        {
            string sqlQuery = $@"SELECT * FROM {query.Table} WHERE IsDeleted = @withDeleted";

            sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@withDeleted", $"{query.WithDeleted}")
            };

            IEnumerable <TEntity> entities = sqlQueryExecutor.Execute(sqlQuery, GetAll);

            return(entities);
        }
コード例 #9
0
        public TEntity Handle(EntityByIdQuery <TEntity> query)
        {
            string sqlQuery = $@"SELECT * FROM {query.Table} WHERE Id = @id";

            sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@id", $"{query.Id}")
            };

            TEntity entity = sqlQueryExecutor.Execute(sqlQuery, GetById);

            return(entity);
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: cuongls/PSTNReadLog
        public void LoadDLUCombobox(string host)
        {
            string sql = String.Format("SELECT UR, TenVT FROM QuanLyVT WHERE Host = '{0}' UNION SELECT 0 MaDLU, N'Tất cả' Name", host);

            sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass);
            DataTable dt = new DataTable();

            dt = sqlQueryExecutor.Execute(sql);


            cbDLU.ValueMember = "UR";

            cbDLU.DisplayMember = "TenVT";

            cbDLU.DataSource = dt;
        }
コード例 #11
0
        public bool Handle(DeleteEntityCommand command)
        {
            string query = $@"UPDATE {command.Table}
                            SET IsDeleted = @isDeleted, DeletedOn = @deletedOn
                            WHERE Id = @id";

            sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@id", command.Id),
                new SqlParameter("@isDeleted", true),
                new SqlParameter("@deletedOn", DateTime.UtcNow)
            };

            bool isDeleted = sqlQueryExecutor.Execute(query, Delete);

            return(isDeleted);
        }
コード例 #12
0
        public bool Handle(UpdateEntityCommand command)
        {
            string setQuery = string.Join(", ", command.Columns.Keys.Select(x => x + " = @" + x));

            string query = $@"UPDATE {command.Table}
                            SET {setQuery}
                            WHERE Id = @id";

            sqlParameters = new List <SqlParameter>();
            sqlParameters.Add(new SqlParameter("@id", command.Id));

            foreach (var column in command.Columns)
            {
                sqlParameters.Add(new SqlParameter($"@{column.Key}", column.Value));
            }

            bool isUpdated = sqlQueryExecutor.Execute(query, Update);

            return(isUpdated);
        }
コード例 #13
0
        public int Handle(EntityCommand command)
        {
            string columnKeys      = string.Join(", ", command.Columns.Keys);
            string columnVariables = string.Join(", ", command.Columns.Keys.Select(x => "@" + x));

            string query = $@"INSERT INTO {command.Table}({columnKeys})
                            OUTPUT INSERTED.ID
                            VALUES({columnVariables})";

            sqlParameters = new List <SqlParameter>();

            foreach (var column in command.Columns)
            {
                sqlParameters.Add(new SqlParameter($"@{column.Key}", column.Value));
            }

            int id = sqlQueryExecutor.Execute(query, Create);

            return(id);
        }