Example #1
0
        public EmergentOrder QueryEmergentOrder(decimal id, OrderIdType orderIdType)
        {
            string        sql    = "SELECT Id,[Type],Content,[Time],Account,OrderIdType FROM T_EmergentOrder WHERE Id=@Id AND OrderIdType =@OrderIdType";
            EmergentOrder result = null;

            using (DbOperator dboperator = new DbOperator(Provider, ConnectionString))
            {
                dboperator.AddParameter("Id", id);
                dboperator.AddParameter("OrderIdType", orderIdType);
                using (System.Data.Common.DbDataReader reader = dboperator.ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        result                  = new EmergentOrder();
                        result.Id               = reader.GetDecimal(0);
                        result.Type             = (OrderStatus)reader.GetInt32(1);
                        result.Content          = reader.GetString(2);
                        result.Time             = reader.GetDateTime(3);
                        result.Account          = reader.GetString(4);
                        result.OrderIdTypeValue = (OrderIdType)reader.GetByte(5);
                    }
                }
            }
            return(result);
        }
Example #2
0
        public SignalProp getCurSigProp()
        {
            SignalProp   prop = null;
            String       sql  = " SELECT s.lampId, s.signalName, s.type, s.state, c.state as specState, direction, dir_to, s.ip FROM cursignal c LEFT JOIN signal s ON c.lampId=s.lampId AND c.type=1 ";
            MySqlCommand cmd  = new MySql.Data.MySqlClient.MySqlCommand(sql, myConn);

            System.Data.Common.DbDataReader reader = cmd.ExecuteReader();
            try
            {
                if (reader.Read())
                {
                    prop            = new SignalProp();
                    prop.SignalID   = reader.GetString(0).ToUpper();
                    prop.SignalName = DBStringToNormal(reader.GetString(1));
                    prop.Type       = reader.IsDBNull(2)? (byte)0 : (byte)reader.GetInt16(2);
                    prop.State      = reader.GetString(3);
                    prop.SpecState  = reader.IsDBNull(4) ? (byte)0 : (byte)reader.GetInt16(4);
                    prop.DirFrom    = reader.IsDBNull(5) ? (byte)0 : (byte)reader.GetInt16(5);
                    prop.DirTo      = reader.IsDBNull(6) ? (byte)0 : (byte)reader.GetInt16(6);
                    prop.Ip         = reader.GetString(7);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                reader.Close();
                Trace.TraceError("get cur signal prop " + e.StackTrace);
            }

            return(prop);
        }
Example #3
0
        public void frun()
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(""))
                {
                    connection.ConnectionString = @"Data Source=192.168.56.101,1433\SQLEXPRESS;Initial Catalog=mybase;Persist Security Info=True;User ID=User01;Password=User001";

                    connection.Open();
                    string text = "SELECT users.name, users.login, users.password, users.isadmin, users.id FROM users where users.id=" + this.id.ToString();
                    using (SqlCommand command = new SqlCommand(text, connection))
                        using (System.Data.Common.DbDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                reader.Read();
                                textBox1.Text = reader.GetString(0);
                                textBox2.Text = reader.GetString(1);
                                textBox3.Text = reader.GetString(2);
                                int i = reader.GetInt32(3);
                                textBox4.Text = "Нет";
                                if (i == 1)
                                {
                                    textBox4.Text = "Да";
                                }
                            }
                        }
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка работы с базой данных " + ex);
            }
        }
