Esempio n. 1
0
        public void Pull()
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            MutableObservableCollection <CreateOrderModel> newPaymentOrder = new MutableObservableCollection <CreateOrderModel>();
            MutableObservableCollection <CreateOrderModel> newPrintOrder   = new MutableObservableCollection <CreateOrderModel>();
            MutableObservableCollection <CreateOrderModel> newQueue        = new MutableObservableCollection <CreateOrderModel>();
            KeyValueOption selectedRange = this.SelectedRange;

            if (IndexRefreshing == -1 || IndexRefreshing == 1)
            {
                newPrintOrder           = new MutableObservableCollection <CreateOrderModel>();
                newPrintOrder           = db.Query <CreateOrderModel>("GetPrintOrder", new { Between = Convert.ToInt32(selectedRange.Id) * -1 }).Convert <CreateOrderModel>();
                PrintOrderMaster.Source = newPrintOrder.Convert <CreateOrderModel>();
                GetDetails(PrintOrderMaster.Source, db);
            }
            if (IndexRefreshing == -1 || IndexRefreshing == 2)
            {
                newPaymentOrder           = new MutableObservableCollection <CreateOrderModel>();
                newPaymentOrder           = db.Query <CreateOrderModel>("GetFinishedOrder", new { Between = Convert.ToInt32(selectedRange.Id) * -1 }).Convert <CreateOrderModel>();
                PaymentOrderMaster.Source = newPaymentOrder.Convert <CreateOrderModel>();
                GetDetails(PaymentOrderMaster.Source, db);
            }
            if (IndexRefreshing == -1 || IndexRefreshing == 3)
            {
                newQueue           = new MutableObservableCollection <CreateOrderModel>();
                newQueue           = db.Query <CreateOrderModel>("GetQueue", new { Between = Convert.ToInt32(selectedRange.Id) * -1 }).Convert <CreateOrderModel>();
                QueueMaster.Source = newQueue.Convert <CreateOrderModel>();
                GetDetails(QueueMaster.Source, db);
            }

            if (string.IsNullOrEmpty(searchInput))
            {
                if (IndexRefreshing == -1 || IndexRefreshing == 1)
                {
                    PaymentOrder.CheckedHeader = false;
                    PrintOrder.Source          = newPrintOrder;
                    GetDetails(PrintOrder.Source, db);
                }
                if (IndexRefreshing == -1 || IndexRefreshing == 1)
                {
                    PrintOrder.CheckedHeader = false;
                    PaymentOrder.Source      = newPaymentOrder;
                    GetDetails(PaymentOrder.Source, db);
                }
                if (IndexRefreshing == -1 || IndexRefreshing == 1)
                {
                    Queue.CheckedHeader = false;
                    Queue.Source        = newQueue;
                    GetDetails(Queue.Source, db);
                }
            }

            db.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// 分页查询Area
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public QueryResult <QR_Area> QueryAreaList(QF_Area filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryAreaList");
            //DataCommand cmd = new DataCommand("QueryAreaList");
            cmd.QuerySetCondition("Status", ConditionOperation.NotEqual, DbType.Int32, -999);
            if (filter.ProvinceSysNo.HasValue)
            {
                cmd.QuerySetCondition("ProvinceSysNo", ConditionOperation.Equal, DbType.Int32, filter.ProvinceSysNo);
            }
            else
            {
                cmd.QuerySetCondition("and ProvinceSysNo is null");
            }
            if (filter.CitySysNo.HasValue)
            {
                cmd.QuerySetCondition("CitySysNo", ConditionOperation.Equal, DbType.String, filter.CitySysNo);
            }
            else
            {
                cmd.QuerySetCondition("and CitySysNo is null");
            }
            cmd.QuerySetCondition("SysNo", ConditionOperation.Equal, DbType.String, filter.SysNo);
            cmd.QuerySetCondition("Status", ConditionOperation.Equal, DbType.Int32, filter.Status);

            QueryResult <QR_Area> result = cmd.Query <QR_Area>(filter, "OrderNumber ASC");

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 分页查询ProductComment信息
        /// </summary>
        public QueryResult <QR_ProductComment> QueryProductCommentList(QF_ProductComment filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryProductCommentList");

            //DataCommand cmd = new DataCommand("QueryProductCommentList");

            cmd.QuerySetCondition("pc.ProductSysNo", ConditionOperation.Equal, DbType.Int32, filter.ProductSysNo);
            cmd.QuerySetCondition("pc.CommonStatus", ConditionOperation.Equal, DbType.Int32, 1);

            if (filter.Condition == 1)
            {
                cmd.QuerySetCondition("pc.Rate", ConditionOperation.MoreThan, DbType.Int32, 1);
            }
            if (filter.Condition == 2)
            {
                cmd.QuerySetCondition("pc.Rate", ConditionOperation.LessThanEqual, DbType.Int32, 1);
            }
            if (filter.Condition == 3)
            {
                cmd.QuerySetCondition("pc.HasPic", ConditionOperation.Equal, DbType.Int32, 1);
            }


            QueryResult <QR_ProductComment> result = cmd.Query <QR_ProductComment>(filter, " pc.SysNo DESC");

            return(result);
        }
Esempio n. 4
0
        public StockIn()
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

            MaterialMaster = db.Query <MaterialType>("GetMaterial");
            Material       = MaterialMaster.GroupBy(x => x.Id).Select(d => d.First()).ToList();
            db.Close();
        }
