Exemplo n.º 1
0
        private SyncToDepartmentObject GetSyncData(SyncToDepartmentObject syncToDept)
        {
            PosDatabase database = PosDatabase.Instance;
            syncToDept.StockDefinitionStatus = database.ExecuteQueryAll("CRL_STK_DEF_STAT");
            string paramMark = "";
            IDbParameters dbParameters = database.AdoTemplate.CreateDbParameters();
            dbParameters.Add("CREATE_DATE", MySqlDbType.DateTime).Value = DateTime.MinValue;
            if (syncToDept.DepartmentInfo)
            {
                IDbParametersBuilder builder = new DbParametersBuilder(database.DbProvider);
                //builder.Create().Name("update_date").Type(DbType.DateTime).Value(syncToDept.LastSyncTime);
                syncToDept.DepartmentList = database.ExecuteQueryAll("CRL_DEPT");
            }

            if (syncToDept.ProductMasterInfo)
            {

                syncToDept.ProductType = database.ExecuteQueryAll("CRL_PRD_TYP");
                syncToDept.Category = database.ExecuteQueryAll("CRL_CAT");
                syncToDept.ProductMaster = database.ExecuteQueryAll("CRL_PRD_MST");
                syncToDept.ProductColor = database.ExecuteQueryAll("CRL_EX_PRD_COLOR");
                syncToDept.ProductSize = database.ExecuteQueryAll("CRL_EX_PRD_SIZE");
                syncToDept.Product = database.ExecuteQueryAll("CRL_PRD");

                syncToDept.Prices = database.ExecuteQueryAll("CRL_MN_PRICE");
            }
            else
            {
                if (syncToDept.PriceInfo)
                {
                    syncToDept.Prices = database.ExecuteQueryAll("CRL_MN_PRICE");
                }
            }
            string whereQuery = " CREATE_DATE>@CREATE_DATE";
            syncToDept.StockOut = database.ExecuteQueryAll("CRL_STK_OUT", whereQuery, dbParameters);
            syncToDept.StockOutDetail = database.ExecuteQueryAll("CRL_STK_OUT_DET", whereQuery,dbParameters);
            #region Useless
            /*if (syncToDept.DepartmentInfo)
            {
                ObjectCriteria<Department> deptCrit = new ObjectCriteria<Department>();
                deptCrit.Add(dpm => dpm.DepartmentId == syncToDept.Department.DepartmentId);
                syncToDept.Department = (Department)DepartmentDao.FindFirst(deptCrit);
            }

            if (syncToDept.ProductMasterInfo)
            {

                ProductDao.Execute(delegate(ISession session)
                {
                    string hql = "from ProductMaster fetch all properties";
                    IQuery query = session.CreateQuery(hql);
                    syncToDept.ProductMasterList = query.List<ProductMaster>();
                    return null;
                })
                ;
                syncToDept.ProductMasterList = ProductMasterDao.FindAll(new LinqCriteria<ProductMaster>());
                foreach (ProductMaster product in syncToDept.ProductMasterList)
                {
                    ProductMasterDao.Fetch(product);
                }
                syncToDept.PriceList = MainPriceDao.FindAll(new LinqCriteria<MainPrice>());
                foreach (MainPrice mainPrice in syncToDept.PriceList)
                {
                    MainPriceDao.Fetch(mainPrice);
                }
            }
            else
            {
                if (syncToDept.PriceInfo)
                {
                    syncToDept.PriceList = MainPriceDao.FindAll(new LinqCriteria<MainPrice>());
                }
            }
            LinqCriteria<StockOut> stockOutCrit = new LinqCriteria<StockOut>();
            stockOutCrit.AddCriteria(so => so.CreateDate > DateTime.Now.Subtract(new TimeSpan(3, 0, 0, 0)));
            stockOutCrit.AddCriteria(so => so.Department.DepartmentId == syncToDept.Department.DepartmentId);
            stockOutCrit.Fetch(so => so.StockOutDetails);
            IList<StockOut> stockOuts = StockOutDao.FindAll(stockOutCrit);
            foreach (StockOut stockOut in stockOuts)
            {
                StockOutDao.Fetch(stockOut);
            }
            syncToDept.StockOutList = stockOuts; */
            #endregion

            return syncToDept;
        }