Example #4
0
        private async void ReadCommands()
        {
            try
            {
                MySqlCommand readCommands = new MySqlCommand("SELECT command,target,status FROM COMMANDS WHERE target = '" + ProgramOptions.LoggedInUser.Nick + "' AND status = 'start' LIMIT 1;", DataReaderMySQLConnection);
                System.Data.Common.DbDataReader reader = await readCommands.ExecuteReaderAsync();

                while ((isReadingCommands = await reader.ReadAsync()) == true)
                {
                    if (reader.GetString(2) == "start" && (reader.GetString(0) == "kicked" || reader.GetString(0) == "banned"))
                    {
                        MySqlCommand updateCommand = new MySqlCommand("START TRANSACTION; UPDATE COMMANDS SET status = 'finished' WHERE target = '" + ProgramOptions.LoggedInUser.Nick + "'; COMMIT; ", DataManipulationMySQLConnection);
                        await updateCommand.ExecuteNonQueryAsync();

                        MessageBox.Show("You were " + reader.GetString(0) + " from the server!");
                        this.Close();
                    }
                }
                reader.Close();
            }
            catch (Exception mysqlException)
            {
                if (mysqlException is MySqlException)
                {
                    System.Diagnostics.Debug.WriteLine("Exception thrown in ReadCommandsAsync; Not harmful; " + mysqlException.ToString());
                }
            }
        }
Example #5
0
        public static MobileDeviceCC getMobileDeviceCC(System.Data.Common.DbDataReader reader)
        {
            MobileDeviceCC mobileDeviceCC = new MobileDeviceCC();

            mobileDeviceCC.MD_ = reader.GetString(reader.GetOrdinal("MD#"));
            mobileDeviceCC.CC  = reader.GetString(reader.GetOrdinal("CC"));

            return(mobileDeviceCC);
        }
Example #6
0
        public static Manufacture getManufacture(System.Data.Common.DbDataReader reader)
        {
            Manufacture manufacture = new Manufacture();

            manufacture.ManuName = reader.GetString(reader.GetOrdinal("ManuName"));
            manufacture.ManuURL  = reader.GetString(reader.GetOrdinal("ManuURL"));

            return(manufacture);
        }
Example #7
0
 private static ListedAccount ReadAccount(System.Data.Common.DbDataReader reader)
 {
     return(new ListedAccount()
     {
         ProtectionId = reader.GetInt64("protection"),
         AccountName = reader.GetString("account"),
         Reason = reader.GetString("reason")
     });
 }
Example #8
0
        public static MobileDeviceOther getMobileDeviceOther(System.Data.Common.DbDataReader reader)
        {
            MobileDeviceOther mobileDeviceOther = new MobileDeviceOther();

            mobileDeviceOther.MD_   = reader.GetString(reader.GetOrdinal("MD#"));
            mobileDeviceOther.Other = reader.GetString(reader.GetOrdinal("Other"));

            return(mobileDeviceOther);
        }
Example #9
0
        public static MobileDeviceMutimedia getMobileDeviceMutimedia(System.Data.Common.DbDataReader reader)
        {
            MobileDeviceMutimedia mobileDeviceMutimedia = new MobileDeviceMutimedia();

            mobileDeviceMutimedia.MD_       = reader.GetString(reader.GetOrdinal("MD#"));
            mobileDeviceMutimedia.Mutimedia = reader.GetString(reader.GetOrdinal("Mutimedia"));

            return(mobileDeviceMutimedia);
        }
Example #10
0
        public static SMD getSMD(System.Data.Common.DbDataReader reader)
        {
            SMD SMD = new SMD();

            SMD.StoreName = reader.GetString(reader.GetOrdinal("StoreName"));
            SMD.MD_       = reader.GetString(reader.GetOrdinal("MD#"));
            SMD.SMDURL    = reader.GetString(reader.GetOrdinal("SMDURL"));
            SMD.SMDPrice  = reader.GetInt32(reader.GetOrdinal("SMDPrice"));

            return(SMD);
        }
Example #11
0
        public static MobileDeviceReview getMobileDeviceReview(System.Data.Common.DbDataReader reader)
        {
            MobileDeviceReview mobileDeviceReview = new MobileDeviceReview();

            mobileDeviceReview.MD_            = reader.GetString(reader.GetOrdinal("MD#"));
            mobileDeviceReview.ReviewURL      = reader.GetString(reader.GetOrdinal("ReviewURL"));
            mobileDeviceReview.ReviewType     = reader.GetString(reader.GetOrdinal("ReviewType"));
            mobileDeviceReview.ReviewName     = reader.GetString(reader.GetOrdinal("ReviewName"));
            mobileDeviceReview.ReviewMainSite = reader.GetString(reader.GetOrdinal("ReviewMainSite"));

            return(mobileDeviceReview);
        }