Esempio n. 5
0
        /// <summary>
        /// 预约列表
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public static QueryResult <QR_ReservationRecords> GetCustomerReservationRecords(QF_ReservationRecords filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryCustomerReservationRecords");
            //DataCommand cmd = new DataCommand("QueryCustomerReservationRecords");
            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);
            QueryResult <QR_ReservationRecords> result = cmd.Query <QR_ReservationRecords>(filter, " SysNo DESC");

            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// 分页查询RMAItem信息
        /// </summary>
        public QueryResult <QR_RMAItem> QueryRMAItemList(QF_RMAItem filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryRMAItemList");

            //DataCommand cmd = new DataCommand("QueryRMAItemList");
            QueryResult <QR_RMAItem> result = cmd.Query <QR_RMAItem>(filter, " SysNo DESC");

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 分页查询FavoriteProduct信息
        /// </summary>
        public QueryResult <FavoriteProduct> QueryFavoriteProductList(QF_FavoriteProduct filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryFavoriteProductList");

            //DataCommand cmd = new DataCommand("QueryFavoriteProductList");
            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);
            QueryResult <FavoriteProduct> result = cmd.Query <FavoriteProduct>(filter, "F.InDate DESC");

            return(result);
        }
Esempio n. 8
0
        public QueryResult <CouponReceivingRecord> QueryCouponReceivingRecordList(QF_CouponReceivingRecord filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryCouponReceivingRecordList");

            //DataCommand cmd = new DataCommand("QueryCouponReceivingRecordList");
            cmd.QuerySetCondition("UserSysNo", ConditionOperation.Like, DbType.Int32, filter.CustomerSysNo);
            QueryResult <CouponReceivingRecord> result = cmd.Query <CouponReceivingRecord>(filter, "ReceivingDate DESC");

            return(result);
        }
Esempio n. 9
0
        private void GetDetails(MutableObservableCollection <CreateOrderModel> source, IDataCommand db)
        {
            List <CreateOrderDetailModel> details;

            foreach (CreateOrderModel order in source.ToList())
            {
                order.NewOrder = false;
                details        = db.Query <CreateOrderDetailModel>("GetOrderDetail", new { OrderId = order.PoNumber });
                if (details.Any())
                {
                    order.Details.Source = details.Convert <CreateOrderDetailModel>();
                    foreach (CreateOrderDetailModel detail in order.Details.Source.ToList())
                    {
                        detail.Finishing      = db.Query <KeyValueOption>("GetFinishing");
                        detail.Size           = db.Query <KeyValueOption>("GetSize");
                        detail.Quality        = ObjectPool.Instance.Resolve <List <QualityType> >();
                        detail.MaterialMaster = db.Query <MaterialType>("GetMaterial");
                        detail.Material       = detail.MaterialMaster.GroupBy(x => x.Id).Select(d => d.First()).ToList();
                    }
                }
            }
        }
Esempio n. 10
0
        public static QueryResult <QR_Recharge> QueryCustomerRechargeList(QF_Recharge filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryCustomerRechargeList");

            //DataCommand cmd = new DataCommand("QueryCustomerRechargeList");
            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);
            cmd.QuerySetCondition("RechargeStatus", ConditionOperation.NotEqual, DbType.Int32, -2);
            QueryResult <QR_Recharge> result = cmd.Query <QR_Recharge>(filter, " SysNo DESC");

            return(result);
        }
Esempio n. 11
0
        public static QueryResult <QR_Consum> QueryCustomerConsumList(QF_Consum filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryCustomerConsumList");

            //DataCommand cmd = new DataCommand("QueryCustomerConsumList");
            cmd.QuerySetCondition("ND.NursingStatus", ConditionOperation.NotIn, DbType.Int32, "0");
            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);
            QueryResult <QR_Consum> result = cmd.Query <QR_Consum>(filter, " ND.SysNo DESC");

            return(result);
        }
Esempio n. 12
0
        public void Pull()
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

            //int stockType = -1;
            //if (stockTypeSync == StockType.All)
            //    stockType = 100;

            //if (stockType == 100 || stockTypeSync == StockType.Summary)
            //    Summary.Source = db.Query<TransactionStock>("GetSummary", new { Between = Convert.ToInt32(this.SelectedRange.Id) * -1 }).Convert<TransactionStock>();

            //if (stockType == 100 || stockTypeSync == StockType.Transaction)
            //    Transaction.Source = db.Query<TransactionStock>("GetTransactionStock", new { Between = Convert.ToInt32(this.SelectedRange.Id) * -1 }).Convert<TransactionStock>();

            Summary.Source     = db.Query <TransactionStock>("GetSummary", new { Between = Convert.ToInt32(this.SelectedRange.Id) * -1 }).Convert <TransactionStock>();
            Transaction.Source = db.Query <TransactionStock>("GetTransactionStock", new { Between = Convert.ToInt32(this.SelectedRange.Id) * -1 }).Convert <TransactionStock>();

            SearchCommand = new DelegateCommand(new Action(OnSearch));

            db.Close();
        }
Esempio n. 13
0
        private string GetNextPoNumber(params object[] args)
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List <int>   result    = db.Query <int>("GetNextPoNumber", args);
            int          counter   = 0;

            if (result.Any())
            {
                counter += result[0] + 1;
            }
            db.Close();
            return(counter.ToString("000"));
        }
Esempio n. 14
0
        /// <summary>
        /// 分页查询Topic信息
        /// </summary>
        public QueryResult <QR_Topic> QueryTopicList(QF_Topic filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryTopicList");

            //DataCommand cmd = new DataCommand("QueryTopicList");
            cmd.QuerySetCondition("TopicCategorySysNo", ConditionOperation.Equal, DbType.Int32, filter.TopicCategorySysNo);
            cmd.QuerySetCondition("TopicStatus", ConditionOperation.Equal, DbType.Int32, 1);
            cmd.QuerySetCondition("StartTime", ConditionOperation.LessThanEqual, DbType.DateTime, DateTime.Now);
            cmd.QuerySetCondition("EndTime", ConditionOperation.MoreThanEqual, DbType.DateTime, DateTime.Now);
            QueryResult <QR_Topic> result = cmd.Query <QR_Topic>(filter, " SysNo DESC");

            return(result);
        }
Esempio n. 15
0
        private void InitializeModel()
        {
            this.Title       = string.Empty;
            this.Deadline    = DateTime.Now;
            this.CreatedDate = DateTime.Now;
            Qty = 1;

            if (Finishing == null || MaterialMaster == null || Material == null)
            {
                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                Finishing      = db.Query <KeyValueOption>("GetFinishing");
                Size           = db.Query <KeyValueOption>("GetSize");
                MaterialMaster = db.Query <MaterialType>("GetMaterial");
                Material       = MaterialMaster.GroupBy(x => x.Id).Select(d => d.First()).ToList();
                db.Close();
            }
            else
            {
                SelectedFinishing = null;
                SelectedQuality   = null;
                SelectedMaterial  = null;
            }
        }
