Esempio n. 1
0
        private void UpdateRecord()
        {
            dbo_FactFinanceClass oclsdbo_FactFinance = new dbo_FactFinanceClass();
            dbo_FactFinanceClass clsdbo_FactFinance  = new dbo_FactFinanceClass();

            oclsdbo_FactFinance.FinanceKey = System.Convert.ToInt32(Session["FinanceKey"]);
            oclsdbo_FactFinance            = dbo_FactFinanceDataClass.Select_Record(oclsdbo_FactFinance);

            if (VerifyData() == true)
            {
                SetData(clsdbo_FactFinance);
                bool bSucess = false;
                bSucess = dbo_FactFinanceDataClass.Update(oclsdbo_FactFinance, clsdbo_FactFinance);
                if (bSucess == true)
                {
                    pnlForm.Visible   = false;
                    pnlSave.Visible   = false;
                    pnlGrid.Visible   = true;
                    lblMode.InnerText = "";
                    Session.Remove("dvdbo_FactFinance");
                    LoadGriddbo_FactFinance();
                }
                else
                {
                    ec.ShowMessage(" Update failed. ", " Dbo. Fact Finance ");
                }
            }
        }
Esempio n. 2
0
        private void GetData()
        {
            ClearRecord();

            dbo_FactFinanceClass clsdbo_FactFinance = new dbo_FactFinanceClass();

            clsdbo_FactFinance.FinanceKey = System.Convert.ToInt32(Session["FinanceKey"]);
            clsdbo_FactFinance            = dbo_FactFinanceDataClass.Select_Record(clsdbo_FactFinance);

            if ((clsdbo_FactFinance != null))
            {
                try {
                    txtFinanceKey.Text                  = System.Convert.ToString(clsdbo_FactFinance.FinanceKey);
                    txtDateKey.SelectedValue            = System.Convert.ToString(clsdbo_FactFinance.DateKey);
                    txtOrganizationKey.SelectedValue    = System.Convert.ToString(clsdbo_FactFinance.OrganizationKey);
                    txtDepartmentGroupKey.SelectedValue = System.Convert.ToString(clsdbo_FactFinance.DepartmentGroupKey);
                    txtScenarioKey.SelectedValue        = System.Convert.ToString(clsdbo_FactFinance.ScenarioKey);
                    txtAccountKey.SelectedValue         = System.Convert.ToString(clsdbo_FactFinance.AccountKey);
                    txtAmount.Text = System.Convert.ToString(clsdbo_FactFinance.Amount);
                    if (clsdbo_FactFinance.Date == null)
                    {
                        txtDate.Text = DateTime.Now.ToString();
                    }
                    else
                    {
                        txtDate.Text = System.Convert.ToDateTime(clsdbo_FactFinance.Date).ToShortDateString();
                    }
                }
                catch (Exception ex)
                {
                    ec.ShowMessage(ex.Message, " Dbo. Fact Finance ");
                }
            }
        }
    public static bool Delete(dbo_FactFinanceClass clsdbo_FactFinance)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        deleteStatement
            = "DELETE FROM "
              + "     [dbo].[FactFinance] "
              + "WHERE "
              + "     [FinanceKey] = @OldFinanceKey "
              + " AND [DateKey] = @OldDateKey "
              + " AND [OrganizationKey] = @OldOrganizationKey "
              + " AND [DepartmentGroupKey] = @OldDepartmentGroupKey "
              + " AND [ScenarioKey] = @OldScenarioKey "
              + " AND [AccountKey] = @OldAccountKey "
              + " AND [Amount] = @OldAmount "
              + " AND ((@OldDate IS NULL AND [Date] IS NULL) OR [Date] = @OldDate) "
              + "";
        SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

        deleteCommand.CommandType = CommandType.Text;
        deleteCommand.Parameters.AddWithValue("@OldFinanceKey", clsdbo_FactFinance.FinanceKey);
        deleteCommand.Parameters.AddWithValue("@OldDateKey", clsdbo_FactFinance.DateKey);
        deleteCommand.Parameters.AddWithValue("@OldOrganizationKey", clsdbo_FactFinance.OrganizationKey);
        deleteCommand.Parameters.AddWithValue("@OldDepartmentGroupKey", clsdbo_FactFinance.DepartmentGroupKey);
        deleteCommand.Parameters.AddWithValue("@OldScenarioKey", clsdbo_FactFinance.ScenarioKey);
        deleteCommand.Parameters.AddWithValue("@OldAccountKey", clsdbo_FactFinance.AccountKey);
        deleteCommand.Parameters.AddWithValue("@OldAmount", clsdbo_FactFinance.Amount);
        if (clsdbo_FactFinance.Date.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldDate", clsdbo_FactFinance.Date);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldDate", 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 dbo_FactFinanceClass Select_Record(dbo_FactFinanceClass clsdbo_FactFinancePara)
    {
        dbo_FactFinanceClass clsdbo_FactFinance = new dbo_FactFinanceClass();
        SqlConnection        connection         = AdventureWorksDW2012DataClass.GetConnection();
        string selectStatement
            = "SELECT "
              + "     [FinanceKey] "
              + "    ,[DateKey] "
              + "    ,[OrganizationKey] "
              + "    ,[DepartmentGroupKey] "
              + "    ,[ScenarioKey] "
              + "    ,[AccountKey] "
              + "    ,[Amount] "
              + "    ,[Date] "
              + "FROM "
              + "     [dbo].[FactFinance] "
              + "WHERE "
              + "    [FinanceKey] = @FinanceKey "
              + "";
        SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

        selectCommand.CommandType = CommandType.Text;
        selectCommand.Parameters.AddWithValue("@FinanceKey", clsdbo_FactFinancePara.FinanceKey);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_FactFinance.FinanceKey         = System.Convert.ToInt32(reader["FinanceKey"]);
                clsdbo_FactFinance.DateKey            = System.Convert.ToInt32(reader["DateKey"]);
                clsdbo_FactFinance.OrganizationKey    = System.Convert.ToInt32(reader["OrganizationKey"]);
                clsdbo_FactFinance.DepartmentGroupKey = System.Convert.ToInt32(reader["DepartmentGroupKey"]);
                clsdbo_FactFinance.ScenarioKey        = System.Convert.ToInt32(reader["ScenarioKey"]);
                clsdbo_FactFinance.AccountKey         = System.Convert.ToInt32(reader["AccountKey"]);
                clsdbo_FactFinance.Amount             = System.Convert.ToDecimal(reader["Amount"]);
                clsdbo_FactFinance.Date = reader["Date"] is DBNull ? null : (DateTime?)reader["Date"];
            }
            else
            {
                clsdbo_FactFinance = null;
            }
            reader.Close();
        }
        catch (SqlException)
        {
            return(clsdbo_FactFinance);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_FactFinance);
    }
