Esempio n. 1
0
        public void UpdateFiscalYear(SqlTransaction sqlTransaction, FiscalYear fiscalYear)
        {
            const string sqlText =
                   @"UPDATE FiscalYear
                    SET close_date = @close_date,
                    open_date = @open_date,
                    name = @name
                    WHERE id = @id";
            using (OpenCbsCommand command = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
            {
                if (fiscalYear.OpenDate != null)
                {
                    command.AddParam("@open_date", ((DateTime)fiscalYear.OpenDate).Date);
                }
                else
                {
                    command.AddParam("@open_date", null);
                }

                if (fiscalYear.CloseDate != null)
                {
                    command.AddParam("@close_date", ((DateTime)fiscalYear.CloseDate).Date);
                }
                else
                {
                    command.AddParam("@close_date", null);
                }
                command.AddParam("@name", fiscalYear.Name);
                command.AddParam("@id", fiscalYear.Id);
                command.ExecuteNonQuery();
            }
        }
Esempio n. 2
0
 public void DeleteFiscalYear(SqlTransaction sqlTransaction, FiscalYear fiscalYear)
 {
     const string sqlText =
            @"DELETE FROM dbo.FiscalYear
              WHERE id = @id";
     using (OpenCbsCommand command = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
     {
         command.AddParam("@id", fiscalYear.Id);
         command.ExecuteNonQuery();
     }
 }
Esempio n. 3
0
        public void InsertFiscalYear(SqlTransaction sqlTransaction, FiscalYear fiscalYear)
        {
            const string sqlText =
                   @"INSERT INTO dbo.FiscalYear
                            ( name ,
                              open_date ,
                              close_date
                            )
                    VALUES  ( @name ,
                              @open_date ,
                              @close_date
                            )";
            using (OpenCbsCommand command = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
            {
                command.AddParam("@name", fiscalYear.Name);
                if (fiscalYear.OpenDate != null)
                {
                    command.AddParam("@open_date", ((DateTime) fiscalYear.OpenDate).Date);
                }
                else
                {
                    command.AddParam("@open_date", null);
                }

                if (fiscalYear.CloseDate != null)
                {
                    command.AddParam("@close_date", ((DateTime) fiscalYear.CloseDate).Date);
                }
                else
                {
                    command.AddParam("@close_date", null);
                }

                command.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
 public void UpdateFiscalYear(FiscalYear fiscalYear)
 {
     using (SqlConnection conn = _accountManagement.GetConnection())
     {
         SqlTransaction sqlTransac = conn.BeginTransaction();
         try
         {
             _accountManagement.UpdateFiscalYear(sqlTransac, fiscalYear);
             sqlTransac.Commit();
         }
         catch (Exception ex)
         {
             sqlTransac.Rollback();
             throw ex;
         }
     }
 }