Beispiel #1
0
        public System.Collections.Generic.List <Category> GetAll()
        {
            System.Data.SqlClient.SqlCommand           cmd     = null;
            System.Data.SqlClient.SqlDataReader        SDR     = null;
            System.Collections.Generic.List <Category> ListTmp = new System.Collections.Generic.List <Category>();
            Category ObjTmp = null;
            DBCon    Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM CATEGORY WHERE Deleted=0 ORDER BY Category_ID DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new Category
                    {
                        Category_ID = SDR.GetInt32(0),
                        Name        = SDR.GetString(1),
                        Create_By   = SDR.GetInt32(2),
                        Create_Date = SDR.GetDateTime(3),
                        Update_By   = SDR.GetInt32(4),
                        Update_Date = SDR.GetDateTime(5),
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
Beispiel #2
0
        public System.Collections.Generic.List <DeliveryBoy> GetAll()
        {
            System.Data.SqlClient.SqlCommand              cmd     = null;
            System.Data.SqlClient.SqlDataReader           SDR     = null;
            System.Collections.Generic.List <DeliveryBoy> ListTmp = new System.Collections.Generic.List <DeliveryBoy>();
            DeliveryBoy ObjTmp = null;
            DBCon       Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM DELIVERYBOY WHERE Deleted=0 ORDER BY DBID DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new DeliveryBoy
                    {
                        DBID        = SDR.GetInt32(0),
                        Name        = SDR.GetString(1),
                        Mobile      = SDR.GetString(2),
                        Password    = SDR.GetString(3),
                        Create_Date = SDR.GetDateTime(4),
                        Create_By   = SDR.GetInt32(5),
                        Update_Date = SDR.GetDateTime(6),
                        Update_By   = SDR.GetInt32(7),
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
        public override DTOBase PopulateDTO(System.Data.SqlClient.SqlDataReader sqlReader)
        {
            StudentDTO studentDTO = new StudentDTO();

            studentDTO.isNew = false;

            if (!sqlReader.IsDBNull(this.m_IdOrdinal))
            {
                studentDTO.Id = sqlReader.GetInt32(this.m_IdOrdinal);
            }

            if (!sqlReader.IsDBNull(this.m_firstNameOrdinal))
            {
                studentDTO.firstName = sqlReader.GetString(this.m_firstNameOrdinal);
            }

            if (!sqlReader.IsDBNull(this.m_lastNameOrdinal))
            {
                studentDTO.lastName = sqlReader.GetString(this.m_lastNameOrdinal);
            }

            if (!sqlReader.IsDBNull(this.m_isDeletedOrdinal))
            {
                studentDTO.isDeleted = sqlReader.GetInt32(this.m_isDeletedOrdinal);
            }

            return(studentDTO);
        }
        public override void ParseFromDataReader(System.Data.SqlClient.SqlDataReader r)
        {
            ID     = r.GetGuid(0);
            TaskID = r.GetInt32(1);
            if (!r.IsDBNull(2))
            {
                Priority = (Priority)r.GetInt32(2);
            }
            else
            {
                Priority = null;
            }

            if (!r.IsDBNull(3))
            {
                ScheduleID = r.GetGuid(3);
            }
            else
            {
                ScheduleID = null;
            }

            if (!r.IsDBNull(4))
            {
                Inserted = r.GetDateTime(4);
            }
            else
            {
                Inserted = DT_NEVER;
            }

            if (!r.IsDBNull(5))
            {
                ServerID = r.GetInt32(5);
            }
            else
            {
                ServerID = null;
            }

            if (!r.IsDBNull(6))
            {
                LastUpdate = r.GetDateTime(6);
            }
            else
            {
                LastUpdate = DT_NEVER;
            }

            if (!r.IsDBNull(7))
            {
                ReturnCode = r.GetString(7);
            }
            else
            {
                ReturnCode = null;
            }

            Status = (TaskStatus)r.GetInt32(8);
        }
Beispiel #5
0
        public System.Collections.Generic.List <Users> GetAll()
        {
            System.Data.SqlClient.SqlCommand        cmd     = null;
            System.Data.SqlClient.SqlDataReader     SDR     = null;
            System.Collections.Generic.List <Users> ListTmp = new System.Collections.Generic.List <Users>();
            Users ObjTmp = null;
            DBCon Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM USERS WHERE Deleted=0 ORDER BY UID DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new Users
                    {
                        UID         = SDR.GetInt32(0),
                        User_Name   = SDR.GetString(1),
                        Password    = SDR.GetString(2),
                        User_Type   = SDR.GetString(3),
                        Create_By   = SDR.GetInt64(4),
                        Create_Date = SDR.GetDateTime(5),
                        Update_By   = SDR.GetInt64(6),
                        Update_Date = SDR.GetDateTime(7),
                        MESSID      = SDR.IsDBNull(9)? 0:SDR.GetInt32(9),
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
Beispiel #6
0
        /// <summary>
        /// Calls the "sp_GetStoreRevenue" stored procedure
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Revenues(int?id)
        {
            string connectionString = @"Data Source = (localdb)\MSSQLLocalDB; Initial Catalog = SimonsStore; Integrated Security = True; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";

            System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString);

            connection.Open();

            System.Data.SqlClient.SqlCommand command = connection.CreateCommand();
            command.CommandText = "sp_GetStoreRevenue";
            command.CommandType = System.Data.CommandType.StoredProcedure;

            System.Data.SqlClient.SqlParameter parameter = command.CreateParameter();
            parameter.Direction     = System.Data.ParameterDirection.Input;
            parameter.ParameterName = "@store";
            parameter.SqlDbType     = System.Data.SqlDbType.Int;
            parameter.SqlValue      = id;

            command.Parameters.Add(parameter);

            List <Models.ERPRevenueModel> revenues = new List <Models.ERPRevenueModel>();

            System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                Models.ERPRevenueModel revenue = new Models.ERPRevenueModel();
                revenue.Revenue = reader.GetDecimal(0);
                revenue.Date    = new DateTime(reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3));

                revenues.Add(revenue);
            }
            connection.Close();

            return(View(revenues));
        }
        public void GetEnderecoByIdEnd(int id)
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            //conexao.command.CommandText = "SELECT * FROM ENDERECO WHERE idEndereco = @IDENDERECO AND idEndereco = (SELECT idEndereco FROM Endereco_Cliente WHERE idCliente = @IDCLIENTE)";
            conexao.command.CommandText = "SELECT * FROM ENDERECO WHERE idEndereco = @IDENDERECO";
            conexao.command.Parameters.Clear();
            conexao.command.Parameters.Add("@IDENDERECO", SqlDbType.VarChar).Value = id;
            //conexao.command.Parameters.Add("@IDCLIENTE", SqlDbType.Int).Value = (int)HttpContext.Current.Session["idUsuario"];

            System.Data.SqlClient.SqlDataReader dr = conexao.command.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Id             = dr.GetInt32(0);
                    Cep            = dr.GetString(1);
                    Pais           = dr.GetString(2);
                    Estado         = dr.GetString(3);
                    Cidade         = dr.GetString(4);
                    Bairro         = dr.GetString(5);
                    Logradouro     = dr.GetString(6);
                    TipoLogradouro = dr.GetString(7);
                    Numero         = dr.GetInt32(8);
                    Complemento    = dr.GetString(9);
                }
            }

            dr.Close();
            conexao.connection.Close();
        }
        public static ushort LoginUser(string aID, ref string aPass, ref WorldMgr.player aPlayer, bool localConnect)
        {
            if (Helpers.Manager.clients.Count >= Helpers.Manager.maxSlots)
            {
                return(0); // crowded
            }
            DB ms = new DB("SELECT * FROM users WHERE id = '" + aID + "'");

            if (ms.Count() == 0)
            {
                ms.Close();
                return(1);
            }
            ms = new DB("SELECT * FROM users WHERE id = '" + aID + "' AND password='******'");
            if (ms.Count() == 0)
            {
                ms.Close();
                return(5);
            }
            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    if (reader.GetString(1).ToLower() == aID.ToLower()) // id
                    {
                        if (reader.GetByte(3) == 1)                     // online
                        {
                            ms.Close();
                            return(2); // already online
                        }

                        if (reader.GetInt32(5) == 1) // banned
                        {
                            aPass = reader.GetString(4);
                            ms.Close();
                            return(3); // banned
                        }

                        if (aPlayer == null && localConnect)
                        {
                            DB.query("UPDATE users SET online=1 WHERE userid='" + reader.GetInt32(0) + "'");
                        }
                        aPlayer             = new WorldMgr.player();
                        aPlayer.AccountName = aID;
                        aPlayer.Password    = aPass; // Nukei: ?? whats the reason for saving password in memory ?
                        aPlayer.ID          = reader.GetInt32(0);
                        aPlayer.pGold       = reader.GetInt64(7);
                        aPlayer.Silk        = reader.GetInt32(6);
                        aPlayer.SilkPrem    = reader.GetInt32(9);
                        aPlayer.wSlots      = reader.GetByte(11);
                        ms.Close();
                        return(4);
                    }
                }
            }
            ms.Close();
            return(6); // Bilinmeyen geri dönüş:Özel bir durum oluşmadı. (Mecburi Gönderim)
        }