Example #12
0
        private async void ReadOnlineUsers()
        {
            try
            {
                MySqlCommand readOnlineUsers           = new MySqlCommand("SELECT ONLINE_USERS.nick, ONLINE_USERS.status, ACCOUNTS.privileges, ACCOUNTS.login FROM ONLINE_USERS LEFT JOIN ACCOUNTS ON ONLINE_USERS.Nick = ACCOUNTS.Nick WHERE ONLINE_USERS.status != 'Offline';", DataReaderMySQLConnection);
                System.Data.Common.DbDataReader reader = await readOnlineUsers.ExecuteReaderAsync();

                List <Users> temporaryUsers = new List <Users> {
                };
                while ((isReadingUsers = await reader.ReadAsync()) == true)
                {
                    switch (reader.GetString(2))
                    {
                    case "administrator":
                        temporaryUsers.Add(new Administrator(reader.GetString(0), reader.GetString(1)));
                        if (reader.GetString(0) == ProgramOptions.LoggedInUser.Nick && !(ProgramOptions.LoggedInUser is Administrator))
                        {
                            ProgramOptions.LoggedInUser = new Administrator(ProgramOptions.LoggedInUser.Nick, ProgramOptions.LoggedInUser.Status, reader.GetString(3));
                        }
                        break;

                    case "moderator":
                        temporaryUsers.Add(new Moderator(reader.GetString(0), reader.GetString(1)));
                        if (reader.GetString(0) == ProgramOptions.LoggedInUser.Nick && !(ProgramOptions.LoggedInUser is Moderator))
                        {
                            ProgramOptions.LoggedInUser = new Moderator(ProgramOptions.LoggedInUser.Nick, ProgramOptions.LoggedInUser.Status, reader.GetString(3));
                        }
                        break;

                    default:
                        temporaryUsers.Add(new User(reader.GetString(0), reader.GetString(1)));
                        if (reader.GetString(0) == ProgramOptions.LoggedInUser.Nick && !(ProgramOptions.LoggedInUser is User))
                        {
                            ProgramOptions.LoggedInUser = new User(ProgramOptions.LoggedInUser.Nick, ProgramOptions.LoggedInUser.Status, reader.GetString(3));
                        }
                        break;
                    }
                }
                if (temporaryUsers != onlineUsers)
                {
                    onlineUsers = temporaryUsers;
                }
                reader.Close();
                loggedInUsersList.ItemsSource = onlineUsers;
            }
            catch (Exception mysqlException)
            {
                if (mysqlException is MySqlException)
                {
                    System.Diagnostics.Debug.WriteLine("Exception thrown in ReadOnlineUsersAsync; Not harmful; " + mysqlException.ToString());
                }
            }
        }
Example #13
0
        private void DoSearch()
        {
            try
            {
                _searching = true;
                _isStop    = false;
                SetRecordText(null, txtRecord);

                string sql = "select Count(*) from c2lp_optRecord " + _where;
                int    sum = Convert.ToInt32(BaseServer._SqlHelp.ExecuteScalar(sql, CommandType.Text));
                if (sum == 0)
                {
                    MessageBox.Show("没有查到符合条件的相关记录!");
                    return;
                }
                SetRecordText("共查到" + sum + "条记录.", txtRecord);
                sql = sql.Replace("Count(*)", "optTime,optNumber,optType,optCustomerId") + " order by optTime desc ,optTypeId,optCustomerId";
                using (System.Data.Common.DbDataReader r = BaseServer._SqlHelp.ExecuteReader(sql, CommandType.Text))
                {
                    while (r.Read())
                    {
                        if (_isStop)
                        {
                            SetRecordText("已手动停止显示剩余记录.", txtRecord);
                            break;
                        }
                        DateTime optTime       = r.GetDateTime(0);
                        string   optNumber     = r.GetString(1);
                        string   optType       = r.GetString(2);
                        int      optCustomerId = r.GetInt32(3);
                        string   optCustomer   = "";
                        if (_dicConsignor.ContainsKey(optCustomerId))
                        {
                            optCustomer = _dicConsignor[optCustomerId];
                        }
                        SetRecordText(string.Format("{0} {1} {2} {3}", optTime.ToString("MM-dd HH:mm:ss"), optNumber, optType, optCustomer), txtRecord);
                    }
                }
            }
            catch (Exception ex)
            {
                SetRecordText(ex.Message, txtRecord);
            }
            finally
            {
                _searching = false;
                SetRecordText("查询完毕.", txtRecord);
                SetRecordText("CNM", btnSearch);
            }
        }