Exemplo n.º 2
0
 public void UpdateDataTable(DataTable dataTable)
 {
     IDbParametersBuilder builder = new DbParametersBuilder(DbProvider);
     foreach (DataRow dataRow in dataTable.Rows)
     {
         Console.WriteLine(dataRow.ItemArray.ToString());
         Console.WriteLine(dataRow.RowState.ToString());
     }
     AdoTemplate.DataTableUpdateWithCommandBuilder(dataTable, CommandType.Text, "SELECT * FROM " + dataTable.TableName,
                                                   builder.GetParameters(), dataTable.TableName);
 }
Exemplo n.º 3
0
 public void FastUpdateDataTable(DataTable dataTable,string tableName)
 {
     DataTable current = ExecuteQueryAll(tableName);
     current.TableName = tableName;
     ReflectUpdateTable(current, dataTable);
     IDbParametersBuilder builder = new DbParametersBuilder(DbProvider);
     AdoTemplate.DataTableUpdateWithCommandBuilder(current.GetChanges(), CommandType.Text, "SELECT * FROM " + current.TableName,
                                                   builder.GetParameters(), current.TableName);
     // submit changes
     //Flush the session to execute sql in the db.
     SessionFactoryUtils.GetSession(SessionFactory, true).Flush();
 }
Exemplo n.º 4
0
 public void UpdateDataTable(DataTable source,DataTable changes)
 {
     IDbParametersBuilder builder = new DbParametersBuilder(DbProvider);
     source.Merge(changes);
     AdoTemplate.DataTableUpdateWithCommandBuilder(source, CommandType.Text, "SELECT * FROM " + source.TableName,
                                                   builder.GetParameters(), source.TableName);
 }
Exemplo n.º 5
0
        public FlightCollection GetFlights(Airport origin, Airport destination, DateTime departureDate)
        {
            #region Sanity Checks
            AssertUtils.ArgumentNotNull(origin, "origin");
            AssertUtils.ArgumentNotNull(destination, "destination");
            #endregion

            FlightCollection flights = new FlightCollection();
            
            
            IDbParametersBuilder builder = new DbParametersBuilder(DbProvider);
            builder.Create().Name("departureDate").Type(DbType.Date).Value(departureDate);
            builder.Create().Name("departureAirport").Type(DbType.Int32).Value(origin.Id);
            builder.Create().Name("destinationAirport").Type(DbType.Int32).Value(destination.Id);

#if NET_2_0            
            AdoTemplate.QueryWithRowCallbackDelegate(CommandType.Text, FlightsQuery, 
                                                 delegate(IDataReader dataReader)
                                                 {
                                                     int flightId = dataReader.GetInt32(0);
                                                     string flightNumber = dataReader.GetString(1);
                                                     Aircraft aircraft = aircraftDao.GetAircraft(dataReader.GetInt32(2));

                                                     //TODO: Load cabins from the database
                                                     Cabin[] cabins = aircraft.Cabins;

                                                     Flight flight = new Flight(flightId, flightNumber, origin, destination, aircraft, departureDate, cabins);
                                                     flights.Add(flight); 
                                                 }, 
                                             
                                             
                                             builder.GetParameters());
#else
      AdoTemplate.QueryWithRowCallback(CommandType.Text, FlightsQuery,
                                        new FlightRowCallback(flights, aircraftDao, origin,destination,departureDate ),
                                        builder.GetParameters());      
#endif
            
            
            /*
            IDbCommand command = GetCommand(FlightsQuery);
            using(new ConnectionManager(command.Connection))
            {
                SetFlightQueryParameters(command, departureDate, origin.Id, destination.Id);
                using (SqlDataReader reader = (SqlDataReader) command.ExecuteReader())
                {
                    while(reader.Read())
                    {
                        int flightId = reader.GetInt32(0);
                        string flightNumber = reader.GetString(1);
                        Aircraft aircraft = aircraftDao.GetAircraft(reader.GetInt32(2));

                        //TODO: Load cabins from the database
                        Cabin[] cabins = aircraft.Cabins;

                        Flight flight = new Flight(flightId, flightNumber, origin, destination, aircraft, departureDate, cabins);
                        flights.Add(flight);
                    }
                }
            }
             */
            return flights;
        }