Beispiel #9
0
        public TList_Barril Select(Utils.TpBusca[] vBusca, int vTop, string vNM_Campo)
        {
            TList_Barril lista         = new TList_Barril();
            bool         podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Barril reg = new TRegistro_Barril();
                    if (!reader.IsDBNull(reader.GetOrdinal("id_barril")))
                    {
                        reg.Id_barril = reader.GetInt32(reader.GetOrdinal("id_barril"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("nr_barril")))
                    {
                        reg.Nr_barril = reader.GetString(reader.GetOrdinal("nr_barril"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("volume")))
                    {
                        reg.Volume = reader.GetInt32(reader.GetOrdinal("volume"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cancelado")))
                    {
                        reg.Cancelado = reader.GetBoolean(reader.GetOrdinal("cancelado"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_produto")))
                    {
                        reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_produto")))
                    {
                        reg.Ds_produto = reader.GetString(reader.GetOrdinal("ds_produto"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    deletarBanco_Dados();
                }
            }
            return(lista);
        }
        public ScoreDAL ScoreFromReader(System.Data.SqlClient.SqlDataReader reader)
        {
            ScoreDAL ProposedReturnValue = new ScoreDAL();

            ProposedReturnValue.ScoreID  = reader.GetInt32(OffsetToScoreID);
            ProposedReturnValue.Score    = reader.GetInt32(OffsetToScore);
            ProposedReturnValue.UserID   = reader.GetInt32(OffsetToUserID);
            ProposedReturnValue.GameID   = reader.GetInt32(OffsetToGameID);
            ProposedReturnValue.UserName = reader.GetString(OffsetToUserName);
            ProposedReturnValue.GameName = reader.GetString(OffsetToGameName);
            return(ProposedReturnValue);
        }
Beispiel #11
0
        /////////////////////////////////////////////////////////////////////////////////
        // Login user
        /////////////////////////////////////////////////////////////////////////////////
        public static int LoginUser(string aID, ref string aPass, ref DarkEmu_GameServer.player aPlayer, bool localConnect)
        {
            //Console.WriteLine("Login User: {0} - {1}",aID,aPass);

            MsSQL ms = new MsSQL("SELECT * FROM users WHERE password='******'");

            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                if (Systems.clients.Count >= Systems.maxSlots)
                {
                    ms.Close();
                    return(2); // crowded
                }

                while (reader.Read())
                {
                    if (reader.GetString(1).ToLower() == aID.ToLower()) // id
                    {
                        if (reader.GetByte(3) == 1)                     // online
                        {
                            ms.Close();
                            return(3); // already online
                        }

                        if (reader.GetInt32(5) == 1) // banned
                        {
                            aPass = reader.GetString(4);
                            ms.Close();
                            return(4); // banned
                        }

                        if (aPlayer == null && localConnect)
                        {
                            MsSQL.UpdateData("UPDATE users SET online=1 WHERE userid='" + reader.GetInt32(0) + "'");
                        }
                        aPlayer             = new player();
                        aPlayer.AccountName = aID;
                        aPlayer.Password    = aPass; // Nukei: ?? whats the reason for saving password in memory ?
                        aPlayer.ID          = reader.GetInt32(0);
                        aPlayer.pGold       = reader.GetInt64(7);
                        aPlayer.Silk        = reader.GetInt32(6);
                        aPlayer.SilkPrem    = reader.GetInt32(9);
                        aPlayer.wSlots      = reader.GetByte(11);
                        ms.Close();
                        //Console.WriteLine("Login..!!");
                        return(0);
                    }
                }
            }
            ms.Close();
            return(1); // not found
        }
Beispiel #12
0
        public CommentDAL CommentFromReader(System.Data.SqlClient.SqlDataReader reader)
        {
            CommentDAL ProposedReturnValue = new CommentDAL();

            ProposedReturnValue.CommentID   = reader.GetInt32(OffsetToCommentID);
            ProposedReturnValue.GameComment = reader.GetString(OffsetToGameComment);
            ProposedReturnValue.UserID      = reader.GetInt32(OffsetToUserID);
            ProposedReturnValue.GameID      = reader.GetInt32(OffsetToGameID);
            ProposedReturnValue.Liked       = reader.GetBoolean(OffsetToLiked);
            ProposedReturnValue.GameName    = reader.GetString(OffsetToGameName);
            ProposedReturnValue.UserName    = reader.GetString(OffsetToUserName);
            return(ProposedReturnValue);
        }
Beispiel #13
0
        public UserDal UserFromReader(System.Data.SqlClient.SqlDataReader reader)
        {
            UserDal ProposedReturnValue = new UserDal();

            ProposedReturnValue.UserID        = reader.GetInt32(OffsetToUserID);
            ProposedReturnValue.EmailAdderess = reader.GetString(OffsetToEmailAdderess);
            ProposedReturnValue.Hash          = reader.GetString(OffsetToHash);
            ProposedReturnValue.Name          = reader.GetString(OffsetToName);
            ProposedReturnValue.Password      = reader.GetString(OffsetToPassword);
            ProposedReturnValue.RoleID        = reader.GetInt32(OffsetToRoleID);
            ProposedReturnValue.Role          = reader.GetString(OffsetToRole);
            return(ProposedReturnValue);
        }
Beispiel #14
0
        /////////////////////////////////////////////////////////////////////////////////
        // Get Slot Item Information
        /////////////////////////////////////////////////////////////////////////////////
        static Global.slotItem GetItem(uint id, byte slot, int type)
        {
            #region Slot item info

            try
            {
                if (id != 0)
                {
                    Global.slotItem slotItem = new Global.slotItem();
                    int             row      = type;

                    MsSQL ms;
                    if (row == 1)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storageacc='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else if (row == 3)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND owner='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }

                    using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                    {
                        while (reader.Read())
                        {
                            slotItem.dbID       = reader.GetInt32(0);
                            slotItem.ID         = reader.GetInt32(2);
                            slotItem.PlusValue  = reader.GetByte(4);
                            slotItem.Amount     = reader.GetInt16(6);
                            slotItem.Durability = reader.GetInt32(7);
                            slotItem.Slot       = slot;
                            LoadBluesid(slotItem.dbID);
                        }
                    }
                    ms.Close();
                    return(slotItem);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Data item load error {0}", ex);
                Systems.Debugger.Write(ex);
            }
            return(null);

            #endregion
        }
Beispiel #15
0
        public TList_Reserva_X_PreVenda Select(Utils.TpBusca[] vBusca, int vTop, string vNM_Campo)
        {
            TList_Reserva_X_PreVenda lista = new TList_Reserva_X_PreVenda();
            bool podeFecharBco             = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Reserva_X_PreVenda reg = new TRegistro_Reserva_X_PreVenda();
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa")))
                    {
                        reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_reserva")))
                    {
                        reg.Id_reserva = reader.GetInt32(reader.GetOrdinal("id_reserva"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_item")))
                    {
                        reg.Id_item = reader.GetInt32(reader.GetOrdinal("id_item"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_prevenda")))
                    {
                        reg.Id_prevenda = reader.GetDecimal(reader.GetOrdinal("id_prevenda"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_itemprevenda")))
                    {
                        reg.Id_itemprevenda = reader.GetDecimal(reader.GetOrdinal("id_itemprevenda"));
                    }
                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    deletarBanco_Dados();
                }
            }
            return(lista);
        }
Beispiel #16
0
        public List <GenerateOtp> GetAll()
        {
            System.Data.SqlClient.SqlCommand              cmd     = null;
            System.Data.SqlClient.SqlDataReader           SDR     = null;
            System.Collections.Generic.List <GenerateOtp> ListTmp = new System.Collections.Generic.List <GenerateOtp>();
            GenerateOtp ObjTmp = null;
            DBCon       Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM GenerateOtp WHERE Deleted=0 ";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new GenerateOtp
                    {
                        OtpId        = SDR.GetInt64(0),
                        OtpCode      = SDR.GetString(1),
                        OtpType      = SDR.GetString(2),
                        hubid        = SDR.GetInt32(3),
                        CreationDate = SDR.GetDateTime(4),
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
Beispiel #17
0
        public System.Collections.Generic.List <FoodReview> GetAll()
        {
            System.Data.SqlClient.SqlCommand             cmd     = null;
            System.Data.SqlClient.SqlDataReader          SDR     = null;
            System.Collections.Generic.List <FoodReview> ListTmp = new System.Collections.Generic.List <FoodReview>();
            FoodReview ObjTmp = null;
            DBCon      Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM FOODREVIEW WHERE Deleted=0 ORDER BY Date_Time DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new FoodReview
                    {
                        FID       = SDR.GetInt64(0),
                        CID       = SDR.GetInt64(1),
                        Rating    = SDR.GetInt32(2),
                        Comment   = SDR.GetString(3),
                        Date_Time = SDR.GetDateTime(4),
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
        public ConcurrentDictionary <Int64, OrderItemCollection> GetAll()
        {
            System.Data.SqlClient.SqlCommand    cmd = null;
            System.Data.SqlClient.SqlDataReader SDR = null;
            ConcurrentDictionary <Int64, OrderItemCollection> ListTmp = new ConcurrentDictionary <Int64, OrderItemCollection>();
            DBCon Obj = new DBCon();

            try
            {
                string Query = "SELECT * FROM OrderItemCollection";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    OrderItemCollection ObjTmp = new OrderItemCollection();
                    ObjTmp.ItemCollectionId = SDR.GetInt64(0);
                    ObjTmp.OrderItemId      = SDR.GetInt64(1);
                    ObjTmp.TifinRackId      = SDR.GetInt64(2);
                    ObjTmp.FoodId           = SDR.GetInt64(3);
                    ObjTmp.MessId           = SDR.GetInt64(4);
                    ObjTmp.CreationDate     = SDR.GetDateTime(5);
                    ObjTmp.CreatedBy        = SDR.GetInt32(7);
                    ListTmp.TryAdd(ObjTmp.TifinRackId, ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
        internal static TipoDocumento buildGetTiposDoc(System.Data.SqlClient.SqlDataReader lector)
        {
            Dictionary <string, int> camposTiposDoc = Ordinales.camposGetTiposDoc;

            return(new TipoDocumento(lector.GetInt32(camposTiposDoc["tipos_doc_id"]),
                                     lector.GetString(camposTiposDoc["tipos_doc_descr"])));
        }
Beispiel #20
0
        public Common.Item[] GetAllDisplay_Categories_Array()
        {
            Params.spS_tblCategory_Display param = new Params.spS_tblCategory_Display(true);

            param.SetUpConnection(string.Empty);


            using (SPs.spS_tblCategory_Display sp = new SPs.spS_tblCategory_Display(true)) {
                System.Collections.ArrayList records = new System.Collections.ArrayList();

                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                sp.Execute(ref param, out sqlDataReader);

                while (sqlDataReader.Read())
                {
                    records.Add(new Common.Item(sqlDataReader.GetInt32(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_ID1.ColumnIndex), sqlDataReader.GetString(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex)));
                }

                sqlDataReader.Close();

                if (sp.Connection.State == System.Data.ConnectionState.Open)
                {
                    sp.Connection.Close();
                }

                sp.Dispose();
                param.Dispose();

                return((Common.Item[])records.ToArray(typeof(Common.Item)));
            }
        }
        public bool DoIt()
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.Parameters.Clear();
            conexao.command.CommandText = "SELECT idCliente,nome FROM Cliente WHERE EMAIL = @EMAIL AND SENHA = @SENHA";
            conexao.command.Parameters.Add("@EMAIL", SqlDbType.VarChar).Value = Email;
            conexao.command.Parameters.Add("@SENHA", SqlDbType.VarChar).Value = StatueStoreEncrypt.Encrypt(Senha);


            System.Data.SqlClient.SqlDataReader dr = conexao.command.ExecuteReader();

            if (dr.HasRows)
            {
                dr.Read();
                HttpContext.Current.Session["idUsuario"]   = dr.GetInt32(0);
                HttpContext.Current.Session["nomeUsuario"] = dr.GetString(1);
                conexao.connection.Close();
                return(true);
            }

            conexao.connection.Close();
            return(false);
        }
 public void LoadGuildMemberIds(int guildid, ref List <int> MemberIDs)
 {
     try
     {
         //Make sure we start with a clean list
         if (MemberIDs != null)
         {
             //If not null clear the list
             MemberIDs.Clear();
         }
         //Create new query to get guild member information
         DB ms = new DB("SELECT * FROM guild_members WHERE guild_id='" + guildid + "'");
         //Create sql data reader to read database content
         using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
         {
             //While the reader is reading
             while (reader.Read())
             {
                 //Add member id to the list
                 MemberIDs.Add(reader.GetInt32(2));
             }
         }
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write information to debug log
     }
 }
        public ProdutosEAnuncios(int QuantidadeAnuncios, int QuantidadeProdutos)
        {
            Anuncios anun = new Anuncios();

            anuncios = anun.PegarAnuncios(QuantidadeAnuncios);

            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.CommandText = "SELECT TOP @#QUANTIDADE idProduto,nome,imagem,precoVenda FROM PRODUTO ORDER BY NEWID()";
            conexao.command.CommandText = conexao.command.CommandText.Replace("@#QUANTIDADE", QuantidadeProdutos.ToString());

            System.Data.SqlClient.SqlDataReader dr = conexao.command.ExecuteReader();
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    ProdutoDisplay prod = new ProdutoDisplay()
                    {
                        Id     = dr.GetInt32(0),
                        nome   = dr.GetString(1),
                        imagem = dr.GetString(2),
                        preco  = dr.GetDecimal(3)
                    };
                    produtos.Add(prod);
                }
            }
            conexao.connection.Close();
            dr.Close();
        }
Beispiel #24
0
        public ConcurrentDictionary <Int64, TifinMaster> GetAll()
        {
            System.Data.SqlClient.SqlCommand          cmd     = null;
            System.Data.SqlClient.SqlDataReader       SDR     = null;
            ConcurrentDictionary <Int64, TifinMaster> ListTmp = new ConcurrentDictionary <Int64, TifinMaster>();

            DBCon Obj = new DBCon();

            try
            {
                string Query = "SELECT * FROM TifinMaster";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    TifinMaster ObjTmp = new TifinMaster();
                    ObjTmp.TifinID         = SDR.GetInt64(0);
                    ObjTmp.TifinType       = SDR.GetInt32(1);
                    ObjTmp.TifinColor      = SDR.GetString(2);
                    ObjTmp.TifinStatus     = SDR.IsDBNull(4) ? "UnUsed" : SDR.GetString(4);
                    ObjTmp.TifinAtLocation = SDR.IsDBNull(5) ? "2" : SDR.GetString(5);
                    ObjTmp.TifinTakenBy    = SDR.IsDBNull(6) ? "" : SDR.GetString(6);
                    ObjTmp.UpdationDate    = SDR.IsDBNull(7) ? System.DateTime.Now : SDR.GetDateTime(7);
                    ListTmp.TryAdd(ObjTmp.TifinID, ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
        public List <EnderecoVisualiza> CepDosClientes()
        {
            List <EnderecoVisualiza> enderecos = new List <EnderecoVisualiza>();
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.CommandText = "SELECT idEndereco,Estado,CEP FROM Endereco WHERE idEndereco IN (SELECT idEndereco FROM Endereco_Cliente WHERE idCliente = @ID)";
            conexao.command.Parameters.Clear();
            conexao.command.Parameters.Add("@ID", SqlDbType.VarChar).Value = (int)HttpContext.Current.Session["idUsuario"];

            System.Data.SqlClient.SqlDataReader dr = conexao.command.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    enderecos.Add(new EnderecoVisualiza
                    {
                        Id     = dr.GetInt32(0),
                        Estado = dr.GetString(1),
                        Cep    = dr.GetString(2)
                    });
                }
            }

            dr.Close();
            conexao.connection.Close();
            return(enderecos);
        }
Beispiel #26
0
        public System.Collections.Generic.List <Settings> GetAll()
        {
            System.Data.SqlClient.SqlCommand           cmd     = null;
            System.Data.SqlClient.SqlDataReader        SDR     = null;
            System.Collections.Generic.List <Settings> ListTmp = new System.Collections.Generic.List <Settings>();
            Settings ObjTmp = null;
            DBCon    Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM Settings";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new Settings
                    {
                        SettingId      = SDR.GetInt32(0),
                        KeyName        = SDR.GetString(1),
                        KeyValue       = SDR.GetString(2),
                        KeyDiscription = SDR.GetString(3),
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
Beispiel #27
0
         public List<int> GetIdList(int categoryID)
         {
             List<int> list = new List<int>();
             System.Data.SqlClient.SqlCommand command = this.CommandCollection[0];
             command.CommandTimeout = command.Connection.ConnectionTimeout;
 
             System.Data.ConnectionState previousConnectionState = command.Connection.State;
             try {
                 if (((command.Connection.State & System.Data.ConnectionState.Open) != System.Data.ConnectionState.Open)) {
                     command.Connection.Open();
                 }
                 command.Parameters[ "@id" ].Value = categoryID;
                 using (System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader()) {
                     while (reader.Read()) {
                         list.Add(reader.GetInt32(0));
                     }
                 }
             } finally {
                 if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
                     command.Connection.Close();
                 }
             }
 
             return list;
         }
        public void GetClientById(int id)
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.CommandText = "SELECT * FROM CLIENTE WHERE idCliente = @ID";
            conexao.command.Parameters.Clear();
            conexao.command.Parameters.Add("@ID", SqlDbType.Int).Value = id;

            System.Data.SqlClient.SqlDataReader dataReader = conexao.command.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    Id             = dataReader.GetInt32(0);
                    Email          = dataReader.GetString(1);
                    Senha          = dataReader.GetString(2);
                    Nome           = dataReader.GetString(3);
                    Sobrenome      = dataReader.GetString(4);
                    Sexo           = dataReader.GetString(5);
                    Cpf            = dataReader.GetString(6);
                    DataNascimento = dataReader.GetDateTime(7);
                    DataInscricao  = dataReader.GetDateTime(8).ToString();
                }
            }

            dataReader.Close();
            conexao.connection.Close();
        }
Beispiel #29
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            listView.Items.Clear();

            int     iCount   = 0;
            decimal totalQty = 0;
            string  query    = BuildQuery();

            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            cmd.CommandText    = query;
            cmd.CommandTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CommandTimedOut"]);
            cmd.CommandType    = CommandType.Text;

            using (System.Data.SqlClient.SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    ListViewItem objItem = this.listView.Items.Add(reader.GetGuid(0).ToString());
                    objItem.SubItems.Add(reader.GetInt32(2).ToString()); // Line Number
                    objItem.SubItems.Add(reader.GetString(4));
                    objItem.SubItems.Add(reader.GetString(5));
                    objItem.SubItems.Add(reader.GetString(6));
                    objItem.SubItems.Add(reader.GetString(7));
                    objItem.SubItems.Add(reader.GetDecimal(8).ToString("##"));

                    totalQty += reader.GetDecimal(8);
                    iCount++;
                }
            }

            txtTotalStock.Text = iCount.ToString();
            txtTotalQty.Text   = totalQty.ToString("##");
        }
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Repair Items
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void HandleRepair(byte slot, int itemid)
 {
     try
     {
         //Here we use 2nd check for item durability to be sure the item repair is needed.
         //Check max durability on items < Need to check later for stats
         double checkdurability = ObjData.Manager.ItemBase[itemid].Defans.Durability;
         //Load our items
         DB ms = new DB("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "'");
         using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
         {
             while (reader.Read())
             {
                 //Read durability from db
                 int currentdurability = reader.GetInt32(7);
                 //If durability is lower then item durability
                 if (currentdurability < checkdurability)
                 {
                     //Send repair packet to client
                     client.Send(Packet.RepairItems(slot, checkdurability));
                     //Update database information
                     DB.query("UPDATE char_items SET durability='" + checkdurability + "' WHERE id='" + itemid + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'");
                 }
             }
         }
         ms.Close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Repair item error {0}", ex);
         Log.Exception(ex);
     }
 }