コード例 #1
0
 public UserMapper(System.Data.SqlClient.SqlDataReader reader)
 {
     OffsetToUserID = reader.GetOrdinal("UserID");
     Assert(0 == OffsetToUserID, $"UserID is {OffsetToUserID} not 0 as expected");
     OffsetToEmailAdderess = reader.GetOrdinal("EMailAdderess");
     Assert(1 == OffsetToEmailAdderess, $"EmailAdderess is {OffsetToEmailAdderess} not 1 as expected");
     OffsetToName = reader.GetOrdinal("Name");
     Assert(2 == OffsetToName, $"Name is {OffsetToName} not 2 as expected");
     OffsetToPassword = reader.GetOrdinal("Password");
     Assert(3 == OffsetToPassword, $"Passwoed is {OffsetToPassword} not 3 as expected");
     OffsetToHash = reader.GetOrdinal("Hash");
     Assert(4 == OffsetToHash, $"Hash is {OffsetToHash} not 4 as expected");
     OffsetToRoleID = reader.GetOrdinal("RoleID");
     Assert(5 == OffsetToRoleID, $"RoleID is {OffsetToRoleID} not 5 as expected");
     OffsetToRole = reader.GetOrdinal("Role");
     Assert(6 == OffsetToRole, $"Role is {OffsetToRole} not 6 as expected");
 }
コード例 #2
0
        /// <summary>
        /// Calls the "sp_EmployeeSchedule" stored procedure
        /// </summary>
        /// <param name="id"></param>
        /// <param name="day"></param>
        /// <returns></returns>
        public ActionResult Schedule(int?id, DateTime?day)
        {
            if (!day.HasValue)
            {
                day = DateTime.Today;
            }
            //TODO: call the sp_GetEmployeesWorking procedure

            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["StoreDB"].ConnectionString;

            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.ERPScheduleModel> schedules = new List <Models.ERPScheduleModel>();

            System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                Models.ERPScheduleModel schedule = new Models.ERPScheduleModel();
                schedule.EmployeeName = reader.GetString(reader.GetOrdinal("Name"));
                schedule.StartTime    = reader.GetDateTime(1);
                schedule.EndTime      = reader.GetDateTime(2);

                schedules.Add(schedule);
            }
            connection.Close();

            return(View(schedules));
        }
コード例 #3
0
        public SupplierMapper(System.Data.SqlClient.SqlDataReader reader)
        {
            OffsetToSupplierID = reader.GetOrdinal("SupplierID");
            Assert(0 == OffsetToSupplierID, "The SupplierID is not 0 as expected");
            OffsetToSupplierName = reader.GetOrdinal("SupplierName");
            Assert(1 == OffsetToSupplierName, "The SupplierName is not 1 as expected");
            OffsetToContactName = reader.GetOrdinal("ContactName");
            Assert(2 == OffsetToContactName, "The ContactName is not 2 as expected");
            OffsetToContactEmail = reader.GetOrdinal("ContactEmail");
            Assert(3 == OffsetToContactEmail, "The ContactEmail is not 3 as expected");
            OffsetToAddress = reader.GetOrdinal("Address");
            Assert(4 == OffsetToAddress, "The Address is not 4 as expected");

            OffsetToSupplierCreateDate = reader.GetOrdinal("SupplierCreateDate");
            Assert(5 == OffsetToSupplierCreateDate, "The SupplierCreateDate is not 5 as expected");

            OffsetToSuppliersPhotoURL = reader.GetOrdinal("SuppliersPhotoURL");
            Assert(6 == OffsetToSuppliersPhotoURL, "The SuppliersPhotoURL is not 6 as expected");

            OffsetToWebsiteURL = reader.GetOrdinal("WebsiteURL");
            Assert(7 == OffsetToWebsiteURL, "The WebsiteURL is not 7 as expected");
        }
コード例 #4
0
ファイル: HelperDataReader.cs プロジェクト: renatomatos/prova
        public static DateTime?GetDateTime(System.Data.SqlClient.SqlDataReader rd, string field)
        {
            var index = rd.GetOrdinal(field);

            if (index < 0)
            {
                return(null);
            }
            else
            {
                if (rd.IsDBNull(index))
                {
                    return(null);
                }
                else
                {
                    return(rd.GetDateTime(index));
                }
            }
        }
コード例 #5
0
ファイル: HelperDataReader.cs プロジェクト: renatomatos/prova
        public static string GetString(System.Data.SqlClient.SqlDataReader rd, string field)
        {
            var index = rd.GetOrdinal(field);

            if (index < 0)
            {
                return(string.Empty);
            }
            else
            {
                if (rd.IsDBNull(index))
                {
                    return(string.Empty);
                }
                else
                {
                    return(rd.GetString(index));
                }
            }
        }
コード例 #6
0
ファイル: HelperDataReader.cs プロジェクト: renatomatos/prova
        public static decimal GetDecimal(System.Data.SqlClient.SqlDataReader rd, string field)
        {
            var index = rd.GetOrdinal(field);

            if (index < 0)
            {
                return(0);
            }
            else
            {
                if (rd.IsDBNull(index))
                {
                    return(0);
                }
                else
                {
                    return(rd.GetDecimal(index));
                }
            }
        }