Example #14
0
        private static void QueryEmployee(Oracle.DataAccess.Client.OracleConnection conn)
        {
            string sql = "Select Emp_Id, Emp_No, Emp_Name, Mng_Id from Employee";

            // Tạo một đối tượng Command.
            Oracle.DataAccess.Client.OracleCommand cmd = new Oracle.DataAccess.Client.OracleCommand();

            // Liên hợp Command với Connection.
            cmd.Connection  = conn;
            cmd.CommandText = sql;


            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        // Chỉ số (index) của cột Emp_ID trong câu lệnh SQL.
                        int empIdIndex = reader.GetOrdinal("Emp_Id"); // 0


                        long empId = Convert.ToInt64(reader.GetValue(0));

                        // Chỉ số của cột Emp_No là 1.
                        string empNo        = reader.GetString(1);
                        int    empNameIndex = reader.GetOrdinal("Emp_Name");// 2
                        string empName      = reader.GetString(empNameIndex);


                        int mngIdIndex = reader.GetOrdinal("Mng_Id");

                        long?mngId = null;

                        if (!reader.IsDBNull(mngIdIndex))
                        {
                            mngId = Convert.ToInt64(reader.GetValue(mngIdIndex));
                        }
                        Console.WriteLine("--------------------");
                        Console.WriteLine("empIdIndex:" + empIdIndex);
                        Console.WriteLine("EmpId:" + empId);
                        Console.WriteLine("EmpNo:" + empNo);
                        Console.WriteLine("EmpName:" + empName);
                        Console.WriteLine("MngId:" + mngId);
                    }
                }
            }
        }
Example #15
0
        public Models.User GetId(int P_ID)
        {
            Models.User ret    = new Models.User();
            BdUtil      bdUtil = new BdUtil();

            System.Data.Common.DbDataReader rs = bdUtil.Qry("select ID,NAME,AGE,ADDRESS from USERS where ID = " + P_ID, null);
            while (rs.Read())
            {
                ret.Id      = rs.GetInt32(0);
                ret.Name    = rs.GetString(1);
                ret.Age     = rs.GetInt32(2);
                ret.Address = rs.GetString(3);
            }

            return(ret);
        }
        public User GetUserSourceInfo(int user_id)
        {
            User us = new User();

            string sql = $"SELECT users.id, users.name, sources.id, upload_time FROM users,sources WHERE sources.user_id=users.id AND users.id={user_id} AND used=1 AND sources.status='ok'";

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = myConnection;
            cmd.CommandText = sql;

            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        us.id   = reader.GetInt16(0);
                        us.name = reader.GetString(1);
                        us.compiledAndUsedSourceId = reader.GetInt16(3);
                        us.last_upload_time        = reader.GetInt16(4);
                    }
                }
            }
            return(us);
        }
Example #17
0
        public DataTransferObject.Organization.WithholdingView GetWithholding(WithholdingAccountType accountType, Guid company)
        {
            DataTransferObject.Organization.WithholdingView withholding = null;
            //[AccountNo] = @AccountNo AND
            string sql = "SELECT [AccountNo],[AccountType],[Time],[Status],[Amount],[Company] FROM [T_Withholding] WHERE [AccountType]=@AccountType AND [Company] = @Company ";

            using (DbOperator dbOperator = new DbOperator(Provider, ConnectionString)) {
                //dbOperator.AddParameter("AccountNo", withholdingView.AccountNo);
                dbOperator.AddParameter("AccountType", accountType);
                dbOperator.AddParameter("Company", company);
                using (System.Data.Common.DbDataReader reader = dbOperator.ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        withholding             = new DataTransferObject.Organization.WithholdingView();
                        withholding.AccountNo   = reader.GetString(0);
                        withholding.AccountType = (WithholdingAccountType)reader.GetByte(1);
                        withholding.Time        = reader.GetDateTime(2);
                        withholding.Status      = (WithholdingProtocolStatus)reader.GetByte(3);
                        withholding.Amount      = reader.GetDecimal(4);
                        withholding.Company     = reader.GetGuid(5);
                    }
                }
            }
            return(withholding);
        }