Esempio n. 16
0
        public async void ShowLogin()
        {
            LoginDialogData x = await this.ShowLoginAsync("Login", "Enter your credentials", new LoginDialogSettings
            {
                ColorScheme           = MetroDialogColorScheme.Accented,
                EnablePasswordPreview = true,
                PasswordWatermark     = "password",
                UsernameWatermark     = "user name",
                InitialPassword       = "",
                InitialUsername       = "",
                DefaultButtonFocus    = MessageDialogResult.Affirmative,
                AnimateShow           = true
            });

            if ((x == null))
            {
                ShowLogin();
            }
            else
            {
                IDbManager       dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand     db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                List <UserModel> result    = db.Query <UserModel>("GetUser", new { Username = x.Username, Password = x.Password });
                if (result.Any())
                {
                    //string[] accessLevel;
                    switch (result[0].Type)
                    {
                    case 100:
                        ObjectPool.Instance.Register <MasterCollaborator>().ImplementedBy(new MasterCollaborator());

                        break;

                    case 900:
                        ObjectPool.Instance.Register <MasterCollaborator>().ImplementedBy(new MasterCollaborator());
                        ObjectPool.Instance.Register <DashboardCollaborator>().ImplementedBy(new DashboardCollaborator());
                        break;
                    }
                    //AuthorizationProvider.Initialize<DefaultAuthorizationProvider>(accessLevel);
                    db.Close();
                }
                else
                {
                    db.Close();
                    ShowLogin();
                }
            }
        }
        public BaseDashboardViewSource()
        {
            this.Year = DateTime.Now.Year;
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

            Years = db.Query <int>("GetDistinctYear");
            db.Close();

            months = new List <int>();
            for (int i = 1; i <= 12; i++)
            {
                months.Add(i);
            }
            Month = DateTime.Now.Month;
        }
Esempio n. 18
0
        /// <summary>
        /// 分页查询RMAMaster信息
        /// </summary>
        public static QueryResult <QR_RMAMaster> QueryRMAMasterList(QF_RMAMaster filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryRMAMasterList");

            //DataCommand cmd = new DataCommand("QueryRMAMasterList");

            cmd.QuerySetCondition("SOSysNo", ConditionOperation.Equal, DbType.Int32, filter.SOSysNo);
            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);


            QueryResult <QR_RMAMaster> result = cmd.Query <QR_RMAMaster>(filter, " SysNo DESC");

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// 分页查询ShippingAddress信息
        /// </summary>
        public QueryResult <QR_ShippingAddress> QueryShippingAddressList(QF_ShippingAddress filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryShippingAddressList");

            //DataCommand cmd = new DataCommand("QueryShippingAddressList");

            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);

            cmd.QuerySetCondition("IsDefault", ConditionOperation.Equal, DbType.Int32, filter.IsDefault);


            QueryResult <QR_ShippingAddress> result = cmd.Query <QR_ShippingAddress>(filter, " SysNo DESC");

            return(result);
        }
Esempio n. 20
0
        public override void Load()
        {
            IDbManager              dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand            db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List <InvoiceDataValue> result    = db.Query <InvoiceDataValue>("GetDashboardInvoiceMonth", new { Year = this.Year });

            Total = 0;
            Order = 0;
            MutableObservableCollection <SeriesData <InvoiceDataValue> > model = new MutableObservableCollection <SeriesData <InvoiceDataValue> >();
            InvoiceDataValue item;

            for (int i = 1; i <= 12; i++)
            {
                item = result.Where(x => x.Name == i.ToString()).SingleOrDefault();
                model.Add(new SeriesData <InvoiceDataValue>()
                {
                    SeriesDisplayName = DateTimeFormatInfo.CurrentInfo.GetMonthName(i)
                });

                if (item != null)
                {
                    model[i - 1].Items.Add(new InvoiceDataValue()
                    {
                        Name   = DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
                        Number = item.Number
                    });

                    Total           += item.Number;
                    Order           += item.Order;
                    OrderInstallment = item.OrderInstallment;
                    TotalInstallment = item.TotalInstallment;
                }
                else
                {
                    model[i - 1].Items.Add(new InvoiceDataValue()
                    {
                        Name   = DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
                        Number = 0
                    });
                }
            }
            this.Source = model;
            db.Close();
        }
        public void StartSyncronizing()
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);

            List <Contact> newContact;

            {
                newContact = db.Query <Contact>("GetContactAll");
                // save current view source
                DbContactMaster = newContact;
                // refresh all view source when search text box is empty
                if (string.IsNullOrEmpty(searchText))
                {
                    Source = newContact;
                }
            }
            db.Close();
        }
Esempio n. 22
0
        //[TestMethod]
        public void TestMethod1()
        {
            IFileLoader loader    = new FileSqlLoader("file-sql-loader", AppDomain.CurrentDomain.BaseDirectory + @"\App_Code\SqlFiles");
            IDbManager  dbManager = new Common.Database.Petapoco.PetapocoDbManager(null, null);

            //// initialize sql loader and connection descriptor
            dbManager.AddSqlLoader(loader);

            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = @"DATA SOURCE=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = tcp)(HOST = batuampar.idbpn.chevronCommon.net)(PORT = 1521)))(CONNECT_DATA =(SID = ih10bpnd))); USER ID=MIMSWH; PASSWORD=mimswh4devel#2012;",
                IsDefault        = true,
                ProviderName     = "System.Data.OracleClient",
                Name             = "MIMSWH"
            });

            IDataCommand  db     = dbManager.GetDatabase("MIMSWH");
            List <object> result = db.Query <object>("SELECT * FROM tddistrict", null);
        }
Esempio n. 23
0
        private void CheckRemainingStock()
        {
            if (selectedMaterial == null || selectedQuality == null)
            {
                return;
            }

            IDbManager              dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand            db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List <TransactionStock> stocks    = db.Query <TransactionStock>("GetRemainingStockInHand", new { MaterialId = selectedMaterial.Id, QualityId = selectedQuality.Id });

            if (stocks.Any())
            {
                RemainingStock = stocks[0].Qty;
            }
            else
            {
                RemainingStock = 0;
            }
            db.Close();
        }
Esempio n. 24
0
 private async Task OnRefresh()
 {
     await Task.Run(() =>
     {
         // Initialize master
         IsBusy                     = true;
         IsEnabled                  = false;
         IDbManager dbManager       = ObjectPool.Instance.Resolve <IDbManager>();
         IDataCommand db            = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
         List <QualityType> quality = db.Query <QualityType>("GetQuality");
         ObjectPool.Instance.Register <List <QualityType> >().ImplementedBy(quality);
         db.Close();
         if (selectedRange == null)
         {
             selectedRange = Range[1];
         }
         Pull();
         IsBusy    = false;
         IsEnabled = true;
     });
 }
Esempio n. 25
0
        public QueryResult <SOMaster> QueryOrderList(QF_SO filter)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("QueryOrderList");

            //DataCommand cmd = new DataCommand("QueryOrderList");
            cmd.QuerySetCondition("CustomerSysNo", ConditionOperation.Equal, DbType.Int32, filter.CustomerSysNo);
            if (filter.SOStatus.HasValue && filter.SOStatus.Value == 101)
            {
                cmd.QuerySetCondition("and  exists(select 1  from    [ECCenter].[dbo].SOItem  as si with (nolock) left join [ECCenter].[dbo].[ProductComment] as pc with (nolock) on si.ProductSysNo=pc.ProductSysNo and si.SOSysNo=pc.SOSysNo where si.SOSysNo=[ECCenter].[dbo].[SOMaster].SysNo and pc.SysNo is null  )");
                cmd.QuerySetCondition("SOStatus", ConditionOperation.Equal, DbType.Int32, 100);
                cmd.QuerySetCondition("and DATEDIFF(M, SODATE ,GETDATE())<=1");
            }
            else
            {
                cmd.QuerySetCondition("SOStatus", ConditionOperation.Equal, DbType.Int32, filter.SOStatus);
            }
            QueryResult <SOMaster> result = cmd.Query <SOMaster>(filter, " SODate DESC");

            return(result);
        }