Esempio n. 5
0
        private void UpdateRecord()
        {
            try {
                TextBox      txtFinanceKey         = (TextBox)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtFinanceKey");
                DropDownList txtDateKey            = (DropDownList)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtDateKey");
                DropDownList txtOrganizationKey    = (DropDownList)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtOrganizationKey");
                DropDownList txtDepartmentGroupKey = (DropDownList)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtDepartmentGroupKey");
                DropDownList txtScenarioKey        = (DropDownList)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtScenarioKey");
                DropDownList txtAccountKey         = (DropDownList)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtAccountKey");
                TextBox      txtAmount             = (TextBox)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtAmount");
                TextBox      txtDate = (TextBox)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtDate");

                dbo_FactFinanceClass oclsdbo_FactFinance = new dbo_FactFinanceClass();
                dbo_FactFinanceClass clsdbo_FactFinance  = new dbo_FactFinanceClass();
                oclsdbo_FactFinance.FinanceKey = System.Convert.ToInt32(txtFinanceKey.Text);
                oclsdbo_FactFinance            = dbo_FactFinanceDataClass.Select_Record(oclsdbo_FactFinance);

                if (VerifyData() == true)
                {
                    clsdbo_FactFinance.DateKey            = System.Convert.ToInt32(txtDateKey.SelectedValue);
                    clsdbo_FactFinance.OrganizationKey    = System.Convert.ToInt32(txtOrganizationKey.SelectedValue);
                    clsdbo_FactFinance.DepartmentGroupKey = System.Convert.ToInt32(txtDepartmentGroupKey.SelectedValue);
                    clsdbo_FactFinance.ScenarioKey        = System.Convert.ToInt32(txtScenarioKey.SelectedValue);
                    clsdbo_FactFinance.AccountKey         = System.Convert.ToInt32(txtAccountKey.SelectedValue);
                    clsdbo_FactFinance.Amount             = System.Convert.ToDecimal(txtAmount.Text);
                    if (string.IsNullOrEmpty(txtDate.Text))
                    {
                        clsdbo_FactFinance.Date = null;
                    }
                    else
                    {
                        clsdbo_FactFinance.Date = System.Convert.ToDateTime(txtDate.Text);
                    }
                    bool bSucess = false;
                    bSucess = dbo_FactFinanceDataClass.Update(oclsdbo_FactFinance, clsdbo_FactFinance);
                    if (bSucess == true)
                    {
                        Session.Remove("dvdbo_FactFinance");
                        grddbo_FactFinance.EditIndex = -1;
                        LoadGriddbo_FactFinance();
                    }
                    else
                    {
                        ec.ShowMessage(" Update failed. ", " Dbo. Fact Finance ");
                    }
                }
            } catch {
            }
        }
Esempio n. 6
0
 private void SetData(dbo_FactFinanceClass clsdbo_FactFinance)
 {
     clsdbo_FactFinance.DateKey            = System.Convert.ToInt32(txtDateKey.SelectedValue);
     clsdbo_FactFinance.OrganizationKey    = System.Convert.ToInt32(txtOrganizationKey.SelectedValue);
     clsdbo_FactFinance.DepartmentGroupKey = System.Convert.ToInt32(txtDepartmentGroupKey.SelectedValue);
     clsdbo_FactFinance.ScenarioKey        = System.Convert.ToInt32(txtScenarioKey.SelectedValue);
     clsdbo_FactFinance.AccountKey         = System.Convert.ToInt32(txtAccountKey.SelectedValue);
     clsdbo_FactFinance.Amount             = System.Convert.ToDecimal(txtAmount.Text);
     if (string.IsNullOrEmpty(txtDate.Text))
     {
         clsdbo_FactFinance.Date = null;
     }
     else
     {
         clsdbo_FactFinance.Date = System.Convert.ToDateTime(txtDate.Text);
     }
 }
Esempio n. 7
0
        private void Edit()
        {
            try {
                dbo_FactFinanceClass clsdbo_FactFinance = new dbo_FactFinanceClass();
                Label lblFinanceKey = (Label)grddbo_FactFinance.Rows[grddbo_FactFinance.EditIndex].FindControl("lblFinanceKey");
                clsdbo_FactFinance.FinanceKey = System.Convert.ToInt32(lblFinanceKey.Text);
                clsdbo_FactFinance            = dbo_FactFinanceDataClass.Select_Record(clsdbo_FactFinance);

                Session["DateKey_SelectedValue"]            = clsdbo_FactFinance.DateKey;
                Session["OrganizationKey_SelectedValue"]    = clsdbo_FactFinance.OrganizationKey;
                Session["DepartmentGroupKey_SelectedValue"] = clsdbo_FactFinance.DepartmentGroupKey;
                Session["ScenarioKey_SelectedValue"]        = clsdbo_FactFinance.ScenarioKey;
                Session["AccountKey_SelectedValue"]         = clsdbo_FactFinance.AccountKey;

                LoadGriddbo_FactFinance();
            } catch {
            }
        }
Esempio n. 8
0
        private void InsertRecord()
        {
            try {
                DropDownList txtNewDateKey            = (DropDownList)grddbo_FactFinance.FooterRow.FindControl("txtNewDateKey");
                DropDownList txtNewOrganizationKey    = (DropDownList)grddbo_FactFinance.FooterRow.FindControl("txtNewOrganizationKey");
                DropDownList txtNewDepartmentGroupKey = (DropDownList)grddbo_FactFinance.FooterRow.FindControl("txtNewDepartmentGroupKey");
                DropDownList txtNewScenarioKey        = (DropDownList)grddbo_FactFinance.FooterRow.FindControl("txtNewScenarioKey");
                DropDownList txtNewAccountKey         = (DropDownList)grddbo_FactFinance.FooterRow.FindControl("txtNewAccountKey");
                TextBox      txtNewAmount             = (TextBox)grddbo_FactFinance.FooterRow.FindControl("txtNewAmount");
                TextBox      txtNewDate = (TextBox)grddbo_FactFinance.FooterRow.FindControl("txtNewDate");

                dbo_FactFinanceClass clsdbo_FactFinance = new dbo_FactFinanceClass();
                if (VerifyDataNew() == true)
                {
                    clsdbo_FactFinance.DateKey            = System.Convert.ToInt32(txtNewDateKey.SelectedValue);
                    clsdbo_FactFinance.OrganizationKey    = System.Convert.ToInt32(txtNewOrganizationKey.SelectedValue);
                    clsdbo_FactFinance.DepartmentGroupKey = System.Convert.ToInt32(txtNewDepartmentGroupKey.SelectedValue);
                    clsdbo_FactFinance.ScenarioKey        = System.Convert.ToInt32(txtNewScenarioKey.SelectedValue);
                    clsdbo_FactFinance.AccountKey         = System.Convert.ToInt32(txtNewAccountKey.SelectedValue);
                    clsdbo_FactFinance.Amount             = System.Convert.ToDecimal(txtNewAmount.Text);
                    if (string.IsNullOrEmpty(txtNewDate.Text))
                    {
                        clsdbo_FactFinance.Date = null;
                    }
                    else
                    {
                        clsdbo_FactFinance.Date = System.Convert.ToDateTime(txtNewDate.Text);
                    }
                    bool bSucess = false;
                    bSucess = dbo_FactFinanceDataClass.Add(clsdbo_FactFinance);
                    if (bSucess == true)
                    {
                        Session.Remove("dvdbo_FactFinance");
                        LoadGriddbo_FactFinance();
                    }
                    else
                    {
                        ec.ShowMessage(" Insert failed. ", " Dbo. Fact Finance ");
                    }
                }
            } catch {
            }
        }
Esempio n. 9
0
        private void DeleteRecord()
        {
            dbo_FactFinanceClass clsdbo_FactFinance = new dbo_FactFinanceClass();
            Label lblFinanceKey = (Label)grddbo_FactFinance.Rows[Convert.ToInt32(Session["Row"])].FindControl("lblFinanceKey");

            clsdbo_FactFinance.FinanceKey = System.Convert.ToInt32(lblFinanceKey.Text);
            clsdbo_FactFinance            = dbo_FactFinanceDataClass.Select_Record(clsdbo_FactFinance);
            bool bSucess = false;

            bSucess = dbo_FactFinanceDataClass.Delete(clsdbo_FactFinance);
            if (bSucess == true)
            {
                Session.Remove("dvdbo_FactFinance");
                LoadGriddbo_FactFinance();
            }
            else
            {
                ec.ShowMessage(" Delete failed. ", " Dbo. Fact Finance ");
            }
        }
Esempio n. 10
0
        private void InsertRecord()
        {
            dbo_FactFinanceClass clsdbo_FactFinance = new dbo_FactFinanceClass();

            if (VerifyData() == true)
            {
                SetData(clsdbo_FactFinance);
                bool bSucess = false;
                bSucess = dbo_FactFinanceDataClass.Add(clsdbo_FactFinance);
                if (bSucess == true)
                {
                    pnlForm.Visible   = false;
                    pnlSave.Visible   = false;
                    pnlGrid.Visible   = true;
                    lblMode.InnerText = "";
                    Session.Remove("dvdbo_FactFinance");
                    LoadGriddbo_FactFinance();
                }
                else
                {
                    ec.ShowMessage(" Insert failed. ", " Dbo. Fact Finance ");
                }
            }
        }
    public static bool Update(dbo_FactFinanceClass olddbo_FactFinanceClass,
                              dbo_FactFinanceClass newdbo_FactFinanceClass)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        updateStatement
            = "UPDATE "
              + "     [dbo].[FactFinance] "
              + "SET "
              + "     [DateKey] = @NewDateKey "
              + "    ,[OrganizationKey] = @NewOrganizationKey "
              + "    ,[DepartmentGroupKey] = @NewDepartmentGroupKey "
              + "    ,[ScenarioKey] = @NewScenarioKey "
              + "    ,[AccountKey] = @NewAccountKey "
              + "    ,[Amount] = @NewAmount "
              + "    ,[Date] = @NewDate "
              + "WHERE "
              + "     [FinanceKey] = @OldFinanceKey "
              + " AND [DateKey] = @OldDateKey "
              + " AND [OrganizationKey] = @OldOrganizationKey "
              + " AND [DepartmentGroupKey] = @OldDepartmentGroupKey "
              + " AND [ScenarioKey] = @OldScenarioKey "
              + " AND [AccountKey] = @OldAccountKey "
              + " AND [Amount] = @OldAmount "
              + " AND ((@OldDate IS NULL AND [Date] IS NULL) OR [Date] = @OldDate) "
              + "";
        SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

        updateCommand.CommandType = CommandType.Text;
        updateCommand.Parameters.AddWithValue("@NewDateKey", newdbo_FactFinanceClass.DateKey);
        updateCommand.Parameters.AddWithValue("@NewOrganizationKey", newdbo_FactFinanceClass.OrganizationKey);
        updateCommand.Parameters.AddWithValue("@NewDepartmentGroupKey", newdbo_FactFinanceClass.DepartmentGroupKey);
        updateCommand.Parameters.AddWithValue("@NewScenarioKey", newdbo_FactFinanceClass.ScenarioKey);
        updateCommand.Parameters.AddWithValue("@NewAccountKey", newdbo_FactFinanceClass.AccountKey);
        updateCommand.Parameters.AddWithValue("@NewAmount", newdbo_FactFinanceClass.Amount);
        if (newdbo_FactFinanceClass.Date.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewDate", newdbo_FactFinanceClass.Date);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewDate", DBNull.Value);
        }
        updateCommand.Parameters.AddWithValue("@OldFinanceKey", olddbo_FactFinanceClass.FinanceKey);
        updateCommand.Parameters.AddWithValue("@OldDateKey", olddbo_FactFinanceClass.DateKey);
        updateCommand.Parameters.AddWithValue("@OldOrganizationKey", olddbo_FactFinanceClass.OrganizationKey);
        updateCommand.Parameters.AddWithValue("@OldDepartmentGroupKey", olddbo_FactFinanceClass.DepartmentGroupKey);
        updateCommand.Parameters.AddWithValue("@OldScenarioKey", olddbo_FactFinanceClass.ScenarioKey);
        updateCommand.Parameters.AddWithValue("@OldAccountKey", olddbo_FactFinanceClass.AccountKey);
        updateCommand.Parameters.AddWithValue("@OldAmount", olddbo_FactFinanceClass.Amount);
        if (olddbo_FactFinanceClass.Date.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldDate", olddbo_FactFinanceClass.Date);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldDate", 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_FactFinanceClass clsdbo_FactFinance)
    {
        SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection();
        string        insertStatement
            = "INSERT "
              + "     [dbo].[FactFinance] "
              + "     ( "
              + "     [DateKey] "
              + "    ,[OrganizationKey] "
              + "    ,[DepartmentGroupKey] "
              + "    ,[ScenarioKey] "
              + "    ,[AccountKey] "
              + "    ,[Amount] "
              + "    ,[Date] "
              + "     ) "
              + "VALUES "
              + "     ( "
              + "     @DateKey "
              + "    ,@OrganizationKey "
              + "    ,@DepartmentGroupKey "
              + "    ,@ScenarioKey "
              + "    ,@AccountKey "
              + "    ,@Amount "
              + "    ,@Date "
              + "     ) "
              + "";
        SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

        insertCommand.CommandType = CommandType.Text;
        insertCommand.Parameters.AddWithValue("@DateKey", clsdbo_FactFinance.DateKey);
        insertCommand.Parameters.AddWithValue("@OrganizationKey", clsdbo_FactFinance.OrganizationKey);
        insertCommand.Parameters.AddWithValue("@DepartmentGroupKey", clsdbo_FactFinance.DepartmentGroupKey);
        insertCommand.Parameters.AddWithValue("@ScenarioKey", clsdbo_FactFinance.ScenarioKey);
        insertCommand.Parameters.AddWithValue("@AccountKey", clsdbo_FactFinance.AccountKey);
        insertCommand.Parameters.AddWithValue("@Amount", clsdbo_FactFinance.Amount);
        if (clsdbo_FactFinance.Date.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Date", clsdbo_FactFinance.Date);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Date", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }