public int Add(IExpense expenseDomain)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Expenses.Expense_Add);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseTypeId, expenseDomain.ExpenseType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseDate, expenseDomain.ExpenseDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Description, expenseDomain.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Comments, expenseDomain.Comments);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Amount, expenseDomain.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.UserId, expenseDomain.CurrentUser.UserId);
            object result = cmd.ExecuteScalar();

            conn.Close();
            return(int.Parse(result.ToString()));
        }
Example #2
0
        public int AddIncome(IIncome income)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Incomes.INCOME_ADD);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.USERId, income.UserId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMETYPEID, income.IncomeType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.AMOUNT, income.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMEDATE, income.IncomeDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.DESCRIPTION, income.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.COMMENTS, income.Comments);
            int incomeTypeId = int.Parse(cmd.ExecuteScalar().ToString());

            conn.Close();
            return(incomeTypeId);
        }
        public void Update(IExpense expenseDomain)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Expenses.Expense_Update);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseId, expenseDomain.Id);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.UserId, expenseDomain.CurrentUser.UserId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseTypeId, expenseDomain.ExpenseType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseDate, expenseDomain.ExpenseDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Description, expenseDomain.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Comments, expenseDomain.Comments);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Amount, expenseDomain.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.MODIFIEDBY, expenseDomain.CurrentUser.UserId);
            cmd.ExecuteNonQuery();
            cmd.Dispose(); //ToDo ==> If this is success ,implement this in all methods...
            conn.Close();
        }
Example #4
0
        public void Update(IIncome incomeDomain)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Incomes.Income_Update);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMEID, incomeDomain.IncomeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.USERId, incomeDomain.UserId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMETYPEID, incomeDomain.IncomeType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMEDATE, incomeDomain.IncomeDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.DESCRIPTION, incomeDomain.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.COMMENTS, incomeDomain.Comments);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.AMOUNT, incomeDomain.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.MODIFIEDBY, incomeDomain.UserId);
            cmd.ExecuteNonQuery();
            cmd.Dispose(); //ToDo ==> If this is success ,implement this in all methods...
            conn.Close();
        }
Example #5
0
        public int UploadImage(IImage image)
        {
            int uploadedImageId = -1;

            if (image == null)
            {
                return(uploadedImageId);
            }

            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Image.Image_Add);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Image.Parameters.IMAGE, image.UserImage);
            object result = cmd.ExecuteScalar();

            if (result != null)
            {
                uploadedImageId = int.Parse(result.ToString());
            }
            ;
            return(uploadedImageId);
        }