Esempio n. 26
0
        public List <PacketEventArgs> ToList()
        {
            List <WorkItem> queryResult;

            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);

            queryResult = db.Query <WorkItem>("GetAllQueueWorkItem", null);
            db.Close();

            List <PacketEventArgs> result = new List <PacketEventArgs>();

            if (queryResult.Count > 0)
            {
                foreach (WorkItem workItem in queryResult)
                {
                    result.Add(new PacketEventArgs(null, ASCIIEncoding.ASCII.GetBytes(queryResult[0].Command), null));
                }
            }

            return(result);
        }
Esempio n. 27
0
        public override void Load()
        {
            IDbManager       dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand     db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List <DataValue> result    = db.Query <DataValue>("GetDashboardTopConsumer", new { Year = this.Year });

            MutableObservableCollection <SeriesData <DataValue> > model = new MutableObservableCollection <SeriesData <DataValue> >();

            for (int i = 0; i < result.Count; i++)
            {
                model.Add(new SeriesData <DataValue>()
                {
                    SeriesDisplayName = result[i].Name
                });

                model[i].Items.Add(new DataValue()
                {
                    Name   = result[i].Name,
                    Number = result[i].Number
                });
            }
            this.Source = model;
            db.Close();
        }
Esempio n. 28
0
        public void Pull()
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            int          mstrType  = -1;

            if (masterTypeSync == MasterType.All)
            {
                mstrType = 100;
            }

            if (mstrType == 100 || masterTypeSync == MasterType.Finishing)
            {
                Finishing.Source = db.Query <KeyValueOption>("GetFinishing").Convert <KeyValueOption>();
            }

            if (mstrType == 100 || masterTypeSync == MasterType.Material)
            {
                Material.Source = db.Query <MaterialType>("GetMaterial").Convert <MaterialType>();
            }

            if (mstrType == 100 || masterTypeSync == MasterType.Quality)
            {
                Quality.Source = db.Query <KeyValueOption>("GetQuality").Convert <KeyValueOption>();
            }

            if (mstrType == 100 || masterTypeSync == MasterType.Size)
            {
                Size.Source = db.Query <KeyValueOption>("GetSize").Convert <KeyValueOption>();
            }

            if (mstrType == 100 || masterTypeSync == MasterType.Supplier)
            {
                Supplier.Source = db.Query <Supplier>("GetSupplier").Convert <Supplier>();
            }

            if (mstrType == 100 || masterTypeSync == MasterType.Stock)
            {
                Stock.Source = db.Query <TransactionStock>("GetSummary").Convert <TransactionStock>();
            }

            db.Close();
        }
Esempio n. 29
0
 private void GetDetails(MutableObservableCollection<CreateOrderModel> source, IDataCommand db)
 {
     List<CreateOrderDetailModel> details;
     foreach (CreateOrderModel order in source.ToList())
     {
         order.NewOrder = false;
         details = db.Query<CreateOrderDetailModel>("GetOrderDetail", new { OrderId = order.PoNumber });
         if (details.Any())
         {
             order.Details.Source = details.Convert<CreateOrderDetailModel>();
             foreach (CreateOrderDetailModel detail in order.Details.Source.ToList())
             {
                 detail.Finishing = db.Query<KeyValueOption>("GetFinishing");
                 detail.Size = db.Query<KeyValueOption>("GetSize");
                 detail.Quality = ObjectPool.Instance.Resolve<List<QualityType>>();
                 detail.MaterialMaster = db.Query<MaterialType>("GetMaterial");
                 detail.Material = detail.MaterialMaster.GroupBy(x => x.Id).Select(d => d.First()).ToList(); 
             }
         }
     }  
 }
