Exemplo n.º 1
0
        public static void addMessageToPoisonQueue(Exception error, Notification.Domain.dtoModuleNotificationMessage message, String poisonQueue = "")
        {
            if (String.IsNullOrEmpty(poisonQueue))
            {
                poisonQueue = System.Configuration.ConfigurationManager.AppSettings["PoisonErrorsQueueName"];
            }
            if (null != error && !String.IsNullOrEmpty(poisonQueue))
            {
                MessageQueue poisonMessageQueue = new MessageQueue(poisonQueue);
                if (poisonMessageQueue != null)
                {
                    using (TransactionScope txScope = new TransactionScope(TransactionScopeOption.RequiresNew))
                    {
                        ErrorNotificationMessage obj = new ErrorNotificationMessage()
                        {
                            Message = message
                        };
                        obj.Error.HelpLink       = error.HelpLink;
                        obj.Error.StackTrace     = error.StackTrace;
                        obj.Error.Source         = error.Source;
                        obj.Error.Message        = error.Message;
                        obj.Error.InnerException = (error.InnerException == null) ? "" : error.InnerException.Message;

                        poisonMessageQueue.Send(obj, MessageQueueTransactionType.Single);
                        txScope.Complete();
                    }
                }
            }
        }
        private void LoadDialogErrorNotPermission()
        {
            ErrorNotificationMessage msg = new ErrorNotificationMessage();

            msg.Message = "Bạn Không Có Quyền Truy Cập! Vui Lòng Liên Hệ Quản Trị Viên!";

            DialogHost.Show(msg, "RootDialog");
        }