Example #18
0
        public Dictionary <string, string> QueryAccountNames(IEnumerable <string> accounts)
        {
            string sql    = string.Format("select [login],name from T_Employee where [Login] in ('{0}');", string.Join("','", accounts));
            var    result = new Dictionary <string, string>();

            using (DbOperator dboperator = new DbOperator(Provider, ConnectionString))
            {
                using (System.Data.Common.DbDataReader reader = dboperator.ExecuteReader(sql))
                {
                    while (reader.Read())
                    {
                        result.Add(reader.GetString(0), reader.GetString(1));
                    }
                }
            }
            return(result);
        }
Example #19
0
 public static string SafeGetString(this System.Data.Common.DbDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
     {
         return(reader.GetString(colIndex));
     }
     return(string.Empty);
 }
Example #20
0
        private static DBSerie ExtractDataFromDataReader(System.Data.Common.DbDataReader result)
        {
            DBSerie dbSerie = new DBSerie();

            dbSerie.ID   = result.GetInt32(0);
            dbSerie.Name = result.GetString(1);
            if (!string.IsNullOrEmpty(result.GetValue(2).ToString()) && !string.IsNullOrWhiteSpace(result.GetValue(2).ToString()))
            {
                dbSerie.Image = ReadToEnd(result.GetStream(2));
            }
            dbSerie.Extension = result.GetString(3);
            if (!string.IsNullOrEmpty(result.GetValue(4).ToString()) && !string.IsNullOrWhiteSpace(result.GetValue(4).ToString()))
            {
                dbSerie.ParentID = result.GetInt32(4);
            }
            return(dbSerie);
        }
Example #21
0
 public void MapProperties(System.Data.Common.DbDataReader dr)
 {
     ID              = dr.GetLong("ID");
     Invoice_ID      = dr.GetString("Invoice_ID");
     Payment_Type    = (DepositType)dr.GetByte("Payment_Type");
     Detail          = dr.GetString("Detail");
     Payment         = dr.GetDouble("Payment");
     Total_Payment   = dr.GetDouble("Total_Payment");
     Balance         = dr.GetDouble("Balance");
     Created_By      = dr.GetLong("Created_By");
     Updated_By      = dr.GetLong("Updated_By");
     Created_Date    = dr.GetDateTime("Created_Date");
     Updated_Date    = dr.GetDateTime("Updated_Date");
     Organization_ID = dr.GetLong("Organization_ID");
     IsActive        = dr.GetBoolean("IsActive");
     IsDeleted       = dr.GetBoolean("IsDeleted");
 }
Example #22
0
        public static GPU getGPU(System.Data.Common.DbDataReader reader)
        {
            GPU GPU = new GPU();

            GPU.GPU_         = reader.GetString(reader.GetOrdinal("GPU#"));
            GPU.ManuName     = reader.GetString(reader.GetOrdinal("ManuName"));
            GPU.GPUName      = reader.GetString(reader.GetOrdinal("GPUName"));
            GPU.Cores        = reader.GetString(reader.GetOrdinal("Cores"));
            GPU.BaseClock    = reader.GetString(reader.GetOrdinal("BaseClock"));
            GPU.BoostClock   = reader.GetString(reader.GetOrdinal("BoostClock"));
            GPU.MemorySpeed  = reader.GetString(reader.GetOrdinal("MemorySpeed"));
            GPU.MemoryConfig = reader.GetString(reader.GetOrdinal("MemoryConfig"));
            GPU.PowerDraw    = reader.GetString(reader.GetOrdinal("PowerDraw"));

            return(GPU);
        }