Esempio n. 30
0
        private async Task OnSave(object obj)
        {
            if (obj != null)
            {
                CreateOrderModel model = (CreateOrderModel)obj;
                if (string.IsNullOrEmpty(model.CustomerName))
                {
                    return;
                }

                await Task.Run(() =>
                {
                    IsBusy    = true;
                    IsEnabled = false;

                    IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                    IDataCommand db      = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

                    Dictionary <string, string> scripts = new Dictionary <string, string>();

                    List <int> result = db.Query <int>("CheckExistsOrder", new
                    {
                        OrderId = model.PoNumber
                    });

                    if (result.Any())
                    {
                        scripts.Add("Order", "UpdateOrder");
                        scripts.Add("OrderDetail", "UpdateOrderDetail");
                    }
                    else
                    {
                        scripts.Add("Order", "CreateOrder");
                        scripts.Add("OrderDetail", "CreateOrderDetail");
                    }

                    IDbTransaction transaction = ((BaseDbCommand)db).BeginTransaction();
                    try
                    {
                        db.Execute(scripts["Order"], new
                        {
                            OrderId       = model.PoNumber,
                            CustomerName  = model.CustomerName,
                            CustomerPhone = model.CustomerPhone,
                            Status        = "I",
                            Total         = model.TotalPayment,
                            Installment   = model.Installment,
                            Remaining     = model.Remaining,
                            Disc          = model.discount
                        });

                        CreateOrderDetailModel detail;
                        for (int i = 0; i < model.Details.Source.Count; i++)
                        {
                            detail = model.Details.Source[i];

                            result = db.Query <int>("CheckExistsOrderDetail", new
                            {
                                OrderId = model.poNumber,
                                SeqNbr  = detail.SeqNbr
                            });

                            if (!result.Any())
                            {
                                scripts["OrderDetail"] = "CreateOrderDetail";
                            }

                            db.Execute(scripts["OrderDetail"], new
                            {
                                OrderId        = model.PoNumber,
                                SeqNbr         = i + 1,
                                MaterialTypeId = detail.MaterialId,
                                QualityId      = detail.QualityId,
                                FinishingId    = detail.FinishingId,
                                Title          = detail.Title,
                                Width          = detail.Width,
                                Height         = detail.Height,
                                Qty            = detail.Qty,
                                Filename       = detail.Filename,
                                Image          = detail.Stream,
                                Queue          = 0,
                                Deadline       = detail.Deadline,
                                Description    = detail.Description,
                                Total          = detail.Price
                            });
                        }
                        transaction.Commit();
                    }
                    catch (Exception x)
                    {
                        transaction.Rollback();
                    }

                    db.Close();

                    IsBusy    = false;
                    IsEnabled = true;

                    OnItemCreated();
                });
            }
        }
