示例#1
0
        public SanitizingWindow(List <RuntimeData> dataContext, BillingDataDataContext db, int sheetNo, DataGrid dg, DataGridHelper helper, Dictionary <string, List <string> > SubClientList, List <string> ConsigneeList, List <string> ConsignerList, RuntimeData selectedRec = null)
            : this()
        {
            ConsigneeListSource        = (CollectionViewSource)FindResource("ConsigneeListSource");
            ConsignerListSource        = (CollectionViewSource)FindResource("ConsignerListSource");
            SubClientListSource        = (CollectionViewSource)FindResource("SubClientListSource");
            this.SubClientList         = SubClientList;
            this.ConsigneeList         = ConsigneeList;
            this.ConsignerList         = ConsignerList;
            ConsignerListSource.Source = this.ConsignerList;
            ConsigneeListSource.Source = this.ConsigneeList;
            string SelectedClientCode = ((Client)CustomerSelected.SelectedItem).CLCODE;

            SubClientListSource.Source = SubClientList.ContainsKey(SelectedClientCode) ? SubClientList[SelectedClientCode] : null;
            this.helper       = helper;
            this.backDataGrid = dg;
            this.sheetNo      = sheetNo;
            if (dataContext != null)
            {
                this.dataContext = dataContext;
            }
            if (dg.ItemsSource != null)
            {
                dataListContext = (ListCollectionView)dg.ItemsSource;
            }
            conssNumbers        = (CollectionViewSource)FindResource("ConsignmentNumbers");
            conssNumbers.Source = (from id in dataContext
                                   orderby id.ConsignmentNo
                                   select id.ConsignmentNo).ToList();
            InsertionDate.SelectedDate = DateTime.Today;
            if (selectedRec != null)
            {
                ConnsignmentNumber.Text = selectedRec.ConsignmentNo;
            }
            fillAllElements(ConnsignmentNumber.Text);
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();
            isInitialized = true;
            // Client listing data import procedure
            clientToEdit            = new List <Client>();
            clientViewSource        = (CollectionViewSource)FindResource("ClienTable");
            clientViewSource.Source = DataSources.ClientCopy;
            cityViewSource          = (CollectionViewSource)FindResource("CityTable");
            cityViewSource.Source   = DataSources.CityCopy;
            BillingDataDataContext db = new BillingDataDataContext();

            ServiceTable        = (CollectionViewSource)FindResource("ServiceTable");
            ServiceTable.Source = DataSources.ServicesCopy;
            #region setupCode
            PreviewMouseMove += OnPreviewMouseMove;
            #endregion
            if (Configs.Default.Background == null || Configs.Default.Background == "")
            {
                Configs.Default.Background = "LightSeaGreen";
            }
            this.MainGrid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Configs.Default.Background));
            ResourceDictionary dict = this.Resources;
            #region DataGrid Code Lines
            dataGridSource = (CollectionViewSource)FindResource("DataGridDataContext");
            dataGridHelper = new DataGridHelper(dataGridSource);
            buttonList     = new Dictionary <Button, int>();
            DataGridPageNum.DataContext   = dataGridHelper;
            DataGridNumOfRows.DataContext = dataGridHelper;
            #endregion
            #region Command Bindings
            CommandBinding SanitizingCommandBinding = new CommandBinding(SanitizingCommand, ExecuteSanitizingCommand, CanExecuteSanitizingCommand);
            this.CommandBindings.Add(SanitizingCommandBinding);
            SanitizingButton.Command = SanitizingCommand;

            CommandBinding PowerEntryCommandBinding = new CommandBinding(PowerEntryCommand, PowerEntryCommandExecuted, CanExecuteIsDataGridNotNull);
            this.CommandBindings.Add(PowerEntryCommandBinding);
            PowerEntryButton.Command = PowerEntryCommand;
            CommandBinding DeleteCommandBinding = new CommandBinding(DeleteCommand, DeleteCommandExecuted, DeleteCommand_CanExecute);
            this.CommandBindings.Add(DeleteCommandBinding);
            CommandBinding NewSheetCommandBinding = new CommandBinding(NewSheetCommand, NewSheetCommandExecuted, NewSheetCommand_CanExecute);
            NewSheetCommand.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            NewSheetButton.Command = NewSheetMenuItem.Command = NewSheetCommand;
            this.CommandBindings.Add(NewSheetCommandBinding);
            #endregion
            #region loading initial pages
            List <int> sheets = db.RuntimeDatas.Where(y => y.UserId == SecurityModule.currentUserName).Select(x => x.SheetNo).Distinct().ToList();
            foreach (int sheet in sheets)
            {
                List <RuntimeData> runtimeData = db.RuntimeDatas.Where(x => x.UserId == SecurityModule.currentUserName && x.SheetNo == sheet).OrderBy(z => z.ConsignmentNo).ToList();;
                dataGridHelper.addNewSheet(runtimeData, "sheet " + sheet.ToString());
                addingNewPage(sheet);
            }
            #endregion
            #region LoadConfigs
            Configs.Default.PropertyChanged += Default_PropertyChanged;
            #endregion
            LoadWorker                            = new BackgroundWorker();
            LoadWorker.DoWork                    += LoadWorker_DoWork;
            LoadWorker.ProgressChanged           += LoadWorker_ProgressChanged;
            LoadWorker.RunWorkerCompleted        += LoadWorker_RunWorkerCompleted;
            DeleteSheetWorker                     = new BackgroundWorker();
            DeleteSheetWorker.DoWork             += DeleteWorker_DoWork;
            DeleteSheetWorker.RunWorkerCompleted += DeleteWorker_RunWorkerCompleted;
            costingRules                          = new List <CostingRule>();
            setUiFromPermissions();
        }