コード例 #1
0
        private void saveItemButton_Click(object sender, RoutedEventArgs e)
        {
            if (item.Name == null)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Item Name is required!");
                defaultDialog.ShowDialog();
                return;
            }
            try
            {
                using (var db = new ApplicationDBContext())
                {
                    if (item.Id != 0)
                    {
                        db.Items.Update(item);
                        db.SaveChanges();
                    }
                    else
                    {
                        db.Items.Add(item);
                        db.SaveChanges();
                    }
                }
            }
            catch (DbUpdateException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }


            this.DialogResult = true;
            this.Close();
        }
コード例 #2
0
        private void saveContactButton_Click(object sender, RoutedEventArgs e)
        {
            if (contact.Name == null)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Contact Name is required!");
                defaultDialog.ShowDialog();
                return;
            }
            try
            {
                System.Diagnostics.Debug.WriteLine(contact.Id);
                using (var db = new ApplicationDBContext())
                {
                    if (contact.Id != 0)
                    {
                        db.Contacts.Update(contact);
                        db.SaveChanges();
                    }
                    else
                    {
                        db.Contacts.Add(contact);
                        db.SaveChanges();
                    }
                }
            }
            catch (DbUpdateException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }


            this.DialogResult = true;
            this.Close();
        }
コード例 #3
0
        private void saveReportButton_Click(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Start - " + this.report.StartDate);
            Debug.WriteLine("Start - " + this.report.EndDate);
            if (this.report.EndDate.Date > DateTime.Today.Date)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "End Date Cant be greater than today");
                defaultDialog.ShowDialog();
                return;
            }
            if (this.report.StartDate.Date > this.report.EndDate.Date)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Start Date cant be greater than End Date");
                defaultDialog.ShowDialog();
                return;
            }

            try
            {
                using (var db = new ApplicationDBContext())
                {
                    this.report.ReportItems = new List <ReportItem>();
                    List <Transaction> transactions = db.Transactions.Where(t => t.Created.Date >= report.StartDate.Date && t.Created.Date <= report.EndDate.Date).ToList();
                    foreach (Transaction transaction in transactions)
                    {
                        this.report.TotalTransactions += 1;

                        if (transaction.Credit)
                        {
                            report.Received += transaction.Amount;
                        }
                        else
                        {
                            report.Taken += transaction.Amount;
                        }
                    }
                    db.Reports.Add(report);
                    db.SaveChanges();
                }
            }
            catch (DbUpdateException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }


            this.DialogResult = true;
            this.Close();
        }
コード例 #4
0
        internal DialogRequest(string viewID, bool isModal, DialogInformation dialogInformation)
        {
            InnerWindow         = new DefaultDialog(this, viewID);
            InnerWindow.Closed += InnerWindow_Closed;

            m_IsModal = isModal;
            if (dialogInformation == null)
            {
                DialogInformation = new DialogInformation()
                {
                    Confirm = false
                };
            }
            else
            {
                DialogInformation = dialogInformation;
            }
        }
コード例 #5
0
        /// <summary>
        /// 同時起動ショートカット作成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateLauncher_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Title  = "同時起動のショートカットを指定してください。";
            fileDialog.Filter = "URL Files (.url)|*.url|LNK Files (*.lnk)|*.lnk|EXE Files(*.exe)|*.exe";
            if (fileDialog.ShowDialog() == true)
            {
                string createPath = SysIO.Path.Combine(SysIO.Path.GetDirectoryName(fileDialog.FileName), SysIO.Path.GetFileNameWithoutExtension(fileDialog.FileName) + "_QRCodeWebLoader.bat");
                using (StreamWriter writer = new StreamWriter(createPath, false))
                {
                    writer.WriteLine("start " + System.Reflection.Assembly.GetExecutingAssembly().Location + " 1 \"" + fileDialog.FileName + "\"");
                    writer.Close();
                }

                DefaultDialog error = new DefaultDialog("完了");
                error.SetMsg("ショートカットを作成しました。\n[" + createPath + "]");
                error.ShowDialog();
                return;
            }
        }