Exemplo n.º 3
0
        private void LoadDialogError(string Message)
        {
            ErrorNotificationMessage msg = new ErrorNotificationMessage();

            msg.Title   = "Lỗi";
            msg.Message = Message;

            DialogHost.Show(msg, "SellDialog");
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message">message </param>
        /// <param name="poisonQueue">queue name</param>
        public static void addMessageToPoisonQueue(Notification.Domain.dtoModuleNotificationMessage message, String poisonQueue = "")
        {
            if (String.IsNullOrEmpty(poisonQueue))
            {
                poisonQueue = System.Configuration.ConfigurationManager.AppSettings["PoisonErrorsQueueName"];
            }
            if (null != message && !String.IsNullOrEmpty(poisonQueue))
            {
                MessageQueue poisonMessageQueue = new MessageQueue(poisonQueue);
                if (poisonMessageQueue != null)
                {
                    using (TransactionScope txScope = new TransactionScope(TransactionScopeOption.RequiresNew))
                    {
                        ErrorNotificationMessage obj = new ErrorNotificationMessage()
                        {
                            Message = message
                        };

                        poisonMessageQueue.Send(obj, MessageQueueTransactionType.Single);
                        txScope.Complete();
                    }
                }
            }
        }
Exemplo n.º 5
0
        public ImportViewModel()
        {
            loadUserCurrentLogin();
            LoadImportData();

            ListProduct            = new List <ProductTable> (DataProvider.Ins.Entities.ProductTable);
            CreateNewImportCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                InputTable newInput = new InputTable();
                newInput.DateInput  = DateTime.Now;
                newInput.ID_User    = ID_CurrentUser;
                if (newInput == null)
                {
                    return;
                }

                DataProvider.Ins.Entities.InputTable.Add(newInput);
                DataProvider.Ins.Entities.SaveChanges();

                IsActiveSnackBar = true;
                Message          = "Thêm Mới Phiếu Nhập Thành Công!";

                LoadImportData();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 3000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            LoadEditCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadDialogAccountEdit(); });

            AddCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status))
                {
                    return(false);
                }


                var Product = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Product == SelectedProduct.ID && x.ID_Input == SelectedItemInput.input.ID);

                if (Product.Count() != 0 || Product == null)
                {
                    return(false);
                }

                return(true);
            },
                                                   (p) =>
            {
                InputDetailTable detailItem = new InputDetailTable();
                detailItem.ID_Input         = SelectedItemInput.input.ID;
                detailItem.ID_Product       = SelectedProduct.ID;
                detailItem.PriceInput       = InputPrice;
                detailItem.Status           = Status;
                detailItem.Amount           = Amount;
                detailItem.TotalPrice       = Amount * InputPrice;
                DataProvider.Ins.Entities.InputDetailTable.Add(detailItem);
                DataProvider.Ins.Entities.SaveChanges();

                ListInputDetail = new List <ImportDetailModel>();
                var List        = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    ListInputDetail.Add(detail);
                }

                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar          = true;
                Message                   = "Thêm Mới Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            EditCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status) || SelectedProduct == null)
                {
                    return(false);
                }

                var Product = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID != SelectedItemInputDetail.Product.ID && x.ID_Product == SelectedProduct.ID && x.ID_Input == SelectedItemInput.input.ID);

                if (Product.Count() != 0 || Product == null)
                {
                    return(false);
                }

                return(true);
            },
                                                    (p) =>
            {
                InputDetailTable detailItem = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID == SelectedItemInputDetail.InputDetail.ID).FirstOrDefault();
                detailItem.ID_Product       = SelectedProduct.ID;
                detailItem.PriceInput       = InputPrice;
                detailItem.Status           = Status;
                detailItem.Amount           = Amount;
                detailItem.TotalPrice       = Amount * InputPrice;
                DataProvider.Ins.Entities.SaveChanges();

                ListInputDetail = new List <ImportDetailModel>();
                var List        = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    ListInputDetail.Add(detail);
                }

                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar          = true;
                Message                   = "Sửa Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            DeleteCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status) || SelectedProduct == null)
                {
                    return(false);
                }

                return(true);
            }, (p) =>
            {
                DeleteNotificationMessage msg = new DeleteNotificationMessage();
                Message = "Xóa Thông Tin Có Thể Dẫn Đến Sai Lệch Dữ Liệu! Bạn Chắc Chắn Chứ?";
                DialogHost.Show(msg, "ImportDialog");
            });

            DeleteConfirmCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status) || SelectedProduct == null)
                {
                    return(false);
                }

                return(true);
            }, (p) =>
            {
                InputDetailTable detailItem = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID == SelectedItemInputDetail.InputDetail.ID).FirstOrDefault();
                DataProvider.Ins.Entities.InputDetailTable.Remove(detailItem);
                DataProvider.Ins.Entities.SaveChanges();

                ListInputDetail = new List <ImportDetailModel>();
                var List        = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    ListInputDetail.Add(detail);
                }
                DialogHost.CloseDialogCommand.Execute(null, null);

                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar          = true;
                Message                   = "Xóa Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            DeleteImportCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                var List = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                if (List.Count() != 0)
                {
                    ErrorNotificationMessage msg = new ErrorNotificationMessage();
                    Message = "Phiếu Nhập Này Đang Có Chi Tiết! Bạn Vui Lòng Xóa Bỏ Các Thông Tin Liên Quan!";
                    DialogHost.Show(msg, "ImportDialog");
                    return;
                }

                DataProvider.Ins.Entities.InputTable.Remove(SelectedItemInput.input);
                DataProvider.Ins.Entities.SaveChanges();

                SelectedItemInput       = null;
                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar = true;
                Message          = "Xóa Phiếu Nhập Thành Công!";

                LoadImportData();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            SearchCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            },
                                                      (p) =>
            {
                if (SearchTermInput == null)
                {
                    return;
                }


                var ListInput             = DataProvider.Ins.Entities.InputTable;
                List <ImportModel> Result = new List <ImportModel>();
                foreach (var item in ListInput)
                {
                    ImportModel import = new ImportModel();
                    import.input       = item;
                    import.User        = DataProvider.Ins.Entities.UserTable.Where(x => x.ID == item.ID_User).FirstOrDefault();
                    Result.Add(import);
                }

                ListImport = new List <ImportModel>(Result.Where(
                                                        x => x.input.DateInput.ToString().ToLower().Contains(SearchTermInput) ||
                                                        x.User.DisplayName.ToLower().Contains(SearchTermInput)
                                                        ));
            });

            SearchDetailCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            },
                                                            (p) =>
            {
                if (SearchTermInputDetail == null || SelectedItemInput == null)
                {
                    return;
                }
                List <ImportDetailModel> Result = new List <ImportDetailModel>();

                var List = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    Result.Add(detail);
                }
                ListInputDetail = new List <ImportDetailModel>(Result.Where(
                                                                   x => x.Product.DisplayName.ToLower().Contains(SearchTermInputDetail) ||
                                                                   x.InputDetail.Amount.ToString().ToLower().Contains(SearchTermInputDetail) || x.InputDetail.PriceInput.ToString().ToLower().Contains(SearchTermInputDetail) ||
                                                                   x.InputDetail.Status.Contains(SearchTermInputDetail)
                                                                   ));
            });
        }
Exemplo n.º 6
0
        public BillViewModel()
        {
            LoadOutputData();
            loadUserCurrentLogin();

            LoadEditCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadDialogAccountEdit(); });

            DeleteDetailCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedItemOutputDetail == null)
                {
                    return(false);
                }
                return(true);
            }, (p) =>
            {
                DeleteNotificationMessage msg = new DeleteNotificationMessage();
                Message = "Xóa Thông Tin Có Thể Dẫn Đến Sai Lệch Dữ Liệu! Bạn Chắc Chắn Chứ?";
                DialogHost.Show(msg, "BillDialog");
            });

            DeleteConfirmCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                OutPutDetailTable detailItem = DataProvider.Ins.Entities.OutPutDetailTable.Where(x => x.ID == SelectedItemOutputDetail.Output.ID).FirstOrDefault();
                DataProvider.Ins.Entities.OutPutDetailTable.Remove(detailItem);
                DataProvider.Ins.Entities.SaveChanges();

                ListOutputDetail = new List <OutputDetailModel>();
                var List         = DataProvider.Ins.Entities.OutPutDetailTable.Where(x => x.ID_Output == SelectedItemOutput.Output.ID);
                foreach (var item in List)
                {
                    OutputDetailModel detail = new OutputDetailModel();
                    ProductTable product     = new ProductTable();
                    product        = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.Output  = item;
                    detail.Product = product;
                    ListOutputDetail.Add(detail);
                }
                DialogHost.CloseDialogCommand.Execute(null, null);

                SelectedItemOutputDetail = null;

                IsActiveSnackBar          = true;
                Message                   = "Xóa Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            DeleteOutputCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                var List = DataProvider.Ins.Entities.OutPutDetailTable.Where(x => x.ID_Output == SelectedItemOutput.Output.ID);
                if (List.Count() != 0)
                {
                    ErrorNotificationMessage msg = new ErrorNotificationMessage();
                    Message = "Phiếu Nhập Này Đang Có Chi Tiết! Bạn Vui Lòng Xóa Bỏ Các Thông Tin Liên Quan!";
                    DialogHost.Show(msg, "BillDialog");
                    return;
                }

                DataProvider.Ins.Entities.OutputTable.Remove(SelectedItemOutput.Output);
                DataProvider.Ins.Entities.SaveChanges();

                LoadOutputData();
                DialogHost.CloseDialogCommand.Execute(null, null);

                SelectedItemOutput = null;

                IsActiveSnackBar          = true;
                Message                   = "Xóa Phiếu Nhập Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            SearchCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            },
                                                      (p) =>
            {
                if (SearchTermOutput == null)
                {
                    return;
                }


                var ListInput             = DataProvider.Ins.Entities.OutputTable;
                List <OutputModel> Result = new List <OutputModel>();
                foreach (var item in ListInput)
                {
                    OutputModel output = new OutputModel();
                    output.Output      = item;
                    output.User        = DataProvider.Ins.Entities.UserTable.Where(x => x.ID == item.ID_User).FirstOrDefault();
                    output.Customer    = DataProvider.Ins.Entities.CustomerTable.Where(x => x.ID == item.ID_Customer).FirstOrDefault();
                    Result.Add(output);
                }

                ListOutput = new List <OutputModel>(Result.Where(
                                                        x => x.Output.DateOutput.ToString().ToLower().Contains(SearchTermOutput) ||
                                                        x.User.DisplayName.ToLower().Contains(SearchTermOutput) || x.Customer.FullName.ToLower().Contains(SearchTermOutput)
                                                        ));
            });
        }