private void btn_SearchInfo_Click(object sender, RoutedEventArgs e)
        {
            BookLib booklib = new BookLib();
            ObservableCollection <Book> _book = booklib.GetInformation("Computer network", false);

            //Binding bind = new Binding();
            listView1.DataContext = _book;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Menu    menu = new Menu();
            BookLib lib  = new BookLib();

            menu.List = lib;

            do
            {
                menu.printTitle();
                string opt = menu.chooseOption();
                menu.processWithOption(opt);
            } while (!menu.Existed);

            Console.ReadKey();
        }
        /// <summary>
        /// Get data from datasource
        /// </summary>
        /// <returns></returns>
        private ObservableCollection <Book> GetQueryResults()
        {
            BookLib bokLib = new BookLib();

            return(bokLib.Search(SearchLib.Search("")));
        }
        //Create a Book or Journal
        private void Validation_Click(object sender, RoutedEventArgs e)
        {
            string title = string.Empty;

            if (boxTitle.Text != string.Empty)
            {
                title = boxTitle.Text;
            }
            else
            {
                ShowMessage("Invalide Title", "Invalide Data");
                return;
            }

            Guid   ISBN = Guid.Empty;
            UInt64 ISBNValue;

            if (boxISBN.Text != string.Empty && boxISBN.Text.Length == 10 && UInt64.TryParse(boxISBN.Text, out ISBNValue))
            {
                ISBN = Guid.Parse("AAAAAAAA-BBBB-CCCC-DDDD-EE" + boxISBN.Text);
                if (ItCollec[ISBN] != default(AbstractItem))
                {
                    ShowMessage("A book with this ISBN Already Exist...", "Invalide Data");
                    return;
                }
            }
            else
            {
                ShowMessage("Invalide ISBN", "Invalide Data");
                return;
            }

            double price = default(double);

            if (!double.TryParse(boxPrice.Text, out price))
            {
                ShowMessage("Invalide Price", "Invalide Data");
                return;
            }

            DateTime EditionDate = new DateTime(boxDate.Date.Year, boxDate.Date.Month, boxDate.Date.Day);

            if (EditionDate > DateTime.Now)
            {
                ShowMessage("Invalide Date", "Invalide Data");
                return;
            }

            Categorie subject = Categorie.Other;

            if (!Enum.TryParse(boxCategorie.SelectedItem.ToString(), out subject))
            {
                ShowMessage("Invalide Categorie", "Invalide Data");
                return;
            }

            int stock = default(int);

            if (boxStock.Text == string.Empty)
            {
                stock = 0;
            }
            else if (!int.TryParse(boxStock.Text, out stock))
            {
                ShowMessage("Invalide stock", "Invalide Data");
                return;
            }

            decimal discount = default(decimal);

            if (boxDiscount.Text == string.Empty)
            {
                discount = 0;
            }
            else if (!decimal.TryParse(boxDiscount.Text, out discount))
            {
                ShowMessage("Invalide Discount", "Invalide Data");
                return;
            }

            AbstractItem newBook;

            if (selectedType is BookLib)
            {
                newBook = new BookLib(ISBN, price, title, EditionDate, subject, stock, discount, null);
            }
            else
            {
                newBook = new JournalLib(ISBN, price, title, EditionDate, subject, stock, discount, null);
            }
            ItCollec.Add(newBook);
            listView.Items.Add(newBook);
            boxTitle.Text         = string.Empty;
            boxISBN.Text          = string.Empty;
            boxPrice.Text         = string.Empty;
            boxStock.Text         = string.Empty;
            boxDiscount.Text      = string.Empty;
            sPEmployee.Visibility = Visibility.Collapsed;
        }
Esempio n. 5
0
        protected override void AfterContentWritten()
        {
            ReportSourceProfile profile = this.SheetAdapter.ReportProfile;

            //設定顯示格式
            //this.SheetAdapter.SetFormat(4, profile.IndexOf("退驗數量") + 1, "[紅色]G/通用格式;G/通用格式;* \"-\"_-");
            //string format = "#,##0.00;#,##0.00;* \"-\"_-";
            //string format = "G/通用格式;G/通用格式;* \"-\"_-";

            this.SheetAdapter.SetFormat(4, profile.IndexOf("生產效率") + 1, "0.00%");

            //設定小數位數
            int[] formatCols = new int[]
            {
                profile.IndexOf("標準工時") + 1,
                profile.IndexOf("單位人工成本") + 1,
                profile.IndexOf("標準總工時") + 1,
                profile.IndexOf("標準總工資") + 1,
                profile.IndexOf("單位標準工資") + 1,
                profile.IndexOf("內部工時") + 1,
                profile.IndexOf("內部工資") + 1,
                profile.IndexOf("外包工資") + 1,
                profile.IndexOf("外包工時") + 1,
                profile.IndexOf("實際工時") + 1,
                profile.IndexOf("實際工資") + 1,
                profile.IndexOf("實際總工時") + 1,
                profile.IndexOf("實際總工資") + 1
            };

            foreach (int col in formatCols)
            {
                this.SheetAdapter.SetFormat(4, col, "[=0]* \"-\"_-;G/通用格式");
            }

            formatCols = new int[]
            {
                profile.IndexOf("標準工時") + 1,
                profile.IndexOf("單位人工成本") + 1,
                profile.IndexOf("標準總工時") + 1,
                profile.IndexOf("標準總工資") + 1,
                profile.IndexOf("單位標準工資") + 1,
                profile.IndexOf("內部工時") + 1,
                profile.IndexOf("內部工資") + 1,
                profile.IndexOf("外包工資") + 1,
                profile.IndexOf("外包工時") + 1,
                profile.IndexOf("實際工時") + 1,
                profile.IndexOf("實際工資") + 1,
                profile.IndexOf("實際總工資") + 1
            };
            this.SheetAdapter.RoundValues(formatCols, 4, 2);

            //移動欄位
            //this.SheetAdapter.GetRange(1, 14, 1, 15).EntireColumn.Cut(Missing);
            //this.SheetAdapter.GetRange(1, 21).EntireColumn.Insert(XlInsertShiftDirection.xlShiftToRight, Missing);

            //設定外觀樣式
            Range range;

            for (int i = 0; i < 4; i++)
            {
                this.SheetAdapter.GetRange(1, profile.IndexOf("內部工時") + 1 + i).ColumnWidth = 15.5;
            }
            for (int i = 0; i < 10; i++)
            {
                this.SheetAdapter.GetRange(1, profile.IndexOf("實際總工時") + 1 + i).ColumnWidth = 13.5;
            }

            //this.SheetAdapter.GetRange(1, _table.Columns.IndexOf("單位人工成本") + 1).ColumnWidth = 15;
            range = this.SheetAdapter.GetRange(3, 1, this.SheetAdapter.UsedRowsCount, profile.IndexOf("單位") + 1);
            range.Columns.AutoFit();

            range = this.SheetAdapter.GetUsedRange(3);
            this.SheetAdapter.SetBorder(range, true, true, true, true);

            //設定小計總計列公式
            int    subttlCol             = this.SheetAdapter.ReportProfile.IndexOf("實際總工時") + 1;
            string subttlColLetter       = BookLib.GetColumnLetter(subttlCol);
            int    subttlEffectCol       = this.SheetAdapter.ReportProfile.IndexOf("生產效率") + 1;
            string subttlEffectColLetter = BookLib.GetColumnLetter(subttlEffectCol);
            string ttlFormula            = "=";

            foreach (int subttlRow in _subttlRows)
            {
                Range subttlCell = this.SheetAdapter.GetRange(subttlRow, subttlCol);
                subttlCell.Formula        = "= " + subttlCell.Value + " + " + subttlColLetter + (subttlRow - 1) + " + " + subttlColLetter + (subttlRow - 2);
                subttlCell.Interior.Color = 65535;
                //更改 標準總工時/實際總工時
                Range subttlEffectCell = this.SheetAdapter.GetRange(subttlRow, subttlEffectCol);
                subttlEffectCell.Formula = "=" + BookLib.GetColumnLetter(this.SheetAdapter.ReportProfile.IndexOf("標準總工時") + 1) + subttlRow + "/"
                                           + subttlColLetter + subttlRow;

                ttlFormula += subttlColLetter + (subttlRow) + "+";
            }
            ttlFormula = ttlFormula.Substring(0, ttlFormula.Length - 1);

            //總計列公式
            Range ttlCell = this.SheetAdapter.GetRange(_ttlRow, subttlCol);

            ttlCell.Formula        = ttlFormula;
            ttlCell.Interior.Color = 65535;

            //更改 標準總工時/實際總工時
            Range ttlEffectCell = this.SheetAdapter.GetRange(_ttlRow, subttlEffectCol);

            ttlEffectCell.Formula = "=" + BookLib.GetColumnLetter(this.SheetAdapter.ReportProfile.IndexOf("標準總工時") + 1) + _ttlRow + "/"
                                    + subttlColLetter + _ttlRow;

            range = this.SheetAdapter.GetRange(4, 1);
            range.Select();
            this.Application.ActiveWindow.FreezePanes = true;

            base.AfterContentWritten();
        }