Example #23
0
        public static x86CPU getX86CPU(System.Data.Common.DbDataReader reader)
        {
            x86CPU x86CPU = new x86CPU();

            x86CPU.CpuName    = reader.GetString(reader.GetOrdinal("CpuName"));
            x86CPU.ManuName   = reader.GetString(reader.GetOrdinal("ManuName"));
            x86CPU.CAndT      = reader.GetString(reader.GetOrdinal("CAndT"));
            x86CPU.BaseClock  = reader.GetString(reader.GetOrdinal("BaseClock"));
            x86CPU.TurboClock = reader.GetString(reader.GetOrdinal("TurboClock"));
            x86CPU.TDP        = reader.GetString(reader.GetOrdinal("TDP"));
            x86CPU.Graphics   = reader.GetString(reader.GetOrdinal("Graphics"));
            x86CPU.Cache      = reader.GetString(reader.GetOrdinal("Cache"));

            return(x86CPU);
        }
Example #24
0
        public static LapTop getLapTop(System.Data.Common.DbDataReader reader)
        {
            LapTop laptop = new LapTop();

            laptop.MD_         = reader.GetString(reader.GetOrdinal("MD#"));
            laptop.CDPlayer    = reader.GetString(reader.GetOrdinal("CDPlayer"));
            laptop.Adapter     = reader.GetString(reader.GetOrdinal("Adapter"));
            laptop.Port        = reader.GetString(reader.GetOrdinal("Port"));
            laptop.Webcam      = reader.GetString(reader.GetOrdinal("Webcam"));
            laptop.CpuName     = reader.GetString(reader.GetOrdinal("CpuName"));
            laptop.CPUManuName = reader.GetString(reader.GetOrdinal("CPUManuName"));
            laptop.InPort      = reader.GetString(reader.GetOrdinal("InPort"));

            return(laptop);
        }
Example #25
0
 private static Domain.IncomeGroupLimitGroup loadIncomeGroup(System.Data.Common.DbDataReader reader)
 {
     Domain.IncomeGroupLimitGroup income = new Domain.IncomeGroupLimitGroup();
     income.Limitation = new List <Domain.IncomeGroupLimit>();
     Domain.IncomeGroupLimit limit = null;
     while (reader.Read())
     {
         var currentId = reader.GetGuid(0);
         if (income.Id != currentId)
         {
             income.Id            = currentId;
             income.CompanyId     = reader.GetGuid(1);
             income.IncomeGroupId = reader.IsDBNull(2) ? (Guid?)null : reader.GetGuid(2);
             income.Remark        = reader.GetString(3);
             income.Limitation    = new List <Domain.IncomeGroupLimit>();
         }
         var currlimitId = reader.GetGuid(4);
         if (!income.Limitation.Any(it => it.Id == currlimitId))
         {
             limit               = new Domain.IncomeGroupLimit();
             limit.Id            = currlimitId;
             limit.IncomeId      = reader.GetGuid(5);
             limit.Type          = (Common.Enums.PeriodType)reader.GetByte(6);
             limit.Price         = reader.GetInt32(7);
             limit.Airlines      = reader.GetString(12);
             limit.IsOwnerPolicy = reader.GetBoolean(13);
             limit.Period        = new List <Domain.IncomeGroupPeriod>();
             income.Limitation.Add(limit);
         }
         Domain.IncomeGroupPeriod period = new Domain.IncomeGroupPeriod();
         period.DeductId    = reader.GetGuid(8);
         period.StartPeriod = reader.GetDecimal(9);
         period.EndPeriod   = reader.GetDecimal(10);
         period.Period      = reader.GetDecimal(11);
         limit.Period.Add(period);
     }
     return(income);
 }
