private Boolean VerifyDataNew()
        {
            TextBox txtNewAverageRate  = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewAverageRate");
            TextBox txtNewCurrencyID   = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewCurrencyID");
            TextBox txtNewCurrencyDate = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewCurrencyDate");
            TextBox txtNewEndOfDayRate = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewEndOfDayRate");
            TextBox txtNewCurrencyKey  = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewCurrencyKey");
            TextBox txtNewDateKey      = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewDateKey");

            if (
                txtNewAverageRate.Text != ""
                )
            {
                dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
                clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(txtNewAverageRate.Text);
                clsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(clsdbo_NewFactCurrencyRate);
                if (clsdbo_NewFactCurrencyRate != null)
                {
                    ec.ShowMessage(" Record already exists. ", " Dbo. New Fact Currency Rate ");
                    txtNewAverageRate.Focus();
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        private void UpdateRecord()
        {
            dbo_NewFactCurrencyRateClass oclsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
            dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate  = new dbo_NewFactCurrencyRateClass();

            oclsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(Session["AverageRate"]);
            oclsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(oclsdbo_NewFactCurrencyRate);

            if (VerifyData() == true)
            {
                SetData(clsdbo_NewFactCurrencyRate);
                bool bSucess = false;
                bSucess = dbo_NewFactCurrencyRateDataClass.Update(oclsdbo_NewFactCurrencyRate, clsdbo_NewFactCurrencyRate);
                if (bSucess == true)
                {
                    pnlForm.Visible   = false;
                    pnlSave.Visible   = false;
                    pnlGrid.Visible   = true;
                    lblMode.InnerText = "";
                    Session.Remove("dvdbo_NewFactCurrencyRate");
                    LoadGriddbo_NewFactCurrencyRate();
                }
                else
                {
                    ec.ShowMessage(" Update failed. ", " Dbo. New Fact Currency Rate ");
                }
            }
        }
        private void Edit()
        {
            try {
                dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
                Label lblAverageRate = (Label)grddbo_NewFactCurrencyRate.Rows[grddbo_NewFactCurrencyRate.EditIndex].FindControl("lblAverageRate");
                clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(lblAverageRate.Text);
                clsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(clsdbo_NewFactCurrencyRate);


                LoadGriddbo_NewFactCurrencyRate();
            } catch {
            }
        }
示例#4
0
 private void SetData(dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate)
 {
     if (string.IsNullOrEmpty(txtAverageRate.Text))
     {
         clsdbo_NewFactCurrencyRate.AverageRate = null;
     }
     else
     {
         clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(txtAverageRate.Text);
     }
     if (string.IsNullOrEmpty(txtCurrencyID.Text))
     {
         clsdbo_NewFactCurrencyRate.CurrencyID = null;
     }
     else
     {
         clsdbo_NewFactCurrencyRate.CurrencyID = txtCurrencyID.Text;
     }
     if (string.IsNullOrEmpty(txtCurrencyDate.Text))
     {
         clsdbo_NewFactCurrencyRate.CurrencyDate = null;
     }
     else
     {
         clsdbo_NewFactCurrencyRate.CurrencyDate = System.Convert.ToDateTime(txtCurrencyDate.Text);
     }
     if (string.IsNullOrEmpty(txtEndOfDayRate.Text))
     {
         clsdbo_NewFactCurrencyRate.EndOfDayRate = null;
     }
     else
     {
         clsdbo_NewFactCurrencyRate.EndOfDayRate = System.Convert.ToDecimal(txtEndOfDayRate.Text);
     }
     if (string.IsNullOrEmpty(txtCurrencyKey.Text))
     {
         clsdbo_NewFactCurrencyRate.CurrencyKey = null;
     }
     else
     {
         clsdbo_NewFactCurrencyRate.CurrencyKey = System.Convert.ToInt32(txtCurrencyKey.Text);
     }
     if (string.IsNullOrEmpty(txtDateKey.Text))
     {
         clsdbo_NewFactCurrencyRate.DateKey = null;
     }
     else
     {
         clsdbo_NewFactCurrencyRate.DateKey = System.Convert.ToInt32(txtDateKey.Text);
     }
 }
    public static dbo_NewFactCurrencyRateClass Select_Record(dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRatePara)
    {
        dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        selectStatement
            = "SELECT "
              + "     [AverageRate] "
              + "    ,[CurrencyID] "
              + "    ,[CurrencyDate] "
              + "    ,[EndOfDayRate] "
              + "    ,[CurrencyKey] "
              + "    ,[DateKey] "
              + "FROM "
              + "     [dbo].[NewFactCurrencyRate] "
              + "WHERE "
              + "    [AverageRate] = @AverageRate "
              + "";
        SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

        selectCommand.CommandType = CommandType.Text;
        selectCommand.Parameters.AddWithValue("@AverageRate", clsdbo_NewFactCurrencyRatePara.AverageRate);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_NewFactCurrencyRate.AverageRate  = reader["AverageRate"] is DBNull ? null : (Decimal?)(Single?)reader["AverageRate"];
                clsdbo_NewFactCurrencyRate.CurrencyID   = reader["CurrencyID"] is DBNull ? null : reader["CurrencyID"].ToString();
                clsdbo_NewFactCurrencyRate.CurrencyDate = reader["CurrencyDate"] is DBNull ? null : (DateTime?)reader["CurrencyDate"];
                clsdbo_NewFactCurrencyRate.EndOfDayRate = reader["EndOfDayRate"] is DBNull ? null : (Decimal?)(Single?)reader["EndOfDayRate"];
                clsdbo_NewFactCurrencyRate.CurrencyKey  = reader["CurrencyKey"] is DBNull ? null : (Int32?)reader["CurrencyKey"];
                clsdbo_NewFactCurrencyRate.DateKey      = reader["DateKey"] is DBNull ? null : (Int32?)reader["DateKey"];
            }
            else
            {
                clsdbo_NewFactCurrencyRate = null;
            }
            reader.Close();
        }
        catch (SqlException)
        {
            return(clsdbo_NewFactCurrencyRate);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_NewFactCurrencyRate);
    }
示例#6
0
 private Boolean VerifyData()
 {
     if (
         txtAverageRate.Text != ""
         )
     {
         dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
         clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(txtAverageRate.Text);
         clsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(clsdbo_NewFactCurrencyRate);
         if (clsdbo_NewFactCurrencyRate != null && (String)Session["Mode"] == "Add")
         {
             ec.ShowMessage(" Record already exists. ", " Dbo. New Fact Currency Rate ");
             txtAverageRate.Focus();
             return(false);
         }
     }
     return(true);
 }
        private void DeleteRecord()
        {
            dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
            Label lblAverageRate = (Label)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("lblAverageRate");

            clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(lblAverageRate.Text);
            clsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(clsdbo_NewFactCurrencyRate);
            bool bSucess = false;

            bSucess = dbo_NewFactCurrencyRateDataClass.Delete(clsdbo_NewFactCurrencyRate);
            if (bSucess == true)
            {
                Session.Remove("dvdbo_NewFactCurrencyRate");
                LoadGriddbo_NewFactCurrencyRate();
            }
            else
            {
                ec.ShowMessage(" Delete failed. ", " Dbo. New Fact Currency Rate ");
            }
        }
示例#8
0
        private void InsertRecord()
        {
            dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();

            if (VerifyData() == true)
            {
                SetData(clsdbo_NewFactCurrencyRate);
                bool bSucess = false;
                bSucess = dbo_NewFactCurrencyRateDataClass.Add(clsdbo_NewFactCurrencyRate);
                if (bSucess == true)
                {
                    pnlForm.Visible   = false;
                    pnlSave.Visible   = false;
                    pnlGrid.Visible   = true;
                    lblMode.InnerText = "";
                    Session.Remove("dvdbo_NewFactCurrencyRate");
                    LoadGriddbo_NewFactCurrencyRate();
                }
                else
                {
                    ec.ShowMessage(" Insert failed. ", " Dbo. New Fact Currency Rate ");
                }
            }
        }
        private void UpdateRecord()
        {
            try {
                TextBox txtAverageRate  = (TextBox)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtAverageRate");
                TextBox txtCurrencyID   = (TextBox)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCurrencyID");
                TextBox txtCurrencyDate = (TextBox)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCurrencyDate");
                TextBox txtEndOfDayRate = (TextBox)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtEndOfDayRate");
                TextBox txtCurrencyKey  = (TextBox)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCurrencyKey");
                TextBox txtDateKey      = (TextBox)grddbo_NewFactCurrencyRate.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtDateKey");

                dbo_NewFactCurrencyRateClass oclsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
                dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate  = new dbo_NewFactCurrencyRateClass();
                oclsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(txtAverageRate.Text);
                oclsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(oclsdbo_NewFactCurrencyRate);

                if (VerifyData() == true)
                {
                    if (string.IsNullOrEmpty(txtAverageRate.Text))
                    {
                        clsdbo_NewFactCurrencyRate.AverageRate = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(txtAverageRate.Text);
                    }
                    if (string.IsNullOrEmpty(txtCurrencyID.Text))
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyID = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyID = txtCurrencyID.Text;
                    }
                    if (string.IsNullOrEmpty(txtCurrencyDate.Text))
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyDate = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyDate = System.Convert.ToDateTime(txtCurrencyDate.Text);
                    }
                    if (string.IsNullOrEmpty(txtEndOfDayRate.Text))
                    {
                        clsdbo_NewFactCurrencyRate.EndOfDayRate = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.EndOfDayRate = System.Convert.ToDecimal(txtEndOfDayRate.Text);
                    }
                    if (string.IsNullOrEmpty(txtCurrencyKey.Text))
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyKey = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyKey = System.Convert.ToInt32(txtCurrencyKey.Text);
                    }
                    if (string.IsNullOrEmpty(txtDateKey.Text))
                    {
                        clsdbo_NewFactCurrencyRate.DateKey = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.DateKey = System.Convert.ToInt32(txtDateKey.Text);
                    }
                    bool bSucess = false;
                    bSucess = dbo_NewFactCurrencyRateDataClass.Update(oclsdbo_NewFactCurrencyRate, clsdbo_NewFactCurrencyRate);
                    if (bSucess == true)
                    {
                        Session.Remove("dvdbo_NewFactCurrencyRate");
                        grddbo_NewFactCurrencyRate.EditIndex = -1;
                        LoadGriddbo_NewFactCurrencyRate();
                    }
                    else
                    {
                        ec.ShowMessage(" Update failed. ", " Dbo. New Fact Currency Rate ");
                    }
                }
            } catch {
            }
        }
        private void InsertRecord()
        {
            try {
                TextBox txtNewAverageRate  = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewAverageRate");
                TextBox txtNewCurrencyID   = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewCurrencyID");
                TextBox txtNewCurrencyDate = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewCurrencyDate");
                TextBox txtNewEndOfDayRate = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewEndOfDayRate");
                TextBox txtNewCurrencyKey  = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewCurrencyKey");
                TextBox txtNewDateKey      = (TextBox)grddbo_NewFactCurrencyRate.FooterRow.FindControl("txtNewDateKey");

                dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();
                if (VerifyDataNew() == true)
                {
                    if (string.IsNullOrEmpty(txtNewAverageRate.Text))
                    {
                        clsdbo_NewFactCurrencyRate.AverageRate = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(txtNewAverageRate.Text);
                    }
                    if (string.IsNullOrEmpty(txtNewCurrencyID.Text))
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyID = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyID = txtNewCurrencyID.Text;
                    }
                    if (string.IsNullOrEmpty(txtNewCurrencyDate.Text))
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyDate = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyDate = System.Convert.ToDateTime(txtNewCurrencyDate.Text);
                    }
                    if (string.IsNullOrEmpty(txtNewEndOfDayRate.Text))
                    {
                        clsdbo_NewFactCurrencyRate.EndOfDayRate = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.EndOfDayRate = System.Convert.ToDecimal(txtNewEndOfDayRate.Text);
                    }
                    if (string.IsNullOrEmpty(txtNewCurrencyKey.Text))
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyKey = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.CurrencyKey = System.Convert.ToInt32(txtNewCurrencyKey.Text);
                    }
                    if (string.IsNullOrEmpty(txtNewDateKey.Text))
                    {
                        clsdbo_NewFactCurrencyRate.DateKey = null;
                    }
                    else
                    {
                        clsdbo_NewFactCurrencyRate.DateKey = System.Convert.ToInt32(txtNewDateKey.Text);
                    }
                    bool bSucess = false;
                    bSucess = dbo_NewFactCurrencyRateDataClass.Add(clsdbo_NewFactCurrencyRate);
                    if (bSucess == true)
                    {
                        Session.Remove("dvdbo_NewFactCurrencyRate");
                        LoadGriddbo_NewFactCurrencyRate();
                    }
                    else
                    {
                        ec.ShowMessage(" Insert failed. ", " Dbo. New Fact Currency Rate ");
                    }
                }
            } catch {
            }
        }
