Esempio n. 1
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();
                }
            }
        }
Esempio n. 2
0
        public override void OnEdit(object arg)
        {
            if (arg != null)
            {
                Supplier model = (Supplier)arg;

                IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();
                if (dialog.ShowDialog <Views.Dialogs.Supplier>(model).Value == true)
                {
                    IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                    IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

                    try
                    {
                        db.Execute("UpdateSupplier", new
                        {
                            SupplierId = model.Id,
                            Name       = model.Name,
                            Address    = model.Address,
                            Telp       = model.Telp,
                            Active     = model.Active
                        });
                    }
                    catch { }

                    db.Close();
                    OnSourceChanged(this);
                }
            }
        }
Esempio n. 3
0
        public override void OnDelete(object arg)
        {
            WarningModel message = new WarningModel()
            {
                Message = "Are you sure want to delete data?"
            };

            IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();
            bool?          result = dialog.ShowDialog <YesNo>(message);

            if (result.HasValue && result.Value)
            {
                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                foreach (Supplier item in Source)
                {
                    if (item.IsSelected)
                    {
                        try
                        {
                            db.Execute("DeleteSupplier", new
                            {
                                SupplierId = item.Id
                            });
                        }
                        catch { }
                    }
                }
                db.Close();
                CheckedHeader = false;
                OnSourceChanged(this);
            }
        }
Esempio n. 4
0
 public void OnDataReceived(string data)
 {
     try
     {
         if (data != "[]")
         {
             if (data.StartsWith("[") && data.EndsWith("]") && data.Contains("SMSReadResult"))
             {
                 ConfigurationSettings configuration     = ObjectPool.Instance.Resolve <ConfigurationSettings>();
                 List <BaseResult <SMSReadResult> > list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <BaseResult <SMSReadResult> > >(data);
                 IDbManager   dbManager = ObjectPool.Instance.Resolve <PetapocoDbManager>();
                 IDataCommand db        = dbManager.GetDatabase("SMSGW");
                 foreach (BaseResult <SMSReadResult> read in list)
                 {
                     db.Execute("Obstruction", null);
                 }
                 db.Close();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 5
0
        public void Write(object value)
        {
            if (value == null)
            {
                return;
            }

            System.Reflection.PropertyInfo pi = value.GetType().GetProperty("ID");

            if (pi != null)
            {
                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);

                string propValue = (string)pi.GetValue(value, null);
                if (!string.IsNullOrEmpty(propValue))
                {
                    StringBuilder responseJson = new StringBuilder(Newtonsoft.Json.JsonConvert.SerializeObject(value,
                                                                                                               Newtonsoft.Json.Formatting.None,
                                                                                                               new Newtonsoft.Json.JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                    }));

                    db.Execute("InsertResultWorkItem", new
                    {
                        SeqNbr   = propValue,
                        Response = responseJson.ToString()
                    });
                    db.Close();
                }
            }
        }
Esempio n. 6
0
        public override void OnDelete(object arg)
        {
            if (arg != null)
            {
                TransactionStock model = (TransactionStock)arg;

                IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();
                if (dialog.ShowDialog <Koala.Views.Dialogs.Stock>(model).Value == true)
                {
                    IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                    IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                    UserModel    user      = ObjectPool.Instance.Resolve <UserModel>();

                    try
                    {
                        db.Execute("DeleteStock", new
                        {
                            MaterialId = model.MaterialId,
                            QualityId  = model.QualityId,
                            SupplierId = model.SupplierId,
                            Qty        = model.Qty,
                            CreatedBy  = user.Username
                        });
                    }
                    catch { }

                    db.Close();
                    OnSourceChanged(this);
                }
            }
        }
Esempio n. 7
0
        private void OnDeleteDetail(dynamic obj)
        {
            System.Collections.IList items = (System.Collections.IList)obj;
            var collection = items.Cast <CreateOrderDetailModel>();

            if (!NewOrder)
            {
                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                foreach (CreateOrderDetailModel item in collection.ToList())
                {
                    db.Execute("DeleteOrderDetail", new
                    {
                        OrderId = item.OrderId,
                        SeqNbr  = item.SeqNbr
                    });
                }
                db.Close();
            }

            foreach (CreateOrderDetailModel item in collection.ToList())
            {
                if (item.IsSelected)
                {
                    Details.Source.Remove(item);
                }
            }
            CalculatingTotalPayment();
            CalculatingTotalPaymentByDiscount();
            Details.CheckedHeader = false;
        }
Esempio n. 8
0
        private void MarkReadUnread(int read)
        {
            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;

                foreach (Inbox message in SelectableRow.ToList())
                {
                    message.IsRead = read;
                    db.Execute("UpdateMessageRead", new
                    {
                        IsRead = read,
                        SeqNbr = message.SeqNbr
                    });
                    message.IsSelected = false;
                    if (read == (int)MessageRead.Read)
                    {
                        Unread -= 1;
                    }
                }

                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
Esempio n. 9
0
        public override void OnDelete(object obj)
        {
            WarningModel message = new WarningModel()
            {
                Message = "Are you sure want to delete data?"
            };

            IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();
            bool?          result = dialog.ShowDialog <YesNo>(message);

            if (result.HasValue && result.Value)
            {
                IDbManager        dbManager         = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand      db                = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                OrderCollaborator orderCollaborator = ObjectPool.Instance.Resolve <OrderCollaborator>();
                foreach (CreateOrderModel order in Source.ToList())
                {
                    if (order.IsSelected)
                    {
                        db.Execute("DeletePrintOrder", new
                        {
                            OrderId = order.PoNumber,
                            Status  = "F"
                        });
                        orderCollaborator.PaymentOrder.source.Remove(order);
                    }
                }
                db.Close();
                base.OnDelete(obj);
            }
        }
        public override void OnCreate()
        {
            KeyValueOption model = new KeyValueOption();

            model.Id = GenerateId(3, "SE");
            IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();

            if (dialog.ShowDialog <Size>(model).Value == true)
            {
                if (model.Description == null)
                {
                    return;
                }


                this.Source.Add(model);

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

                try
                {
                    db.Execute("InsertSize", new
                    {
                        Id          = model.Id,
                        Description = model.Description
                    });
                }
                catch { }

                db.Close();
                OnSourceChanged(this);
            }
        }
Esempio n. 11
0
        public override void OnCreate()
        {
            TransactionStock model = new TransactionStock();

            IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();

            if (dialog.ShowDialog <Koala.Views.Dialogs.Stock>(model).Value == true)
            {
                if (model.MaterialId == null || model.QualityId == null || model.SupplierId == null || model.Qty == 0)
                {
                    return;
                }

                this.Source.Add(model);

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

                try
                {
                    db.Execute("InsertStock", new
                    {
                    });
                }
                catch { }

                db.Close();
                OnSourceChanged(this);
            }
        }
Esempio n. 12
0
        private void OnUpdateDetail(object arg)
        {
            if (UpdatingOrderDetail != null)
            {
                UpdatingOrderDetail(this, this);
            }

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

                CreateOrderDetailModel detail = (CreateOrderDetailModel)arg;
                db.Execute("UpdateOrderDetail", new
                {
                    MaterialTypeId = detail.SelectedMaterial.Id,
                    QualityId      = detail.SelectedQuality.Id,
                    FinishingId    = detail.SelectedFinishing.Id,
                    Title          = detail.title,
                    Width          = detail.width,
                    Height         = detail.height,
                    Qty            = detail.qty,
                    Queue          = detail.Queue,
                    Deadline       = detail.deadline,
                    Description    = detail.description,
                    Total          = detail.Price,
                    OrderId        = detail.orderId,
                    SeqNbr         = detail.SeqNbr
                });

                db.Close();
            });
        }
Esempio n. 13
0
        private void OnDelete(string source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("Source");
            }

            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;
                string number;
                foreach (BaseDataRow message in SelectableRow.ToList())
                {
                    BaseMessageModel model;
                    if (source == "O") // source from Outbox
                    {
                        model  = (BaseMessageModel)message;
                        number = ((Outbox)message).Receiver;
                        db.Execute("UpdateMessageStatus", new
                        {
                            Status = "D",
                            SeqNbr = model.SeqNbr,
                            Sender = number,
                            Source = source.ToUpper()
                        });
                    }
                    else if (source == "I") // source from Inbox
                    {
                        model  = (BaseMessageModel)message;
                        number = model.Sender;
                        db.Execute("UpdateMessageStatus", new
                        {
                            Status = "D",
                            SeqNbr = model.SeqNbr,
                            Sender = number,
                            Source = source.ToUpper()
                        });
                    }
                    else if (source == "D") // source from Draft
                    {
                        ComposeMessageModel compose = (ComposeMessageModel)message;

                        db.Execute("DeleteQueue", new
                        {
                            SeqNbr = compose.SeqNbr
                        });
                    }
                    message.IsSelected = false;
                }
                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
Esempio n. 14
0
        private void OnDelete(object args)
        {
            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;

                foreach (BaseContactModel item in SelectableRow)
                {
                    db.Execute("DeleteContact", new
                    {
                        ID = item.ID
                    });
                }

                IDataSyncronize data = ObjectPool.Instance.Resolve <DatabaseCollectionViewSource>();
                data.StartSyncronizing();

                SelectableRow.Clear();

                db.Close();
                IsBusy = false;
            });
        }
Esempio n. 15
0
        private void OnMarkAsSpam(string source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("Source");
            }

            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;

                foreach (BaseMessageModel message in SelectableRow.ToList())
                {
                    db.Execute("UpdateMessageStatus", new
                    {
                        Status = "S",
                        SeqNbr = message.SeqNbr,
                        Sender = message.Sender,
                        Source = source.ToUpper()
                    });
                    message.IsSelected = false;
                }

                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
Esempio n. 16
0
        private void OnUpdateDetailStatus(object status)
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

            foreach (CreateOrderDetailModel detail in this.details.Source)
            {
                if (detail.IsSelected)
                {
                    db.Execute("UpdateOrderDetailStatus", new
                    {
                        Queue   = status,
                        OrderId = this.poNumber,
                        SeqNbr  = detail.SeqNbr
                    });

                    detail.Queue       = Convert.ToInt32(status);
                    detail.QueueStatus = "Just Trigger";
                    detail.IsSelected  = false;
                }
            }
            db.Close();

            bool completed = this.details.Source.Where(x => x.Queue == 2).Count() == this.details.Source.Count;

            if (completed)
            {
                OnStatusCompleted();
            }

            this.Details.CheckedHeader = false;
        }
        public override void OnEdit(object arg)
        {
            if (arg != null)
            {
                KeyValueOption model = (KeyValueOption)arg;
                model.IsReadOnly = true;

                IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>();
                if (dialog.ShowDialog <Size>(model).Value == true)
                {
                    IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                    IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

                    try
                    {
                        db.Execute("UpdateSize", new
                        {
                            Id          = model.Id,
                            Description = model.Description
                        });
                    }
                    catch { }

                    db.Close();
                    OnSourceChanged(this);
                }
            }
        }
Esempio n. 18
0
        private void OnSave(ComposeNewContactModel args)
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);

            if (args.ID == null)
            {
                string id = GenerateID();
                db.Execute("InsertContact", new
                {
                    ID          = id,
                    Name        = args.Name,
                    PhoneNumber = args.PhoneNumber
                });
            }
            else
            {
                db.Execute("UpdateContact", new
                {
                    ID          = args.ID,
                    Name        = args.Name,
                    PhoneNumber = args.PhoneNumber
                });
            }
            db.Close();
        }
Esempio n. 19
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. 20
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. 21
0
        private void OnMessageOpen(object args)
        {
            ComposeMessageModel forward = new ComposeMessageModel();

            if (args == null)
            {
                return;
            }
            else if (args.GetType() == typeof(ComposeMessageModel))
            {
                DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(args);
                return;
            }
            Type typeArgs = args.GetType();

            if (typeArgs == typeof(Inbox) || typeArgs == typeof(Spam) || typeArgs == typeof(Trash))
            {
                BaseMessageModel inbox = (BaseMessageModel)args;
                if (typeArgs == typeof(Inbox))
                {
                    ((Inbox)inbox).IsRead = (int)MessageRead.Read;
                }
                else if (typeArgs == typeof(Trash))
                {
                    ((Trash)inbox).IsRead = (int)MessageRead.Read;
                }

                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);
                db.Execute("UpdateMessageRead", new
                {
                    IsRead = (int)MessageRead.Read,
                    SeqNbr = inbox.SeqNbr
                });
                db.Close();

                forward.Message     = inbox.Message;
                forward.Phonenumber = inbox.Sender;
            }

            Outbox outbox = new Outbox();

            if (typeArgs == typeof(Outbox))
            {
                outbox          = (Outbox)args;
                forward.Message = outbox.Message;
            }
            else if (typeArgs.Name == "SelectedItemCollection")
            {
                outbox          = (Outbox)((System.Collections.IList)args)[0];
                forward.Message = outbox.Message;
            }
            DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(forward);
        }
Esempio n. 22
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. 23
0
        private void OnUpdate(MaterialType model)
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);

            db.Execute("UpdateMaterial", new
            {
                Id          = model.Id,
                Description = model.Description,
                QualityId   = model.SelectedQuality.Id,
                Price       = model.Price
            });
            db.Close();
            OnItemChanged();
        }
        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. 25
0
        private void OnRestore()
        {
            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;
                string number;
                Type messageType;

                foreach (BaseMessageModel message in SelectableRow.ToList())
                {
                    messageType = message.GetType();
                    if (messageType == typeof(Trash))
                    {
                        if (((Trash)message).Source.ToLower() == "inbox")
                        {
                            number = ((Trash)message).Sender;
                        }
                        else
                        {
                            number = ((Trash)message).Receiver;
                        }
                    }
                    else
                    {
                        number = message.Sender;
                    }

                    db.Execute("UpdateMessageStatus", new
                    {
                        Status = "R",
                        SeqNbr = message.SeqNbr,
                        Sender = number,
                        Source = ""
                    });
                    message.IsSelected = false;
                }
                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
Esempio n. 26
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();
        }
Esempio n. 27
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();
        }
        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. 29
0
        private void OnUpdateQueueOrder(string status)
        {
            IDbManager        dbManager         = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand      db                = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            OrderCollaborator orderCollaborator = ObjectPool.Instance.Resolve <OrderCollaborator>();
            UserModel         user              = ObjectPool.Instance.Resolve <UserModel>();

            foreach (CreateOrderModel order in Source.ToList())
            {
                if (order.IsSelected)
                {
                    db.Execute("UpdatePrintOrder", new
                    {
                        OrderId = order.PoNumber,
                        Status  = status,
                        Queue   = 1
                    });
                    order.IsSelected = false;

                    /// update list
                    order.Status = "Q";

                    foreach (CreateOrderDetailModel detail in order.Details.Source)
                    {
                        db.Execute("InsertTransactionStock", new
                        {
                            MaterialId = detail.MaterialId,
                            QualityId  = detail.QualityId,
                            Qty        = detail.Qty,
                            CreatedBy  = user.Username,
                        });
                    }

                    orderCollaborator.PrintOrder.source.Remove(order);
                    orderCollaborator.Queue.Source.Add(order);
                }
            }
            db.Close();
            orderCollaborator.Queue.Source = orderCollaborator.Queue.Source.OrderBy(x => x.UpdateDate).Convert();
            CheckedHeader = false;
        }
Esempio n. 30
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();
        }