コード例 #7
0
        public TList_Pergunta_X_Resposta Select(Utils.TpBusca[] vBusca, int vTop, string vNm_Campo)
        {
            TList_Pergunta_X_Resposta lista = new TList_Pergunta_X_Resposta();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = CriarBanco_Dados(false);
            }
            try
            {
                reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_Pergunta_x_Resposta reg = new TRegistro_Pergunta_x_Resposta();

                    if (!reader.IsDBNull(reader.GetOrdinal("id_pergunta")))
                    {
                        reg.Id_pergunta = reader.GetDecimal(reader.GetOrdinal("id_pergunta"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_resposta")))
                    {
                        reg.Id_resposta = reader.GetDecimal(reader.GetOrdinal("id_resposta"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_resposta")))
                    {
                        reg.ds_resposta = reader.GetString(reader.GetOrdinal("ds_resposta"));
                    }


                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    deletarBanco_Dados();
                }
            }
            return(lista);
        }
コード例 #8
0
        public TList_Questionario Select(Utils.TpBusca[] vBusca, int vTop, string vNm_Campo)
        {
            TList_Questionario lista = new TList_Questionario();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = CriarBanco_Dados(false);
            }
            try
            {
                reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_Questionario reg = new TRegistro_Questionario();

                    if (!reader.IsDBNull(reader.GetOrdinal("id_questionario")))
                    {
                        reg.Id_questionario = reader.GetDecimal(reader.GetOrdinal("id_questionario"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_questionario")))
                    {
                        reg.Ds_questionario = reader.GetString(reader.GetOrdinal("ds_questionario"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cancelado")))
                    {
                        reg.Cancelado = reader.GetBoolean(reader.GetOrdinal("cancelado"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    deletarBanco_Dados();
                }
            }
            return(lista);
        }
コード例 #9
0
        public TList_Triggers Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo, string vOrder)
        {
            TList_Triggers lista = new TList_Triggers();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            try
            {
                reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo, vOrder));

                while (reader.Read())
                {
                    CamadaDados.Diversos.TRegistro_Triggers reg = new CamadaDados.Diversos.TRegistro_Triggers();
                    if (!(reader.IsDBNull(reader.GetOrdinal("Trigger_Name"))))
                    {
                        reg.trigger_nome = reader.GetString(reader.GetOrdinal("Trigger_Name"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("definition"))))
                    {
                        reg.trigger_script = reader.GetString(reader.GetOrdinal("definition"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("is_disabled"))))
                    {
                        reg.st_ativo = !reader.GetBoolean(reader.GetOrdinal("is_disabled"));
                    }
                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
コード例 #10
0
        public TList_Usuario_RegraEspecial Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            TList_Usuario_RegraEspecial lista = new TList_Usuario_RegraEspecial();
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                this.CriarBanco_Dados(false);
                podeFecharBco = true;
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Usuario_RegraEspecial cadUser = new TRegistro_Usuario_RegraEspecial();
                    if (!reader.IsDBNull(reader.GetOrdinal("login")))
                    {
                        cadUser.Login = reader.GetString(reader.GetOrdinal("login"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ID_Regra")))
                    {
                        cadUser.Id_regra = reader.GetDecimal(reader.GetOrdinal("ID_Regra"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Regra")))
                    {
                        cadUser.Ds_regra = reader.GetString(reader.GetOrdinal("DS_Regra"));
                    }

                    lista.Add(cadUser);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
コード例 #11
0
        public TList_Manutencao_X_Almox Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco             = false;
            TList_Manutencao_X_Almox lista = new TList_Manutencao_X_Almox();

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Manutencao_X_Almox reg = new TRegistro_Manutencao_X_Almox();
                    if (!reader.IsDBNull(reader.GetOrdinal("id_manutencao")))
                    {
                        reg.Id_manutencao = reader.GetDecimal(reader.GetOrdinal("id_manutencao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_veiculo")))
                    {
                        reg.Id_veiculo = reader.GetDecimal(reader.GetOrdinal("id_veiculo"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_movimento")))
                    {
                        reg.Id_movimento = reader.GetDecimal(reader.GetOrdinal("id_movimento"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
コード例 #12
0
        public TList_FaturamentoCCusto Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco            = false;
            TList_FaturamentoCCusto lista = new TList_FaturamentoCCusto();

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_FaturamentoCCusto reg = new TRegistro_FaturamentoCCusto();
                    if (!(reader.IsDBNull(reader.GetOrdinal("nr_lanctofiscal"))))
                    {
                        reg.Nr_lanctofiscal = reader.GetDecimal(reader.GetOrdinal("nr_lanctofiscal"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa")))
                    {
                        reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_ccustolan")))
                    {
                        reg.Id_ccustolan = reader.GetDecimal(reader.GetOrdinal("id_ccustolan"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
コード例 #13
0
        public List <Tipo74> Select(string Cd_empresa, string Dt_inventario)
        {
            List <Tipo74> retorno       = new List <Tipo74>();
            bool          podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(Cd_empresa, Dt_inventario));
            try
            {
                while (reader.Read())
                {
                    Tipo74 reg = new Tipo74();
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_produto")))
                    {
                        reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("quantidade")))
                    {
                        reg.Quantidade = reader.GetDecimal(reader.GetOrdinal("quantidade"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("vl_medio")))
                    {
                        reg.Vl_medio = reader.GetDecimal(reader.GetOrdinal("vl_medio"));
                    }
                    retorno.Add(reg);
                }
                return(retorno);
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
        }