示例#11
0
        private void GetData()
        {
            ClearRecord();

            dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate = new dbo_NewFactCurrencyRateClass();

            clsdbo_NewFactCurrencyRate.AverageRate = System.Convert.ToDecimal(Session["AverageRate"]);
            clsdbo_NewFactCurrencyRate             = dbo_NewFactCurrencyRateDataClass.Select_Record(clsdbo_NewFactCurrencyRate);

            if ((clsdbo_NewFactCurrencyRate != null))
            {
                try {
                    if (clsdbo_NewFactCurrencyRate.AverageRate == null)
                    {
                        txtAverageRate.Text = default(string);
                    }
                    else
                    {
                        txtAverageRate.Text = System.Convert.ToString(clsdbo_NewFactCurrencyRate.AverageRate);
                    }
                    if (clsdbo_NewFactCurrencyRate.CurrencyID == null)
                    {
                        txtCurrencyID.Text = default(string);
                    }
                    else
                    {
                        txtCurrencyID.Text = System.Convert.ToString(clsdbo_NewFactCurrencyRate.CurrencyID);
                    }
                    if (clsdbo_NewFactCurrencyRate.CurrencyDate == null)
                    {
                        txtCurrencyDate.Text = DateTime.Now.ToString();
                    }
                    else
                    {
                        txtCurrencyDate.Text = System.Convert.ToDateTime(clsdbo_NewFactCurrencyRate.CurrencyDate).ToShortDateString();
                    }
                    if (clsdbo_NewFactCurrencyRate.EndOfDayRate == null)
                    {
                        txtEndOfDayRate.Text = default(string);
                    }
                    else
                    {
                        txtEndOfDayRate.Text = System.Convert.ToString(clsdbo_NewFactCurrencyRate.EndOfDayRate);
                    }
                    if (clsdbo_NewFactCurrencyRate.CurrencyKey == null)
                    {
                        txtCurrencyKey.Text = default(string);
                    }
                    else
                    {
                        txtCurrencyKey.Text = System.Convert.ToString(clsdbo_NewFactCurrencyRate.CurrencyKey);
                    }
                    if (clsdbo_NewFactCurrencyRate.DateKey == null)
                    {
                        txtDateKey.Text = default(string);
                    }
                    else
                    {
                        txtDateKey.Text = System.Convert.ToString(clsdbo_NewFactCurrencyRate.DateKey);
                    }
                }
                catch (Exception ex)
                {
                    ec.ShowMessage(ex.Message, " Dbo. New Fact Currency Rate ");
                }
            }
        }
    public static bool Delete(dbo_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        deleteStatement
            = "DELETE FROM "
              + "     [dbo].[NewFactCurrencyRate] "
              + "WHERE "
              + "     ((@OldAverageRate IS NULL AND [AverageRate] IS NULL) OR [AverageRate] = @OldAverageRate) "
              + " AND ((@OldCurrencyID IS NULL AND [CurrencyID] IS NULL) OR [CurrencyID] = @OldCurrencyID) "
              + " AND ((@OldCurrencyDate IS NULL AND [CurrencyDate] IS NULL) OR [CurrencyDate] = @OldCurrencyDate) "
              + " AND ((@OldEndOfDayRate IS NULL AND [EndOfDayRate] IS NULL) OR [EndOfDayRate] = @OldEndOfDayRate) "
              + " AND ((@OldCurrencyKey IS NULL AND [CurrencyKey] IS NULL) OR [CurrencyKey] = @OldCurrencyKey) "
              + " AND ((@OldDateKey IS NULL AND [DateKey] IS NULL) OR [DateKey] = @OldDateKey) "
              + "";
        SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

        deleteCommand.CommandType = CommandType.Text;
        if (clsdbo_NewFactCurrencyRate.AverageRate.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldAverageRate", clsdbo_NewFactCurrencyRate.AverageRate);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldAverageRate", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.CurrencyID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldCurrencyID", clsdbo_NewFactCurrencyRate.CurrencyID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldCurrencyID", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.CurrencyDate.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldCurrencyDate", clsdbo_NewFactCurrencyRate.CurrencyDate);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldCurrencyDate", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.EndOfDayRate.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldEndOfDayRate", clsdbo_NewFactCurrencyRate.EndOfDayRate);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldEndOfDayRate", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.CurrencyKey.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldCurrencyKey", clsdbo_NewFactCurrencyRate.CurrencyKey);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldCurrencyKey", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.DateKey.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldDateKey", clsdbo_NewFactCurrencyRate.DateKey);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldDateKey", 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_NewFactCurrencyRateClass olddbo_NewFactCurrencyRateClass,
                              dbo_NewFactCurrencyRateClass newdbo_NewFactCurrencyRateClass)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        updateStatement
            = "UPDATE "
              + "     [dbo].[NewFactCurrencyRate] "
              + "SET "
              + "     [AverageRate] = @NewAverageRate "
              + "    ,[CurrencyID] = @NewCurrencyID "
              + "    ,[CurrencyDate] = @NewCurrencyDate "
              + "    ,[EndOfDayRate] = @NewEndOfDayRate "
              + "    ,[CurrencyKey] = @NewCurrencyKey "
              + "    ,[DateKey] = @NewDateKey "
              + "WHERE "
              + "     ((@OldAverageRate IS NULL AND [AverageRate] IS NULL) OR [AverageRate] = @OldAverageRate) "
              + " AND ((@OldCurrencyID IS NULL AND [CurrencyID] IS NULL) OR [CurrencyID] = @OldCurrencyID) "
              + " AND ((@OldCurrencyDate IS NULL AND [CurrencyDate] IS NULL) OR [CurrencyDate] = @OldCurrencyDate) "
              + " AND ((@OldEndOfDayRate IS NULL AND [EndOfDayRate] IS NULL) OR [EndOfDayRate] = @OldEndOfDayRate) "
              + " AND ((@OldCurrencyKey IS NULL AND [CurrencyKey] IS NULL) OR [CurrencyKey] = @OldCurrencyKey) "
              + " AND ((@OldDateKey IS NULL AND [DateKey] IS NULL) OR [DateKey] = @OldDateKey) "
              + "";
        SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

        updateCommand.CommandType = CommandType.Text;
        if (newdbo_NewFactCurrencyRateClass.AverageRate.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewAverageRate", newdbo_NewFactCurrencyRateClass.AverageRate);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewAverageRate", DBNull.Value);
        }
        if (newdbo_NewFactCurrencyRateClass.CurrencyID != null)
        {
            updateCommand.Parameters.AddWithValue("@NewCurrencyID", newdbo_NewFactCurrencyRateClass.CurrencyID);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewCurrencyID", DBNull.Value);
        }
        if (newdbo_NewFactCurrencyRateClass.CurrencyDate.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewCurrencyDate", newdbo_NewFactCurrencyRateClass.CurrencyDate);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewCurrencyDate", DBNull.Value);
        }
        if (newdbo_NewFactCurrencyRateClass.EndOfDayRate.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewEndOfDayRate", newdbo_NewFactCurrencyRateClass.EndOfDayRate);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewEndOfDayRate", DBNull.Value);
        }
        if (newdbo_NewFactCurrencyRateClass.CurrencyKey.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewCurrencyKey", newdbo_NewFactCurrencyRateClass.CurrencyKey);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewCurrencyKey", DBNull.Value);
        }
        if (newdbo_NewFactCurrencyRateClass.DateKey.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewDateKey", newdbo_NewFactCurrencyRateClass.DateKey);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewDateKey", DBNull.Value);
        }
        if (olddbo_NewFactCurrencyRateClass.AverageRate.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldAverageRate", olddbo_NewFactCurrencyRateClass.AverageRate);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldAverageRate", DBNull.Value);
        }
        if (olddbo_NewFactCurrencyRateClass.CurrencyID != null)
        {
            updateCommand.Parameters.AddWithValue("@OldCurrencyID", olddbo_NewFactCurrencyRateClass.CurrencyID);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldCurrencyID", DBNull.Value);
        }
        if (olddbo_NewFactCurrencyRateClass.CurrencyDate.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldCurrencyDate", olddbo_NewFactCurrencyRateClass.CurrencyDate);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldCurrencyDate", DBNull.Value);
        }
        if (olddbo_NewFactCurrencyRateClass.EndOfDayRate.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldEndOfDayRate", olddbo_NewFactCurrencyRateClass.EndOfDayRate);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldEndOfDayRate", DBNull.Value);
        }
        if (olddbo_NewFactCurrencyRateClass.CurrencyKey.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldCurrencyKey", olddbo_NewFactCurrencyRateClass.CurrencyKey);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldCurrencyKey", DBNull.Value);
        }
        if (olddbo_NewFactCurrencyRateClass.DateKey.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldDateKey", olddbo_NewFactCurrencyRateClass.DateKey);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldDateKey", 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_NewFactCurrencyRateClass clsdbo_NewFactCurrencyRate)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        insertStatement
            = "INSERT "
              + "     [dbo].[NewFactCurrencyRate] "
              + "     ( "
              + "     [AverageRate] "
              + "    ,[CurrencyID] "
              + "    ,[CurrencyDate] "
              + "    ,[EndOfDayRate] "
              + "    ,[CurrencyKey] "
              + "    ,[DateKey] "
              + "     ) "
              + "VALUES "
              + "     ( "
              + "     @AverageRate "
              + "    ,@CurrencyID "
              + "    ,@CurrencyDate "
              + "    ,@EndOfDayRate "
              + "    ,@CurrencyKey "
              + "    ,@DateKey "
              + "     ) "
              + "";
        SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

        insertCommand.CommandType = CommandType.Text;
        if (clsdbo_NewFactCurrencyRate.AverageRate.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@AverageRate", clsdbo_NewFactCurrencyRate.AverageRate);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@AverageRate", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.CurrencyID != null)
        {
            insertCommand.Parameters.AddWithValue("@CurrencyID", clsdbo_NewFactCurrencyRate.CurrencyID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@CurrencyID", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.CurrencyDate.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@CurrencyDate", clsdbo_NewFactCurrencyRate.CurrencyDate);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@CurrencyDate", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.EndOfDayRate.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@EndOfDayRate", clsdbo_NewFactCurrencyRate.EndOfDayRate);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@EndOfDayRate", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.CurrencyKey.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@CurrencyKey", clsdbo_NewFactCurrencyRate.CurrencyKey);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@CurrencyKey", DBNull.Value);
        }
        if (clsdbo_NewFactCurrencyRate.DateKey.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@DateKey", clsdbo_NewFactCurrencyRate.DateKey);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@DateKey", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }