Example #1
0
    public int AddNewEarningDeduction(EarningDeductionBO ed)//arguments are required. Fill them later when BO is created.
    {
        SQLHelper helper = SQLHelper.GetInstance(this.connectionString);
        int       numberOfRowImpacted = 0;

        try
        {
            helper.OpenConnection();
            //query to add new earning
            query = @"INSERT INTO [dbo].[EarningsAndDeductionsDescription]
                           ([ED_code]
                           ,[ED_type]
                           ,[ED_name]
                           ,[ED_scale]
                           ,[ED_description]
                           ,[ED_isFixedOrVariable]
                           ,[ED_value]
                           ,[ED_eligibilityConditionOperator]
                           ,[ED_eligibiltyConditionValue]
                           ,[ED_maxValue]
                           ,[ED_category]
                           ,[ED_subcategory]
                           ,[ED_WEF_monthYear]
                           ,[ED_forAll])
                     VALUES
                           (   " +
                    "SELECT CAST((SELECT TOP 1 ed.[ED_code] FROM[dbo].[EarningsAndDeductionsDescription] as ed ORDER BY CAST(ed.[ED_code] as int) DESC)+1 as varchar)," +
                    "'" + ed.EDtype + "'," +
                    "'" + ed.EDname + "'," +
                    "'" + ed.EDscale + "'," +
                    "'" + ed.EDdescription + "'," +
                    "'" + ed.EDfixOrVar + "'," +
                    "'" + ed.EDvalue + "'," +
                    "'" + ed.EDeligibilityCondOp + "'," +
                    "'" + ed.EDeligibiltyCondValue + "'," +
                    "'" + ed.EDmaxValue + "'," +
                    "'" + ed.EDcategory + "'," +
                    "'" + ed.EDsubcategory + "'," +
                    "'" + ed.EDmonthYear + "'," +
                    "'" + ed.EDforAll + "')";

            numberOfRowImpacted = helper.ExecuteNonQuery(query);
        }
        catch (Exception ex)
        {
            numberOfRowImpacted = -1;
            Console.WriteLine(ex.Message);
            dbErrMsg = ex.Message;
        }
        finally
        {
            helper.CloseConnection();
        }

        return(numberOfRowImpacted);
    }
Example #2
0
    public int UpdateEarningDeduction(EarningDeductionBO ed)
    {
        SQLHelper helper = SQLHelper.GetInstance(this.connectionString);
        int       numberOfRowImpacted = 0;

        try
        {
            helper.OpenConnection();
            //query to add new earning
            query = @"UPDATE [dbo].[EarningsAndDeductionsDescription]
                       SET " +
                    ",[ED_name] = '" + ed.EDname + "'" +
                    ",[ED_scale] = '" + ed.EDscale + "'" +
                    ",[ED_description] = '" + ed.EDdescription + "'" +
                    ",[ED_isFixedOrVariable] = '" + ed.EDfixOrVar + "'" +
                    ",[ED_value] = '" + ed.EDvalue + "'" +
                    ",[ED_eligibilityConditionOperator] = '" + ed.EDeligibilityCondOp + "'" +
                    ",[ED_eligibiltyConditionValue] = '" + ed.EDeligibiltyCondValue + "'" +
                    ",[ED_maxValue] = '" + ed.EDmaxValue + "'" +
                    ",[ED_category] = '" + ed.EDcategory + "'" +
                    ",[ED_subcategory] = '" + ed.EDsubcategory + "'" +
                    ",[ED_WEF_monthYear] = '" + ed.EDmonthYear + "'" +
                    ",[ED_forAll] = '" + ed.EDforAll + "'" +
                    "WHERE [ED_code] LIKE '" + ed.EDid + "'";

            numberOfRowImpacted = helper.ExecuteNonQuery(query);
        }
        catch (Exception ex)
        {
            numberOfRowImpacted = -1;
            Console.WriteLine(ex.Message);
            dbErrMsg = ex.Message;
        }
        finally
        {
            helper.CloseConnection();
        }

        return(numberOfRowImpacted);
    }