예제 #1
0
        private void UpdateRecord()
        {
            dbo_DimGeographyClass oclsdbo_DimGeography = new dbo_DimGeographyClass();
            dbo_DimGeographyClass clsdbo_DimGeography  = new dbo_DimGeographyClass();

            oclsdbo_DimGeography.GeographyKey = System.Convert.ToInt32(Session["GeographyKey"]);
            oclsdbo_DimGeography = dbo_DimGeographyDataClass.Select_Record(oclsdbo_DimGeography);

            if (VerifyData() == true)
            {
                SetData(clsdbo_DimGeography);
                bool bSucess = false;
                bSucess = dbo_DimGeographyDataClass.Update(oclsdbo_DimGeography, clsdbo_DimGeography);
                if (bSucess == true)
                {
                    pnlForm.Visible   = false;
                    pnlSave.Visible   = false;
                    pnlGrid.Visible   = true;
                    lblMode.InnerText = "";
                    Session.Remove("dvdbo_DimGeography");
                    LoadGriddbo_DimGeography();
                }
                else
                {
                    ec.ShowMessage(" Update failed. ", " Dbo. Dim Geography ");
                }
            }
        }
예제 #2
0
        private void Edit()
        {
            try {
                dbo_DimGeographyClass clsdbo_DimGeography = new dbo_DimGeographyClass();
                Label lblGeographyKey = (Label)grddbo_DimGeography.Rows[grddbo_DimGeography.EditIndex].FindControl("lblGeographyKey");
                clsdbo_DimGeography.GeographyKey = System.Convert.ToInt32(lblGeographyKey.Text);
                clsdbo_DimGeography = dbo_DimGeographyDataClass.Select_Record(clsdbo_DimGeography);

                Session["SalesTerritoryKey_SelectedValue"] = clsdbo_DimGeography.SalesTerritoryKey;

                LoadGriddbo_DimGeography();
            } catch {
            }
        }
예제 #3
0
        private void DeleteRecord()
        {
            dbo_DimGeographyClass clsdbo_DimGeography = new dbo_DimGeographyClass();
            Label lblGeographyKey = (Label)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("lblGeographyKey");

            clsdbo_DimGeography.GeographyKey = System.Convert.ToInt32(lblGeographyKey.Text);
            clsdbo_DimGeography = dbo_DimGeographyDataClass.Select_Record(clsdbo_DimGeography);
            bool bSucess = false;

            bSucess = dbo_DimGeographyDataClass.Delete(clsdbo_DimGeography);
            if (bSucess == true)
            {
                Session.Remove("dvdbo_DimGeography");
                LoadGriddbo_DimGeography();
            }
            else
            {
                ec.ShowMessage(" Delete failed. ", " Dbo. Dim Geography ");
            }
        }