Example #26
0
        public EmergentOrder QueryEmergentOrder(decimal id, DataTransferObject.Order.OrderStatus status)
        {
            EmergentOrder emergentOrder = new EmergentOrder();
            string        sql           = "select Id,[Type],Content,[Time],Account from T_EmergentOrder WHERE Id =@Id AND [Type] = @Type";

            using (DbOperator dboperator = new DbOperator(Provider, ConnectionString))
            {
                dboperator.AddParameter("Id", id);
                dboperator.AddParameter("Type", status);
                using (System.Data.Common.DbDataReader reader = dboperator.ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        emergentOrder.Id      = reader.GetDecimal(0);
                        emergentOrder.Type    = (DataTransferObject.Order.OrderStatus)reader.GetInt32(1);
                        emergentOrder.Content = reader.GetString(2);
                        emergentOrder.Time    = reader.GetDateTime(3);
                        emergentOrder.Account = reader.GetString(4);
                    }
                }
            }
            return(emergentOrder);
        }
Example #27
0
        public List <SignalProp> getSignalList()
        {
            List <SignalProp> list = new List <SignalProp>();

            String       sql = " SELECT lampId, signalName, type, ip  FROM signal WHERE type IN (1, 4, 5) ";
            MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, myConn);

            System.Data.Common.DbDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                SignalProp prop = new SignalProp();

                prop.SignalID   = reader.GetString(0).Trim().ToUpper(); //.Replace('-', '_')
                prop.SignalName = DBStringToNormal(reader.GetString(1).Trim());
                prop.Type       = reader.IsDBNull(2) ? (byte)1 : (byte)reader.GetInt32(2);
                prop.Ip         = reader.IsDBNull(3) ? "" : reader.GetString(3).Trim();

                list.Add(prop);
            }
            reader.Close();

            return(list);
        }
Example #28
0
        public List <Models.User> GetAll()
        {
            List <Models.User> ret    = new List <Models.User>();
            BdUtil             bdUtil = new BdUtil();

            System.Data.Common.DbDataReader rs = bdUtil.Qry("select ID,NAME,AGE,ADDRESS from USERS order by NAME", null);
            while (rs.Read())
            {
                ret.Add(new Models.User {
                    Id = rs.GetInt32(0), Name = rs.GetString(1), Age = rs.GetInt32(2), Address = rs.GetString(3)
                });
            }

            return(ret);
        }
Example #29
0
        public List <Models.User> GetName(Models.Search P_NAME)
        {
            List <Models.User> ret    = new List <Models.User>();
            BdUtil             bdUtil = new BdUtil();

            System.Data.Common.DbDataReader rs = bdUtil.Qry("select ID,NAME,AGE,ADDRESS from USERS where upper(name) like '%" + P_NAME.Name.ToUpperInvariant() + "%' order by NAME", null);
            while (rs.Read())
            {
                ret.Add(new Models.User {
                    Id = rs.GetInt32(0), Name = rs.GetString(1), Age = rs.GetInt32(2), Address = rs.GetString(3)
                });
            }

            return(ret);
        }
Example #30
0
        private static DBFichier ExtractDataFromDataReader(System.Data.Common.DbDataReader result)
        {
            DBFichier dBFichier = new DBFichier();

            dBFichier.ID   = result.GetInt32(0);
            dBFichier.Name = result.GetString(1);
            if (!string.IsNullOrEmpty(result.GetValue(2).ToString()) && !string.IsNullOrWhiteSpace(result.GetValue(2).ToString()))
            {
                dBFichier.Order = result.GetInt32(2);
            }
            if (!string.IsNullOrEmpty(result.GetValue(3).ToString()) && !string.IsNullOrWhiteSpace(result.GetValue(3).ToString()))
            {
                dBFichier.Image = ReadToEnd(result.GetStream(3));
            }
            if (!string.IsNullOrEmpty(result.GetValue(4).ToString()) && !string.IsNullOrWhiteSpace(result.GetValue(4).ToString()))
            {
                dBFichier.ParentID = result.GetInt32(4);
            }
            if (!string.IsNullOrEmpty(result.GetValue(5).ToString()) && !string.IsNullOrWhiteSpace(result.GetValue(5).ToString()))
            {
                dBFichier.Collection = result.GetString(5);
            }
            return(dBFichier);
        }