コード例 #6
0
 /// <summary>
 /// 監視開始
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Watcher_Click(object sender, RoutedEventArgs e)
 {
     QRDataSave();
     if (fileWatcher.EnableRaisingEvents)
     {
         fileWatcher.EnableRaisingEvents = false;
         Watcher.Content       = "読取開始";
         Status.Content        = "読み取り停止中";
         FileDirPath.IsEnabled = true;
         DirDialog.IsEnabled   = true;
         ReLoad.IsEnabled      = true;
         Delete.IsEnabled      = true;
     }
     else
     {
         fileWatcher.EnableRaisingEvents = false;
         if (!Directory.Exists(FileDirPath.Text))
         {
             DefaultDialog error = new DefaultDialog("エラー");
             error.SetMsg("フォルダが存在しません。");
             error.ShowDialog();
             return;
         }
         fileWatcher.Path                  = FileDirPath.Text;
         fileWatcher.NotifyFilter          = (NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.Security);
         fileWatcher.Filter                = "";
         fileWatcher.IncludeSubdirectories = false;
         fileWatcher.Changed              += new FileSystemEventHandler(Watcher_Changed);
         fileWatcher.Created              += new FileSystemEventHandler(Watcher_Changed);
         fileWatcher.Renamed              += new RenamedEventHandler(Watcher_Renamed);
         fileWatcher.EnableRaisingEvents   = true;
         Watcher.Content       = "読取停止";
         Status.Content        = "読み取り中";
         FileDirPath.IsEnabled = false;
         DirDialog.IsEnabled   = false;
         ReLoad.IsEnabled      = false;
         Delete.IsEnabled      = false;
     }
 }
コード例 #7
0
        private void saveTransactionButton_Click(object sender, RoutedEventArgs e)
        {
            if (transaction.IssuerId == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Issuer is required!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.ReceiverId == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Receiver is required!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.ItemId == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Item is required!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.Amount == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Amount must be greater than 0!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.IssuerId == transaction.ReceiverId)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Can not Issure to your self!");
                defaultDialog.ShowDialog();
                return;
            }
            Item item = (Item)ItemCombo.SelectedItem;

            if (transaction.Amount > item.Stock && !transaction.Credit)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Cant issue more more than stock!");
                defaultDialog.ShowDialog();
                return;
            }
            try
            {
                System.Diagnostics.Debug.WriteLine(transaction.Id);
                using (var db = new ApplicationDBContext())
                {
                    if (transaction.Credit)
                    {
                        item.Stock += transaction.Amount;
                    }
                    else
                    {
                        item.Stock -= transaction.Amount;
                    }
                    ItemReport itemReport = db.ItemReports.Where(ir => ir.ItemId == item.Id && ir.Created.Date == DateTime.Today).SingleOrDefault();
                    if (itemReport == null)
                    {
                        itemReport = new ItemReport();

                        if (transaction.Credit)
                        {
                            itemReport.Brought += transaction.Amount;
                        }
                        else
                        {
                            itemReport.Taken += transaction.Amount;
                        }
                        itemReport.Remaining     = item.Stock;
                        itemReport.Transactions += 1;
                        itemReport.ItemId        = item.Id;
                        db.ItemReports.Add(itemReport);
                    }
                    else
                    {
                        if (transaction.Credit)
                        {
                            itemReport.Brought += transaction.Amount;
                        }
                        else
                        {
                            itemReport.Taken += transaction.Amount;
                        }
                        itemReport.Remaining     = item.Stock;
                        itemReport.Transactions += 1;
                        itemReport.ItemId        = item.Id;
                        db.ItemReports.Update(itemReport);
                    }
                    db.Items.Update(item);
                    db.Transactions.Add(transaction);
                    db.SaveChanges();
                }
            }
            catch (DbUpdateException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }


            this.DialogResult = true;
            this.Close();
        }