예제 #4
0
        private void InsertRecord()
        {
            dbo_DimGeographyClass clsdbo_DimGeography = new dbo_DimGeographyClass();

            if (VerifyData() == true)
            {
                SetData(clsdbo_DimGeography);
                bool bSucess = false;
                bSucess = dbo_DimGeographyDataClass.Add(clsdbo_DimGeography);
                if (bSucess == true)
                {
                    pnlForm.Visible   = false;
                    pnlSave.Visible   = false;
                    pnlGrid.Visible   = true;
                    lblMode.InnerText = "";
                    Session.Remove("dvdbo_DimGeography");
                    LoadGriddbo_DimGeography();
                }
                else
                {
                    ec.ShowMessage(" Insert failed. ", " Dbo. Dim Geography ");
                }
            }
        }
    public static bool Delete(dbo_DimGeographyClass clsdbo_DimGeography)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        deleteStatement
            = "DELETE FROM "
              + "     [dbo].[DimGeography] "
              + "WHERE "
              + "     [GeographyKey] = @OldGeographyKey "
              + " AND ((@OldCity IS NULL AND [City] IS NULL) OR [City] = @OldCity) "
              + " AND ((@OldStateProvinceCode IS NULL AND [StateProvinceCode] IS NULL) OR [StateProvinceCode] = @OldStateProvinceCode) "
              + " AND ((@OldStateProvinceName IS NULL AND [StateProvinceName] IS NULL) OR [StateProvinceName] = @OldStateProvinceName) "
              + " AND ((@OldCountryRegionCode IS NULL AND [CountryRegionCode] IS NULL) OR [CountryRegionCode] = @OldCountryRegionCode) "
              + " AND ((@OldEnglishCountryRegionName IS NULL AND [EnglishCountryRegionName] IS NULL) OR [EnglishCountryRegionName] = @OldEnglishCountryRegionName) "
              + " AND ((@OldSpanishCountryRegionName IS NULL AND [SpanishCountryRegionName] IS NULL) OR [SpanishCountryRegionName] = @OldSpanishCountryRegionName) "
              + " AND ((@OldFrenchCountryRegionName IS NULL AND [FrenchCountryRegionName] IS NULL) OR [FrenchCountryRegionName] = @OldFrenchCountryRegionName) "
              + " AND ((@OldPostalCode IS NULL AND [PostalCode] IS NULL) OR [PostalCode] = @OldPostalCode) "
              + " AND ((@OldSalesTerritoryKey IS NULL AND [SalesTerritoryKey] IS NULL) OR [SalesTerritoryKey] = @OldSalesTerritoryKey) "
              + " AND ((@OldIpAddressLocator IS NULL AND [IpAddressLocator] IS NULL) OR [IpAddressLocator] = @OldIpAddressLocator) "
              + "";
        SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

        deleteCommand.CommandType = CommandType.Text;
        deleteCommand.Parameters.AddWithValue("@OldGeographyKey", clsdbo_DimGeography.GeographyKey);
        if (clsdbo_DimGeography.City != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldCity", clsdbo_DimGeography.City);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldCity", DBNull.Value);
        }
        if (clsdbo_DimGeography.StateProvinceCode != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldStateProvinceCode", clsdbo_DimGeography.StateProvinceCode);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldStateProvinceCode", DBNull.Value);
        }
        if (clsdbo_DimGeography.StateProvinceName != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldStateProvinceName", clsdbo_DimGeography.StateProvinceName);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldStateProvinceName", DBNull.Value);
        }
        if (clsdbo_DimGeography.CountryRegionCode != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldCountryRegionCode", clsdbo_DimGeography.CountryRegionCode);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldCountryRegionCode", DBNull.Value);
        }
        if (clsdbo_DimGeography.EnglishCountryRegionName != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldEnglishCountryRegionName", clsdbo_DimGeography.EnglishCountryRegionName);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldEnglishCountryRegionName", DBNull.Value);
        }
        if (clsdbo_DimGeography.SpanishCountryRegionName != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldSpanishCountryRegionName", clsdbo_DimGeography.SpanishCountryRegionName);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldSpanishCountryRegionName", DBNull.Value);
        }
        if (clsdbo_DimGeography.FrenchCountryRegionName != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldFrenchCountryRegionName", clsdbo_DimGeography.FrenchCountryRegionName);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldFrenchCountryRegionName", DBNull.Value);
        }
        if (clsdbo_DimGeography.PostalCode != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldPostalCode", clsdbo_DimGeography.PostalCode);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldPostalCode", DBNull.Value);
        }
        if (clsdbo_DimGeography.SalesTerritoryKey.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldSalesTerritoryKey", clsdbo_DimGeography.SalesTerritoryKey);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldSalesTerritoryKey", DBNull.Value);
        }
        if (clsdbo_DimGeography.IpAddressLocator != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldIpAddressLocator", clsdbo_DimGeography.IpAddressLocator);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldIpAddressLocator", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = deleteCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
    public static bool Update(dbo_DimGeographyClass olddbo_DimGeographyClass,
                              dbo_DimGeographyClass newdbo_DimGeographyClass)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        updateStatement
            = "UPDATE "
              + "     [dbo].[DimGeography] "
              + "SET "
              + "     [City] = @NewCity "
              + "    ,[StateProvinceCode] = @NewStateProvinceCode "
              + "    ,[StateProvinceName] = @NewStateProvinceName "
              + "    ,[CountryRegionCode] = @NewCountryRegionCode "
              + "    ,[EnglishCountryRegionName] = @NewEnglishCountryRegionName "
              + "    ,[SpanishCountryRegionName] = @NewSpanishCountryRegionName "
              + "    ,[FrenchCountryRegionName] = @NewFrenchCountryRegionName "
              + "    ,[PostalCode] = @NewPostalCode "
              + "    ,[SalesTerritoryKey] = @NewSalesTerritoryKey "
              + "    ,[IpAddressLocator] = @NewIpAddressLocator "
              + "WHERE "
              + "     [GeographyKey] = @OldGeographyKey "
              + " AND ((@OldCity IS NULL AND [City] IS NULL) OR [City] = @OldCity) "
              + " AND ((@OldStateProvinceCode IS NULL AND [StateProvinceCode] IS NULL) OR [StateProvinceCode] = @OldStateProvinceCode) "
              + " AND ((@OldStateProvinceName IS NULL AND [StateProvinceName] IS NULL) OR [StateProvinceName] = @OldStateProvinceName) "
              + " AND ((@OldCountryRegionCode IS NULL AND [CountryRegionCode] IS NULL) OR [CountryRegionCode] = @OldCountryRegionCode) "
              + " AND ((@OldEnglishCountryRegionName IS NULL AND [EnglishCountryRegionName] IS NULL) OR [EnglishCountryRegionName] = @OldEnglishCountryRegionName) "
              + " AND ((@OldSpanishCountryRegionName IS NULL AND [SpanishCountryRegionName] IS NULL) OR [SpanishCountryRegionName] = @OldSpanishCountryRegionName) "
              + " AND ((@OldFrenchCountryRegionName IS NULL AND [FrenchCountryRegionName] IS NULL) OR [FrenchCountryRegionName] = @OldFrenchCountryRegionName) "
              + " AND ((@OldPostalCode IS NULL AND [PostalCode] IS NULL) OR [PostalCode] = @OldPostalCode) "
              + " AND ((@OldSalesTerritoryKey IS NULL AND [SalesTerritoryKey] IS NULL) OR [SalesTerritoryKey] = @OldSalesTerritoryKey) "
              + " AND ((@OldIpAddressLocator IS NULL AND [IpAddressLocator] IS NULL) OR [IpAddressLocator] = @OldIpAddressLocator) "
              + "";
        SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

        updateCommand.CommandType = CommandType.Text;
        if (newdbo_DimGeographyClass.City != null)
        {
            updateCommand.Parameters.AddWithValue("@NewCity", newdbo_DimGeographyClass.City);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewCity", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.StateProvinceCode != null)
        {
            updateCommand.Parameters.AddWithValue("@NewStateProvinceCode", newdbo_DimGeographyClass.StateProvinceCode);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewStateProvinceCode", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.StateProvinceName != null)
        {
            updateCommand.Parameters.AddWithValue("@NewStateProvinceName", newdbo_DimGeographyClass.StateProvinceName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewStateProvinceName", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.CountryRegionCode != null)
        {
            updateCommand.Parameters.AddWithValue("@NewCountryRegionCode", newdbo_DimGeographyClass.CountryRegionCode);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewCountryRegionCode", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.EnglishCountryRegionName != null)
        {
            updateCommand.Parameters.AddWithValue("@NewEnglishCountryRegionName", newdbo_DimGeographyClass.EnglishCountryRegionName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewEnglishCountryRegionName", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.SpanishCountryRegionName != null)
        {
            updateCommand.Parameters.AddWithValue("@NewSpanishCountryRegionName", newdbo_DimGeographyClass.SpanishCountryRegionName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewSpanishCountryRegionName", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.FrenchCountryRegionName != null)
        {
            updateCommand.Parameters.AddWithValue("@NewFrenchCountryRegionName", newdbo_DimGeographyClass.FrenchCountryRegionName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewFrenchCountryRegionName", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.PostalCode != null)
        {
            updateCommand.Parameters.AddWithValue("@NewPostalCode", newdbo_DimGeographyClass.PostalCode);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewPostalCode", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.SalesTerritoryKey.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewSalesTerritoryKey", newdbo_DimGeographyClass.SalesTerritoryKey);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewSalesTerritoryKey", DBNull.Value);
        }
        if (newdbo_DimGeographyClass.IpAddressLocator != null)
        {
            updateCommand.Parameters.AddWithValue("@NewIpAddressLocator", newdbo_DimGeographyClass.IpAddressLocator);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewIpAddressLocator", DBNull.Value);
        }
        updateCommand.Parameters.AddWithValue("@OldGeographyKey", olddbo_DimGeographyClass.GeographyKey);
        if (olddbo_DimGeographyClass.City != null)
        {
            updateCommand.Parameters.AddWithValue("@OldCity", olddbo_DimGeographyClass.City);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldCity", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.StateProvinceCode != null)
        {
            updateCommand.Parameters.AddWithValue("@OldStateProvinceCode", olddbo_DimGeographyClass.StateProvinceCode);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldStateProvinceCode", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.StateProvinceName != null)
        {
            updateCommand.Parameters.AddWithValue("@OldStateProvinceName", olddbo_DimGeographyClass.StateProvinceName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldStateProvinceName", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.CountryRegionCode != null)
        {
            updateCommand.Parameters.AddWithValue("@OldCountryRegionCode", olddbo_DimGeographyClass.CountryRegionCode);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldCountryRegionCode", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.EnglishCountryRegionName != null)
        {
            updateCommand.Parameters.AddWithValue("@OldEnglishCountryRegionName", olddbo_DimGeographyClass.EnglishCountryRegionName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldEnglishCountryRegionName", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.SpanishCountryRegionName != null)
        {
            updateCommand.Parameters.AddWithValue("@OldSpanishCountryRegionName", olddbo_DimGeographyClass.SpanishCountryRegionName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldSpanishCountryRegionName", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.FrenchCountryRegionName != null)
        {
            updateCommand.Parameters.AddWithValue("@OldFrenchCountryRegionName", olddbo_DimGeographyClass.FrenchCountryRegionName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldFrenchCountryRegionName", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.PostalCode != null)
        {
            updateCommand.Parameters.AddWithValue("@OldPostalCode", olddbo_DimGeographyClass.PostalCode);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldPostalCode", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.SalesTerritoryKey.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldSalesTerritoryKey", olddbo_DimGeographyClass.SalesTerritoryKey);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldSalesTerritoryKey", DBNull.Value);
        }
        if (olddbo_DimGeographyClass.IpAddressLocator != null)
        {
            updateCommand.Parameters.AddWithValue("@OldIpAddressLocator", olddbo_DimGeographyClass.IpAddressLocator);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldIpAddressLocator", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = updateCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
    public static bool Add(dbo_DimGeographyClass clsdbo_DimGeography)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        insertStatement
            = "INSERT "
              + "     [dbo].[DimGeography] "
              + "     ( "
              + "     [City] "
              + "    ,[StateProvinceCode] "
              + "    ,[StateProvinceName] "
              + "    ,[CountryRegionCode] "
              + "    ,[EnglishCountryRegionName] "
              + "    ,[SpanishCountryRegionName] "
              + "    ,[FrenchCountryRegionName] "
              + "    ,[PostalCode] "
              + "    ,[SalesTerritoryKey] "
              + "    ,[IpAddressLocator] "
              + "     ) "
              + "VALUES "
              + "     ( "
              + "     @City "
              + "    ,@StateProvinceCode "
              + "    ,@StateProvinceName "
              + "    ,@CountryRegionCode "
              + "    ,@EnglishCountryRegionName "
              + "    ,@SpanishCountryRegionName "
              + "    ,@FrenchCountryRegionName "
              + "    ,@PostalCode "
              + "    ,@SalesTerritoryKey "
              + "    ,@IpAddressLocator "
              + "     ) "
              + "";
        SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

        insertCommand.CommandType = CommandType.Text;
        if (clsdbo_DimGeography.City != null)
        {
            insertCommand.Parameters.AddWithValue("@City", clsdbo_DimGeography.City);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@City", DBNull.Value);
        }
        if (clsdbo_DimGeography.StateProvinceCode != null)
        {
            insertCommand.Parameters.AddWithValue("@StateProvinceCode", clsdbo_DimGeography.StateProvinceCode);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@StateProvinceCode", DBNull.Value);
        }
        if (clsdbo_DimGeography.StateProvinceName != null)
        {
            insertCommand.Parameters.AddWithValue("@StateProvinceName", clsdbo_DimGeography.StateProvinceName);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@StateProvinceName", DBNull.Value);
        }
        if (clsdbo_DimGeography.CountryRegionCode != null)
        {
            insertCommand.Parameters.AddWithValue("@CountryRegionCode", clsdbo_DimGeography.CountryRegionCode);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@CountryRegionCode", DBNull.Value);
        }
        if (clsdbo_DimGeography.EnglishCountryRegionName != null)
        {
            insertCommand.Parameters.AddWithValue("@EnglishCountryRegionName", clsdbo_DimGeography.EnglishCountryRegionName);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@EnglishCountryRegionName", DBNull.Value);
        }
        if (clsdbo_DimGeography.SpanishCountryRegionName != null)
        {
            insertCommand.Parameters.AddWithValue("@SpanishCountryRegionName", clsdbo_DimGeography.SpanishCountryRegionName);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@SpanishCountryRegionName", DBNull.Value);
        }
        if (clsdbo_DimGeography.FrenchCountryRegionName != null)
        {
            insertCommand.Parameters.AddWithValue("@FrenchCountryRegionName", clsdbo_DimGeography.FrenchCountryRegionName);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@FrenchCountryRegionName", DBNull.Value);
        }
        if (clsdbo_DimGeography.PostalCode != null)
        {
            insertCommand.Parameters.AddWithValue("@PostalCode", clsdbo_DimGeography.PostalCode);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@PostalCode", DBNull.Value);
        }
        if (clsdbo_DimGeography.SalesTerritoryKey.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@SalesTerritoryKey", clsdbo_DimGeography.SalesTerritoryKey);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@SalesTerritoryKey", DBNull.Value);
        }
        if (clsdbo_DimGeography.IpAddressLocator != null)
        {
            insertCommand.Parameters.AddWithValue("@IpAddressLocator", clsdbo_DimGeography.IpAddressLocator);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@IpAddressLocator", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
    public static dbo_DimGeographyClass Select_Record(dbo_DimGeographyClass clsdbo_DimGeographyPara)
    {
        dbo_DimGeographyClass clsdbo_DimGeography = new dbo_DimGeographyClass();
        SqlConnection         connection          = AdventureWorksDW2012DataClass.GetConnection();
        string selectStatement
            = "SELECT "
              + "     [GeographyKey] "
              + "    ,[City] "
              + "    ,[StateProvinceCode] "
              + "    ,[StateProvinceName] "
              + "    ,[CountryRegionCode] "
              + "    ,[EnglishCountryRegionName] "
              + "    ,[SpanishCountryRegionName] "
              + "    ,[FrenchCountryRegionName] "
              + "    ,[PostalCode] "
              + "    ,[SalesTerritoryKey] "
              + "    ,[IpAddressLocator] "
              + "FROM "
              + "     [dbo].[DimGeography] "
              + "WHERE "
              + "     [GeographyKey] = @GeographyKey "
              + "";
        SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

        selectCommand.CommandType = CommandType.Text;
        selectCommand.Parameters.AddWithValue("@GeographyKey", clsdbo_DimGeographyPara.GeographyKey);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_DimGeography.GeographyKey             = System.Convert.ToInt32(reader["GeographyKey"]);
                clsdbo_DimGeography.City                     = reader["City"] is DBNull ? null : reader["City"].ToString();
                clsdbo_DimGeography.StateProvinceCode        = reader["StateProvinceCode"] is DBNull ? null : reader["StateProvinceCode"].ToString();
                clsdbo_DimGeography.StateProvinceName        = reader["StateProvinceName"] is DBNull ? null : reader["StateProvinceName"].ToString();
                clsdbo_DimGeography.CountryRegionCode        = reader["CountryRegionCode"] is DBNull ? null : reader["CountryRegionCode"].ToString();
                clsdbo_DimGeography.EnglishCountryRegionName = reader["EnglishCountryRegionName"] is DBNull ? null : reader["EnglishCountryRegionName"].ToString();
                clsdbo_DimGeography.SpanishCountryRegionName = reader["SpanishCountryRegionName"] is DBNull ? null : reader["SpanishCountryRegionName"].ToString();
                clsdbo_DimGeography.FrenchCountryRegionName  = reader["FrenchCountryRegionName"] is DBNull ? null : reader["FrenchCountryRegionName"].ToString();
                clsdbo_DimGeography.PostalCode               = reader["PostalCode"] is DBNull ? null : reader["PostalCode"].ToString();
                clsdbo_DimGeography.SalesTerritoryKey        = reader["SalesTerritoryKey"] is DBNull ? null : (Int32?)reader["SalesTerritoryKey"];
                clsdbo_DimGeography.IpAddressLocator         = reader["IpAddressLocator"] is DBNull ? null : reader["IpAddressLocator"].ToString();
            }
            else
            {
                clsdbo_DimGeography = null;
            }
            reader.Close();
        }
        catch (SqlException)
        {
            return(clsdbo_DimGeography);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_DimGeography);
    }
예제 #9
0
        private void UpdateRecord()
        {
            try {
                TextBox      txtGeographyKey             = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtGeographyKey");
                TextBox      txtCity                     = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCity");
                TextBox      txtStateProvinceCode        = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtStateProvinceCode");
                TextBox      txtStateProvinceName        = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtStateProvinceName");
                TextBox      txtCountryRegionCode        = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCountryRegionCode");
                TextBox      txtEnglishCountryRegionName = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtEnglishCountryRegionName");
                TextBox      txtSpanishCountryRegionName = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtSpanishCountryRegionName");
                TextBox      txtFrenchCountryRegionName  = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtFrenchCountryRegionName");
                TextBox      txtPostalCode               = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtPostalCode");
                DropDownList txtSalesTerritoryKey        = (DropDownList)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtSalesTerritoryKey");
                TextBox      txtIpAddressLocator         = (TextBox)grddbo_DimGeography.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtIpAddressLocator");

                dbo_DimGeographyClass oclsdbo_DimGeography = new dbo_DimGeographyClass();
                dbo_DimGeographyClass clsdbo_DimGeography  = new dbo_DimGeographyClass();
                oclsdbo_DimGeography.GeographyKey = System.Convert.ToInt32(txtGeographyKey.Text);
                oclsdbo_DimGeography = dbo_DimGeographyDataClass.Select_Record(oclsdbo_DimGeography);

                if (VerifyData() == true)
                {
                    if (string.IsNullOrEmpty(txtCity.Text))
                    {
                        clsdbo_DimGeography.City = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.City = txtCity.Text;
                    }
                    if (string.IsNullOrEmpty(txtStateProvinceCode.Text))
                    {
                        clsdbo_DimGeography.StateProvinceCode = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.StateProvinceCode = txtStateProvinceCode.Text;
                    }
                    if (string.IsNullOrEmpty(txtStateProvinceName.Text))
                    {
                        clsdbo_DimGeography.StateProvinceName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.StateProvinceName = txtStateProvinceName.Text;
                    }
                    if (string.IsNullOrEmpty(txtCountryRegionCode.Text))
                    {
                        clsdbo_DimGeography.CountryRegionCode = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.CountryRegionCode = txtCountryRegionCode.Text;
                    }
                    if (string.IsNullOrEmpty(txtEnglishCountryRegionName.Text))
                    {
                        clsdbo_DimGeography.EnglishCountryRegionName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.EnglishCountryRegionName = txtEnglishCountryRegionName.Text;
                    }
                    if (string.IsNullOrEmpty(txtSpanishCountryRegionName.Text))
                    {
                        clsdbo_DimGeography.SpanishCountryRegionName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.SpanishCountryRegionName = txtSpanishCountryRegionName.Text;
                    }
                    if (string.IsNullOrEmpty(txtFrenchCountryRegionName.Text))
                    {
                        clsdbo_DimGeography.FrenchCountryRegionName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.FrenchCountryRegionName = txtFrenchCountryRegionName.Text;
                    }
                    if (string.IsNullOrEmpty(txtPostalCode.Text))
                    {
                        clsdbo_DimGeography.PostalCode = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.PostalCode = txtPostalCode.Text;
                    }
                    if (string.IsNullOrEmpty(txtSalesTerritoryKey.SelectedValue))
                    {
                        clsdbo_DimGeography.SalesTerritoryKey = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.SalesTerritoryKey = System.Convert.ToInt32(txtSalesTerritoryKey.SelectedValue);
                    }
                    if (string.IsNullOrEmpty(txtIpAddressLocator.Text))
                    {
                        clsdbo_DimGeography.IpAddressLocator = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.IpAddressLocator = txtIpAddressLocator.Text;
                    }
                    bool bSucess = false;
                    bSucess = dbo_DimGeographyDataClass.Update(oclsdbo_DimGeography, clsdbo_DimGeography);
                    if (bSucess == true)
                    {
                        Session.Remove("dvdbo_DimGeography");
                        grddbo_DimGeography.EditIndex = -1;
                        LoadGriddbo_DimGeography();
                    }
                    else
                    {
                        ec.ShowMessage(" Update failed. ", " Dbo. Dim Geography ");
                    }
                }
            } catch {
            }
        }
예제 #10
0
        private void InsertRecord()
        {
            try {
                TextBox      txtNewCity = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewCity");
                TextBox      txtNewStateProvinceCode        = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewStateProvinceCode");
                TextBox      txtNewStateProvinceName        = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewStateProvinceName");
                TextBox      txtNewCountryRegionCode        = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewCountryRegionCode");
                TextBox      txtNewEnglishCountryRegionName = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewEnglishCountryRegionName");
                TextBox      txtNewSpanishCountryRegionName = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewSpanishCountryRegionName");
                TextBox      txtNewFrenchCountryRegionName  = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewFrenchCountryRegionName");
                TextBox      txtNewPostalCode        = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewPostalCode");
                DropDownList txtNewSalesTerritoryKey = (DropDownList)grddbo_DimGeography.FooterRow.FindControl("txtNewSalesTerritoryKey");
                TextBox      txtNewIpAddressLocator  = (TextBox)grddbo_DimGeography.FooterRow.FindControl("txtNewIpAddressLocator");

                dbo_DimGeographyClass clsdbo_DimGeography = new dbo_DimGeographyClass();
                if (VerifyDataNew() == true)
                {
                    if (string.IsNullOrEmpty(txtNewCity.Text))
                    {
                        clsdbo_DimGeography.City = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.City = txtNewCity.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewStateProvinceCode.Text))
                    {
                        clsdbo_DimGeography.StateProvinceCode = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.StateProvinceCode = txtNewStateProvinceCode.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewStateProvinceName.Text))
                    {
                        clsdbo_DimGeography.StateProvinceName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.StateProvinceName = txtNewStateProvinceName.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewCountryRegionCode.Text))
                    {
                        clsdbo_DimGeography.CountryRegionCode = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.CountryRegionCode = txtNewCountryRegionCode.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewEnglishCountryRegionName.Text))
                    {
                        clsdbo_DimGeography.EnglishCountryRegionName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.EnglishCountryRegionName = txtNewEnglishCountryRegionName.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewSpanishCountryRegionName.Text))
                    {
                        clsdbo_DimGeography.SpanishCountryRegionName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.SpanishCountryRegionName = txtNewSpanishCountryRegionName.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewFrenchCountryRegionName.Text))
                    {
                        clsdbo_DimGeography.FrenchCountryRegionName = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.FrenchCountryRegionName = txtNewFrenchCountryRegionName.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewPostalCode.Text))
                    {
                        clsdbo_DimGeography.PostalCode = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.PostalCode = txtNewPostalCode.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewSalesTerritoryKey.SelectedValue))
                    {
                        clsdbo_DimGeography.SalesTerritoryKey = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.SalesTerritoryKey = System.Convert.ToInt32(txtNewSalesTerritoryKey.SelectedValue);
                    }
                    if (string.IsNullOrEmpty(txtNewIpAddressLocator.Text))
                    {
                        clsdbo_DimGeography.IpAddressLocator = null;
                    }
                    else
                    {
                        clsdbo_DimGeography.IpAddressLocator = txtNewIpAddressLocator.Text;
                    }
                    bool bSucess = false;
                    bSucess = dbo_DimGeographyDataClass.Add(clsdbo_DimGeography);
                    if (bSucess == true)
                    {
                        Session.Remove("dvdbo_DimGeography");
                        LoadGriddbo_DimGeography();
                    }
                    else
                    {
                        ec.ShowMessage(" Insert failed. ", " Dbo. Dim Geography ");
                    }
                }
            } catch {
            }
        }
예제 #11
0
 private void SetData(dbo_DimGeographyClass clsdbo_DimGeography)
 {
     if (string.IsNullOrEmpty(txtCity.Text))
     {
         clsdbo_DimGeography.City = null;
     }
     else
     {
         clsdbo_DimGeography.City = txtCity.Text;
     }
     if (string.IsNullOrEmpty(txtStateProvinceCode.Text))
     {
         clsdbo_DimGeography.StateProvinceCode = null;
     }
     else
     {
         clsdbo_DimGeography.StateProvinceCode = txtStateProvinceCode.Text;
     }
     if (string.IsNullOrEmpty(txtStateProvinceName.Text))
     {
         clsdbo_DimGeography.StateProvinceName = null;
     }
     else
     {
         clsdbo_DimGeography.StateProvinceName = txtStateProvinceName.Text;
     }
     if (string.IsNullOrEmpty(txtCountryRegionCode.Text))
     {
         clsdbo_DimGeography.CountryRegionCode = null;
     }
     else
     {
         clsdbo_DimGeography.CountryRegionCode = txtCountryRegionCode.Text;
     }
     if (string.IsNullOrEmpty(txtEnglishCountryRegionName.Text))
     {
         clsdbo_DimGeography.EnglishCountryRegionName = null;
     }
     else
     {
         clsdbo_DimGeography.EnglishCountryRegionName = txtEnglishCountryRegionName.Text;
     }
     if (string.IsNullOrEmpty(txtSpanishCountryRegionName.Text))
     {
         clsdbo_DimGeography.SpanishCountryRegionName = null;
     }
     else
     {
         clsdbo_DimGeography.SpanishCountryRegionName = txtSpanishCountryRegionName.Text;
     }
     if (string.IsNullOrEmpty(txtFrenchCountryRegionName.Text))
     {
         clsdbo_DimGeography.FrenchCountryRegionName = null;
     }
     else
     {
         clsdbo_DimGeography.FrenchCountryRegionName = txtFrenchCountryRegionName.Text;
     }
     if (string.IsNullOrEmpty(txtPostalCode.Text))
     {
         clsdbo_DimGeography.PostalCode = null;
     }
     else
     {
         clsdbo_DimGeography.PostalCode = txtPostalCode.Text;
     }
     if (string.IsNullOrEmpty(txtSalesTerritoryKey.SelectedValue))
     {
         clsdbo_DimGeography.SalesTerritoryKey = null;
     }
     else
     {
         clsdbo_DimGeography.SalesTerritoryKey = System.Convert.ToInt32(txtSalesTerritoryKey.SelectedValue);
     }
     if (string.IsNullOrEmpty(txtIpAddressLocator.Text))
     {
         clsdbo_DimGeography.IpAddressLocator = null;
     }
     else
     {
         clsdbo_DimGeography.IpAddressLocator = txtIpAddressLocator.Text;
     }
 }
예제 #12
0
        private void GetData()
        {
            ClearRecord();

            dbo_DimGeographyClass clsdbo_DimGeography = new dbo_DimGeographyClass();

            clsdbo_DimGeography.GeographyKey = System.Convert.ToInt32(Session["GeographyKey"]);
            clsdbo_DimGeography = dbo_DimGeographyDataClass.Select_Record(clsdbo_DimGeography);

            if ((clsdbo_DimGeography != null))
            {
                try {
                    txtGeographyKey.Text = System.Convert.ToString(clsdbo_DimGeography.GeographyKey);
                    if (clsdbo_DimGeography.City == null)
                    {
                        txtCity.Text = default(string);
                    }
                    else
                    {
                        txtCity.Text = System.Convert.ToString(clsdbo_DimGeography.City);
                    }
                    if (clsdbo_DimGeography.StateProvinceCode == null)
                    {
                        txtStateProvinceCode.Text = default(string);
                    }
                    else
                    {
                        txtStateProvinceCode.Text = System.Convert.ToString(clsdbo_DimGeography.StateProvinceCode);
                    }
                    if (clsdbo_DimGeography.StateProvinceName == null)
                    {
                        txtStateProvinceName.Text = default(string);
                    }
                    else
                    {
                        txtStateProvinceName.Text = System.Convert.ToString(clsdbo_DimGeography.StateProvinceName);
                    }
                    if (clsdbo_DimGeography.CountryRegionCode == null)
                    {
                        txtCountryRegionCode.Text = default(string);
                    }
                    else
                    {
                        txtCountryRegionCode.Text = System.Convert.ToString(clsdbo_DimGeography.CountryRegionCode);
                    }
                    if (clsdbo_DimGeography.EnglishCountryRegionName == null)
                    {
                        txtEnglishCountryRegionName.Text = default(string);
                    }
                    else
                    {
                        txtEnglishCountryRegionName.Text = System.Convert.ToString(clsdbo_DimGeography.EnglishCountryRegionName);
                    }
                    if (clsdbo_DimGeography.SpanishCountryRegionName == null)
                    {
                        txtSpanishCountryRegionName.Text = default(string);
                    }
                    else
                    {
                        txtSpanishCountryRegionName.Text = System.Convert.ToString(clsdbo_DimGeography.SpanishCountryRegionName);
                    }
                    if (clsdbo_DimGeography.FrenchCountryRegionName == null)
                    {
                        txtFrenchCountryRegionName.Text = default(string);
                    }
                    else
                    {
                        txtFrenchCountryRegionName.Text = System.Convert.ToString(clsdbo_DimGeography.FrenchCountryRegionName);
                    }
                    if (clsdbo_DimGeography.PostalCode == null)
                    {
                        txtPostalCode.Text = default(string);
                    }
                    else
                    {
                        txtPostalCode.Text = System.Convert.ToString(clsdbo_DimGeography.PostalCode);
                    }
                    if (clsdbo_DimGeography.SalesTerritoryKey == null)
                    {
                        txtSalesTerritoryKey.SelectedValue = default(string);
                    }
                    else
                    {
                        txtSalesTerritoryKey.SelectedValue = System.Convert.ToString(clsdbo_DimGeography.SalesTerritoryKey);
                    }
                    if (clsdbo_DimGeography.IpAddressLocator == null)
                    {
                        txtIpAddressLocator.Text = default(string);
                    }
                    else
                    {
                        txtIpAddressLocator.Text = System.Convert.ToString(clsdbo_DimGeography.IpAddressLocator);
                    }
                }
                catch (Exception ex)
                {
                    ec.ShowMessage(ex.Message, " Dbo. Dim Geography ");
                }
            }
        }