Esempio n. 31
0
        public PacketEventArgs Get()
        {
            lock (syncLock)
            {
                List <DailyTrigger>   daily   = new List <DailyTrigger>();
                List <WeeklyTrigger>  weekly  = new List <WeeklyTrigger>();
                List <MonthlyTrigger> monthly = new List <MonthlyTrigger>();

                PacketEventArgs result = null;
                bool            valid  = false;

                List <QueueWorkItem> workItem;
                ApplicationSettings  configuration = (ApplicationSettings)ObjectPool.Instance.Resolve <IConfiguration>();

                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);
                try
                {
                    try
                    {
                        workItem = db.Query <QueueWorkItem>("GetQueueWorkItem", null);
                        if (!workItem.Any())
                        {
                            return(null);
                        }

                        foreach (QueueWorkItem item in workItem.ToList())
                        {
                            daily   = null;
                            weekly  = null;
                            monthly = null;
                            if (workItem.Count > 0)
                            {
                                if (!item.Enabled)
                                {
                                    return(null);
                                }

                                result = new PacketEventArgs(null, null, ASCIIEncoding.ASCII);
                                DateTime currentTime = DateTime.Now;
                                if (item.Status == "R")
                                {
                                    string triggerPrefix = string.Empty;
                                    if (!string.IsNullOrEmpty(item.ScheduleID))
                                    {
                                        triggerPrefix = item.ScheduleID.Substring(0, 1);
                                    }

                                    switch (triggerPrefix)
                                    {
                                    case "O":
                                        if (item.Created <= currentTime)
                                        {
                                            valid = true;
                                        }
                                        break;

                                    case "D":
                                        daily = db.Query <GSMServer.Worker.Model.DailyTrigger>("GetDailyTriggerByID", new { ID = item.ScheduleID });
                                        if (daily.Any())
                                        {
                                            if (item.NextExecuted.Ticks > 0 &&
                                                item.NextExecuted <= currentTime &&
                                                item.LastExecuted < currentTime)
                                            {
                                                valid = true;
                                            }
                                            else if (item.Created.Ticks > 0)
                                            {
                                                if (item.Created <= currentTime)
                                                {
                                                    valid = true;
                                                }
                                            }
                                        }
                                        break;

                                    case "W":
                                        weekly = db.Query <GSMServer.Worker.Model.WeeklyTrigger>("GetWeeklyTriggerByID", new { ID = item.ScheduleID });
                                        if (weekly.Any())
                                        {
                                            DayOfWeek    day        = currentTime.DayOfWeek;
                                            Type         weeklyType = weekly[0].GetType();
                                            PropertyInfo prop       = weeklyType.GetProperty(day.ToString());
                                            int          valueOfDay;
                                            if (prop != null)
                                            {
                                                valueOfDay = (int)prop.GetValue(weekly[0], null);
                                                if (valueOfDay == 1 && (item.NextExecuted <= currentTime || item.NextExecuted.Ticks == 0))
                                                {
                                                    valid = true;
                                                }
                                            }
                                        }
                                        break;

                                    case "M":
                                        monthly = db.Query <GSMServer.Worker.Model.MonthlyTrigger>("GetMonthlyTriggerByID", new { ID = item.ScheduleID });
                                        if (monthly.Any())
                                        {
                                            string[] days = monthly[0].Days.Split(',');
                                            foreach (string day in days)
                                            {
                                                if (Convert.ToInt32(day) == currentTime.Day && (item.NextExecuted <= currentTime || item.LastExecuted.Ticks == 0))
                                                {
                                                    valid = true;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                                else if (item.Status == "D")
                                {
                                    db.Execute("DeleteQueueWorkItem", new { SeqNbr = item.SeqNbr });
                                }
                                else if (item.Status == "E")
                                {
                                    if (item.NextExecuted < currentTime &&
                                        (item.LastExecuted.Day < currentTime.Day &&
                                         item.LastExecuted.Month <= currentTime.Month &&
                                         item.LastExecuted.Year <= currentTime.Year))
                                    {
                                        db.Execute("UpdateQueueLastExecuted", new
                                        {
                                            Status = "R",
                                            SeqNbr = item.SeqNbr
                                        });
                                    }
                                }

                                if (valid)
                                {
                                    GSMServerModel.QueueWorkItem resultQueue = CopyTo <QueueWorkItem, GSMServerModel.QueueWorkItem>(item);
                                    if (daily != null || weekly != null || monthly != null)
                                    {
                                        if (daily != null)
                                        {
                                            if (daily.Any())
                                            {
                                                resultQueue.Schedule = CopyTo <DailyTrigger, GSMServerModel.DailyTrigger>(daily[0]);
                                            }
                                        }
                                        else if (weekly != null)
                                        {
                                            if (weekly.Any())
                                            {
                                                resultQueue.Schedule = CopyTo <WeeklyTrigger, GSMServerModel.WeeklyTrigger>(weekly[0]);
                                            }
                                        }
                                        else if (monthly != null)
                                        {
                                            if (monthly.Any())
                                            {
                                                resultQueue.Schedule = CopyTo <MonthlyTrigger, GSMServerModel.MonthlyTrigger>(monthly[0]);
                                            }
                                        }
                                    }
                                    result.Data = ConvertToByte(resultQueue);
                                    break;
                                }
                            }
                        }
                    }
                    finally
                    {
                        db.Close();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                return(result.Data == null ? null : result);
            }
        }