コード例 #1
0
 private void Charge_Decide_Button_Click(object sender, RoutedEventArgs e)
 {
     Enable_Toggle();
     if (CheckFunction.balance_Integrity_Check(Num_Box.Text))
     {
         if (int.Parse(Num_Box.Text) > 10000)
         {
             CheckFunction.Message_Show("Error", "一度にチャージできる金額は10000円までです。");
             Enable_Toggle();
             return;
         }
         else if ((int.Parse(Num_Box.Text) + StaticParam._balance) > 100000)
         {
             CheckFunction.Message_Show("Error", "残高の最大は100000円までです。");
             Enable_Toggle();
             return;
         }
         else if (int.Parse(Num_Box.Text) == 0)
         {
             CheckFunction.Message_Show("Error", "チャージ額は1円以上を指定して下さい。");
             Enable_Toggle();
         }
         else
         {
             DatabaseAccess db = new DatabaseAccess();
             Frame.Navigate(typeof(ChargeConfirmationScreen), int.Parse(Num_Box.Text));
         }
     }
     else
     {
         CheckFunction.Message_Show("Error", "チャージ額は0~10000の値で指定して下さい。");
         Enable_Toggle();
         return;
     }
 }
コード例 #2
0
        // 別のページから遷移してきた時に呼び出されるメソッド
        // 画面描画は完了していないのでLoadedメソッドを利用?
        // 参照 : ttps://qiita.com/nagasakulllo/items/0b06ccc66b9fe0909b3f
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // ユーザー情報の再読込
            CheckFunction.update_user();

            if (StaticParam._permission == "利用者")
            {
                Product_Add_Button.IsEnabled  = false;
                Product_Edit_Button.IsEnabled = false;
                User_Edit_Button.IsEnabled    = false;
            }
            else if (StaticParam._permission == "仕入者")
            {
                User_Edit_Button.IsEnabled = false;
            }
            else if (StaticParam._permission == "管理者")
            {
                // 特になし
            }
            else
            {
                Product_Add_Button.IsEnabled  = false;
                Product_Edit_Button.IsEnabled = false;
                User_Edit_Button.IsEnabled    = false;
            }
        }
コード例 #3
0
        private void Purchase_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            if (Items.Count <= 0)
            {
                CheckFunction.Message_Show("Error", "商品が入力されていません");
                Enable_Toggle();
                return;
            }
            DatabaseAccess db = new DatabaseAccess();

            foreach (Item checkItem in Items)
            {
                if (checkItem._num <= 0)
                {
                    CheckFunction.Message_Show("Error", checkItem._itemName + "の購入数が0以下になっています。");
                    Enable_Toggle();
                    return;
                }

                if (db.isStocked_Item(checkItem._janCode, checkItem._num))
                {
                }
                else
                {
                    CheckFunction.Message_Show("Error", checkItem._itemName + "の在庫が不足しています。");
                    Enable_Toggle();
                    return;
                }
            }

            Frame.Navigate(typeof(ProductPurchaseConfirmationScreen), Items);
        }
コード例 #4
0
        private void Charge_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            DatabaseAccess db = new DatabaseAccess();

            db.Exec_Charge(StaticParam._mID, cPrice);
            db.Insert_Charge_Log(StaticParam._mID, cPrice);
            CheckFunction.Message_Show("チャージに成功しました。", "");
            Frame.Navigate(typeof(MenuScreen));
        }
コード例 #5
0
        // 削除実行メソッド
        private async void User_Delete_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            var msgs = new ContentDialog();

            msgs.Title               = ui._user_name + " のデータを削除します。";
            msgs.Content             = "この操作は取り消しできません。";
            msgs.PrimaryButtonText   = "OK";
            msgs.SecondaryButtonText = "Cancel";
            var result = await msgs.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                // OKの場合
                DatabaseAccess db = new DatabaseAccess();
                if (db.Search_UserInformation(ui._mid))
                {
                    db.Delete_UserInformation(ui._mid);
                    db.Insert_Operation_Log(StaticParam._mID, "ユーザー削除(mID = " + ui._mid + ", ユーザー名 = " + ui._user_name + ", 残高 = " + ui._balance + ", 権限 = " + ui._permission + ")");
                    CheckFunction.Message_Show(ui._user_name + " の削除に成功しました。", "");
                    Frame.Navigate(typeof(UserListEditScreen));
                }
                else
                {
                    CheckFunction.Message_Show("Error", "DB上に対象のmIDが存在しません。");
                    Enable_Toggle();
                    return;
                }
            }
            else if (result == ContentDialogResult.Secondary)
            {
                // Cancelの場合
                Enable_Toggle();
                return;
            }
            else
            {
                Enable_Toggle();
                return;
            }
            Enable_Toggle();
            return;
        }
コード例 #6
0
        private async void Product_Delete_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            var msgs = new ContentDialog();

            msgs.Title               = item._itemName + " のデータを削除します。";
            msgs.Content             = "この操作は取り消しできません。";
            msgs.PrimaryButtonText   = "OK";
            msgs.SecondaryButtonText = "Cancel";
            var result = await msgs.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                // OKの場合
                DatabaseAccess db = new DatabaseAccess();
                if (db.Search_Item(item._janCode))
                {
                    db.Delete_Item(item._janCode);
                    db.Insert_Operation_Log(StaticParam._mID, "商品削除(JANコード = " + item._janCode + ", 商品名 = " + item._itemName + ", 価格 = " + item._price + ", 在庫数 = " + item._num + ")");
                    CheckFunction.Message_Show(item._itemName + " の削除に成功しました。", "");
                    Frame.Navigate(typeof(ProductListEditScreen));
                }
                else
                {
                    CheckFunction.Message_Show("Error", "DB上に対象のJANコードが存在しません。");
                }
            }
            else if (result == ContentDialogResult.Secondary)
            {
                // Cancelの場合
                Enable_Toggle();
                return;
            }
            else
            {
                Enable_Toggle();
                return;
            }
            Enable_Toggle();
            return;
        }
コード例 #7
0
        private void Set_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            DatabaseAccess db      = new DatabaseAccess();
            int            balance = 0;

            if (!int.TryParse(Balance_TEXT.Text, out balance))
            {
                CheckFunction.Message_Show("Error", "設定額が不正です。");
            }
            else
            {
                if (balance >= 0 && balance <= 500000)
                {
                    db.Insert_Operation_Log(StaticParam._mID, "初期金額更新(" + db.Get_Balance().ToString() + "円 → " + balance.ToString() + "円)");
                    db.Set_Balance(balance);

                    int All_Balance = balance;
                    foreach (PaymentLog pl in Logs)
                    {
                        if (pl._type == "チャージ")
                        {
                            All_Balance += pl._total_price;
                        }
                        else if (pl._type == "仕入れ")
                        {
                            All_Balance += pl._total_price;
                        }
                    }
                    All_Balance_TEXT.Text = All_Balance.ToString() + "円";
                    CheckFunction.Message_Show("初期金額を更新しました。", "");
                }
                else
                {
                    CheckFunction.Message_Show("Error", "設定額は0円以上500000円以下です。");
                }
            }
            Enable_Toggle();
            return;
        }
 // 登録確定イベント
 private void Registration_Decide_Button_Click(object sender, RoutedEventArgs e)
 {
     Enable_Toggle();
     try
     {
         DatabaseAccess db = new DatabaseAccess();
         // 1件ずつ処理
         foreach (Item regItem in Items)
         {
             if (db.Search_Item(regItem._janCode))
             {
                 // DB上に存在している場合
                 // →既登録されている在庫数を今回追加するデータに加えて上書き
                 // →流れとしては登録データを削除、在庫数他を更新して再登録
                 Item oldItem = db.Get_Item(regItem._janCode);
                 regItem._num += oldItem._num;
                 db.Delete_Item(regItem._janCode);
                 db.Insert_Item(regItem);
                 db.Insert_Operation_Log(StaticParam._mID, "商品在庫更新(JANコード = " + regItem._janCode + ", 商品名 = " + oldItem._itemName + "→" + regItem._itemName + ", 価格 = " + oldItem._price + "→" + regItem._price + ", 在庫数 = " + oldItem._num + "→" + regItem._num + ")");
             }
             else
             {
                 // DB上に存在していない場合
                 // →普通に登録
                 db.Insert_Item(regItem);
                 db.Insert_Operation_Log(StaticParam._mID, "商品登録(JANコード = " + regItem._janCode + ", 商品名 = " + regItem._itemName + ", 価格 = " + regItem._price + ", 在庫数 = " + regItem._num + ")");
             }
         }
         db.Insert_Charge_Log(StaticParam._mID, (StaticParam._usePrice * -1));
         CheckFunction.Message_Show("商品の登録に成功しました。", "");
         StaticParam._usePrice = 0;
         Frame.Navigate(typeof(MenuScreen));
     }
     catch {
         CheckFunction.Message_Show("Error", "DBの登録に失敗しました。");
         Enable_Toggle();
     }
 }
コード例 #9
0
        private void Purchase_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            DatabaseAccess db = new DatabaseAccess();

            if (db.Check_Payment(StaticParam._mID, total_price))
            {
                db.Exec_Payment(StaticParam._mID, total_price);
                foreach (Item item in Items)
                {
                    db.Insert_Purchase_Log(StaticParam._mID, item._janCode, item._num, item._price);
                    db.Reduce_Item(item._janCode, item._num);
                }
                CheckFunction.Message_Show("決済に成功しました。", "");
                Frame.Navigate(typeof(MenuScreen));
            }
            else
            {
                CheckFunction.Message_Show("Error", "残高が不足しています。");
                Enable_Toggle();
                return;
            }
        }
コード例 #10
0
        private void Demand_Send_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            if (DEMAND_TEXT.Text == "")
            {
                CheckFunction.Message_Show("Error", "要望文を入力して下さい。");
                Enable_Toggle();
                return;
            }

            DatabaseAccess db = new DatabaseAccess();

            if (db.Insert_Demand(StaticParam._mID, DEMAND_TEXT.Text))
            {
                CheckFunction.Message_Show("要望文の送信に成功しました。", "");
                Frame.Navigate(typeof(MenuScreen));
            }
            else
            {
                CheckFunction.Message_Show("Error", "要望文の送信に失敗しました。");
                Enable_Toggle();
                return;
            }
        }
コード例 #11
0
 private void Keyword_Box_KeyUp(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         dataGrid.ItemsSource = new ObservableCollection <Item>(from i in Items where i._janCode.Contains(Keyword_Box.Text) | i._itemName.Contains(Keyword_Box.Text) | i._num.ToString().Contains(Keyword_Box.Text) | i._price.ToString().Contains(Keyword_Box.Text) | CheckFunction.Get_categoryName(i._categoryId).Contains(Keyword_Box.Text) orderby i._janCode descending select i);
     }
 }
コード例 #12
0
 // リストに対してキーワードフィルターを適用するメソッド
 private void Search_Button_Click(object sender, RoutedEventArgs e)
 {
     Enable_Toggle();
     dataGrid.ItemsSource = new ObservableCollection <Item>(from i in Items where i._janCode.Contains(Keyword_Box.Text) | i._itemName.Contains(Keyword_Box.Text) | i._num.ToString().Contains(Keyword_Box.Text) | i._price.ToString().Contains(Keyword_Box.Text) | CheckFunction.Get_categoryName(i._categoryId).Contains(Keyword_Box.Text) orderby i._janCode descending select i);
     Enable_Toggle();
 }
コード例 #13
0
        private void User_Edit_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            // 入力パラメータチェック
            if (mid_TEXT.Text == "")
            {
                // midが未入力です。
                CheckFunction.Message_Show("Error", "midが未入力です。");
                Enable_Toggle();
                return;
            }
            else if (userName_TEXT.Text == "")
            {
                // 名前が未入力です。
                CheckFunction.Message_Show("Error", "名前が未入力です。");
                Enable_Toggle();
                return;
            }
            else if (balance_TEXT.Text == "")
            {
                // 残高が未入力です。
                CheckFunction.Message_Show("Error", "残高が未入力です。");
                Enable_Toggle();
                return;
            }
            else if (permisson_TEXT.SelectedIndex == 0)
            {
                // 権限が未選択です。
                CheckFunction.Message_Show("Error", "権限が未選択です。");
                Enable_Toggle();
                return;
            }

            // フォーマットチェック
            if (!CheckFunction.mid_Integrity_Check(mid_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "midのフォーマットが間違っています。もしくは未対応のカードです。");
                Enable_Toggle();
                return;
            }
            else if (!CheckFunction.balance_Integrity_Check(balance_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "登録できる残高は0~99999の値です。");
                Enable_Toggle();
                return;
            }
            else if (!CheckFunction.user_name_Integrity_Check(userName_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "登録できる名前は25文字以下です。");
                Enable_Toggle();
                return;
            }

            DatabaseAccess db = new DatabaseAccess();

            if (db.Search_UserInformation(ui._mid))
            {
                db.Delete_UserInformation(ui._mid);
                UsersInformation add_ui = new UsersInformation(mid_TEXT.Text, userName_TEXT.Text, int.Parse(balance_TEXT.Text), ((ComboBoxItem)permisson_TEXT.SelectedItem).Content as string);
                db.Insert_UserInformation(add_ui);
                db.Insert_Operation_Log(StaticParam._mID, "ユーザー情報更新(mID = " + add_ui._mid + ", ユーザー名 = " + ui._user_name + "→" + add_ui._user_name + ", 残高 = " + ui._balance + "→" + add_ui._balance + ", 権限 = " + ui._permission + "→" + add_ui._permission + ")");
                CheckFunction.Message_Show(add_ui._user_name + " の情報を更新しました。", "");
                Frame.Navigate(typeof(UserListEditScreen));
            }
            else
            {
                CheckFunction.Message_Show("Error", "DB上に対象となるmIDが存在しません。");
                Enable_Toggle();
                return;
            }
        }
コード例 #14
0
        // データリスト初期化メソッド
        private ObservableCollection <PaymentLog> GetData()
        {
            DatabaseAccess db       = new DatabaseAccess();
            var            all_Logs = db.Get_AllPayment();


            // 売上商品の集計
            foreach (var buf in all_Logs)
            {
                if (buf._type == "購入")
                {
                    if (sellingList.ContainsKey(buf._janCode))
                    { // 既にリストに存在する場合、個数を加算
                        sellingList[buf._janCode] += buf._num;
                        // 件数の記録
                        sellingScore[buf._janCode]++;
                    }
                    else
                    {
                        sellingList.Add(buf._janCode, buf._num); // リストに含まれない場合、新規追加
                        sellingScore.Add(buf._janCode, 1);
                    }
                }
            }

            // 売れ筋評価
            foreach (var item in sellingList)
            {
                // 売上日時リスト
                DateTime[] sellingDate = db.Get_AllSellingDate(item.Key);
                // 売上個数リスト
                int[] sellingHistory = new int[0];
                // 仕入れ日時リスト
                DateTime[] stockingDate = db.Get_AllStockingDate(item.Key);
                // 仕入れインデックス
                int stockingidx = 0;
                // itemの売上件数
                int total_record = sellingScore[item.Key];
                // 初期化(ここまでは売上件数の保持につかっていたが、ここからはスコアを保存する)
                sellingScore[item.Key] = 0;
                // 仕入れ個数履歴
                int[] history = db.Get_AllStockingHistory(item.Key);
                // 仕入れ履歴インデックス
                int historyidx = 0, total_sell = 0;


                // 売上商品の集計
                foreach (var buf in all_Logs)
                {
                    if (buf._type == "購入")
                    {
                        if (item.Key == buf._janCode)
                        { // リストの追加
                            Array.Resize(ref sellingHistory, sellingHistory.Length + 1);
                            sellingHistory[sellingHistory.Length - 1] = buf._num;
                        }
                        else
                        {
                        }
                    }
                }

                // スコア計算
                for (int i = 0; i < sellingDate.Length; i++)
                {
                    total_sell += sellingHistory[i];
                    for (; ;)
                    {
                        if (stockingidx == stockingDate.Length - 1)
                        {
                            // 現在参照している仕入れ日時が最終仕入れの場合
                            break;
                        }
                        // 現在参照している仕入れ日時よりも後に仕入れがあった場合
                        if (stockingDate[stockingidx + 1] > sellingDate[i])
                        {
                            // 現在参照している仕入れ日時と後の仕入れ日時の間の売上日時の場合
                            break;
                        }
                        else
                        {
                            // 現在参照している仕入れ日時の後の仕入れ日時以降の売上日時の場合

                            for (; ;)
                            {
                                if (history[historyidx] - total_sell >= 0)
                                {
                                    break;
                                }
                                else
                                {
                                }
                                if (total_sell >= history[historyidx])
                                {
                                    total_sell = total_sell - history[historyidx];
                                    historyidx++;
                                    stockingidx++;
                                    continue;
                                }
                            }
                            break;
                        }
                    }
                    // 売上日時と、直前の仕入れ日時の差を分換算にてスコア算出(大きいほど売れていない)
                    TimeSpan ts = new TimeSpan();
                    if (i == 0)
                    {
                        // 初売上の場合
                        ts = sellingDate[i] - stockingDate[stockingidx];
                    }
                    else if (sellingDate[i - 1] > stockingDate[stockingidx])
                    {
                        // 直前のデータが売上日時の場合
                        ts = sellingDate[i] - sellingDate[i - 1];
                    }
                    else
                    {
                        // 直前のデータが仕入れ日時の場合
                        ts = sellingDate[i] - stockingDate[stockingidx];
                    }
                    sellingScore[item.Key] += (int)ts.TotalMinutes;
                }

                sellingScore[item.Key] /= item.Value;
                // (売上件数/売上個数)のレートでスコアを減らす手法(一度に多く買っている場合の考慮)
                float r = ((float)total_record / (float)item.Value);
                sellingScore[item.Key] = (int)(sellingScore[item.Key] * r);
            }


            foreach (var log in sellingScore)
            {
                PaymentLog pl = new PaymentLog();

                if (log.Key != "")
                {
                    Item item = db.Get_Item(log.Key);
                    pl._price    = log.Value;
                    pl._type     = CheckFunction.Get_categoryName(item._categoryId);
                    pl._itemName = item._itemName;
                    pl._num      = item._num;
                }
                Data.Add(pl);
            }
            List <Item> itemlist = db.Get_AllItem();

            foreach (var item in itemlist)
            {
                if (!sellingList.ContainsKey(item._janCode))
                {
                    PaymentLog pl = new PaymentLog();
                    pl._price    = 99999;
                    pl._type     = CheckFunction.Get_categoryName(item._categoryId);
                    pl._itemName = item._itemName;
                    pl._num      = item._num;
                    Data.Add(pl);
                }
            }
            Data = new ObservableCollection <PaymentLog>(from i in Data orderby i._price ascending select i);
            return(Data);
        }
コード例 #15
0
        ///////////////////////////////////////////////// mid読み取りここまで

        // 追加決定ボタン押下イベント
        private void User_Add_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            // 入力パラメータチェック
            if (mid_TEXT.Text == "")
            {
                // midが未入力です。
                CheckFunction.Message_Show("Error", "midが未入力です。");
                Enable_Toggle();
                return;
            }
            else if (userName_TEXT.Text == "")
            {
                // 名前が未入力です。
                CheckFunction.Message_Show("Error", "名前が未入力です。");
                Enable_Toggle();
                return;
            }
            else if (balance_TEXT.Text == "")
            {
                // 残高が未入力です。
                CheckFunction.Message_Show("Error", "残高が未入力です。");
                Enable_Toggle();
                return;
            }
            else if (permisson_TEXT.SelectedIndex == 0)
            {
                // 権限が未選択です。
                CheckFunction.Message_Show("Error", "権限が未選択です。");
                Enable_Toggle();
                return;
            }

            // フォーマットチェック
            if (!CheckFunction.mid_Integrity_Check(mid_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "midのフォーマットが間違っています。もしくは未対応のカードです。");
                Enable_Toggle();
                return;
            }
            else if (!CheckFunction.balance_Integrity_Check(balance_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "初期登録できる残高は0~99999の値です。");
                Enable_Toggle();
                return;
            }
            else if (!CheckFunction.user_name_Integrity_Check(userName_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "登録できる名前は25文字以下です。");
                Enable_Toggle();
                return;
            }


            // 既登録チェック
            DatabaseAccess db = new DatabaseAccess();

            if (db.Search_UserInformation(mid_TEXT.Text))
            {
                // 既登録されています。
                CheckFunction.Message_Show("Error", "このカードは既に登録されています。同じカードは登録できません。");
                Enable_Toggle();
                return;
            }

            // ユーザー登録
            UsersInformation ui = new UsersInformation(mid_TEXT.Text, userName_TEXT.Text, int.Parse(balance_TEXT.Text), ((ComboBoxItem)permisson_TEXT.SelectedItem).Content as string);

            try{
                db.Insert_UserInformation(ui);
                db.Insert_Operation_Log(StaticParam._mID, "ユーザー登録(mID = " + ui._mid + ", ユーザー名 = " + ui._user_name + ", 残高 = " + ui._balance + ", 権限 = " + ui._permission + ")");
            }catch {
                // タイマーストップ
                _timer.Stop();
                Frame.Navigate(typeof(OperationFailureScreen));
                Enable_Toggle();
                return;
            }

            // タイマーストップ
            _timer.Stop();
            // 画面遷移
            CheckFunction.Message_Show("ユーザーの追加に成功しました。", "");
            Frame.Navigate(typeof(UserListEditScreen));
        }
コード例 #16
0
        private void Category_TEXT_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            if (cb.SelectedIndex == 0)
            {
                return;
            }
            dataGrid.ItemsSource = new ObservableCollection <PaymentLog>(from i in Data where  i._type.Contains(CheckFunction.Get_categoryName(cb.SelectedIndex))  orderby i._price ascending select i);
        }
コード例 #17
0
        private void JANCODE_TEXT_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            //Encoding Enc = Encoding.GetEncoding("");
            //if (Enc.GetByteCount(JANCODE_TEXT.Text) == JANCODE_TEXT.Text.Length * 2
            //JANCODE_TEXT.Text = Regex.Replace(JANCODE_TEXT.Text, "[0-9]", p => ((char)(p.Value[0] - '0' + '0')).ToString());
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                JANCODE_TEXT.IsReadOnly = true;
                if (!CheckFunction.JANCODE_Integrity_Check(JANCODE_TEXT.Text))
                {
                    JANCODE_TEXT.IsReadOnly = false;
                    CheckFunction.Message_Show("Error", "JANコードが正しくありません");
                    JANCODE_TEXT.Text = "";
                    return;
                }

                // 謎ポイント
                // 初回、if (Items.First(x => x._janCode == last_jan)._janCode == JANCODE_TEXT.Text)でマッチするレコードがなかった場合例外発生、2回目以降は例外は発生せずelseに飛ぶ
                // 応急措置として同じコードを書いています
                // いろいろおかしい
                try
                {
                    // リスト上に存在する場合
                    if (Items.First(x => x._janCode == JANCODE_TEXT.Text)._janCode == JANCODE_TEXT.Text)
                    {
                        last_jan = JANCODE_TEXT.Text;
                        Items.First(x => x._janCode == JANCODE_TEXT.Text)._num += 1;
                    }
                    else
                    {
                        // リスト上に存在しない場合
                        DatabaseAccess db = new DatabaseAccess();
                        if (db.Search_Item(JANCODE_TEXT.Text))
                        {
                            // DB既登録の場合
                            Item item = db.Get_Item(JANCODE_TEXT.Text);
                            item._num = 1;
                            last_jan  = JANCODE_TEXT.Text;
                            Items.Add(item);
                        }
                        else
                        {
                            // DB未登録の場合
                            CheckFunction.Message_Show("Error", "データベースに存在しない商品です。");
                        }
                    }
                }
                catch
                {
                    // リスト上に存在しない場合
                    DatabaseAccess db = new DatabaseAccess();
                    if (db.Search_Item(JANCODE_TEXT.Text))
                    {
                        // DB既登録の場合
                        Item item = db.Get_Item(JANCODE_TEXT.Text);
                        item._num = 1;
                        last_jan  = JANCODE_TEXT.Text;
                        Items.Add(item);
                    }
                    else
                    {
                        // DB未登録の場合
                        CheckFunction.Message_Show("Error", "データベースに存在しない商品です。");
                    }
                }


                // 処理完了後
                JANCODE_TEXT.Text       = "";
                JANCODE_TEXT.IsReadOnly = false;
            }
        }
コード例 #18
0
        private async void JANCODE_TEXT_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                JANCODE_TEXT.IsReadOnly = true;
                if (!CheckFunction.JANCODE_Integrity_Check(JANCODE_TEXT.Text))
                {
                    JANCODE_TEXT.IsReadOnly = false;
                    CheckFunction.Message_Show("Error", "JANコードが正しくありません");
                    JANCODE_TEXT.Text = "";
                    return;
                }

                try
                {
                    string s = await RakutenSearchAPI.JAN_Search(JANCODE_TEXT.Text);

                    Candidate_Set(s);
                }
                catch {
                    JANCODE_TEXT.Text = "";
                    return;
                }
                finally{
                }

                // 謎ポイント
                // 初回、if (Items.First(x => x._janCode == last_jan)._janCode == JANCODE_TEXT.Text)でマッチするレコードがなかった場合例外発生、2回目以降は例外は発生せずelseに飛ぶ
                // 応急措置として同じコードを書いています
                // いろいろおかしい
                try
                {
                    // リスト上に存在する場合
                    if (Items.First(x => x._janCode == JANCODE_TEXT.Text)._janCode == JANCODE_TEXT.Text)
                    {
                        last_jan = JANCODE_TEXT.Text;
                        Items.First(x => x._janCode == JANCODE_TEXT.Text)._num += 1;
                    }
                    else
                    {
                        DatabaseAccess db = new DatabaseAccess();
                        if (db.Search_Item(JANCODE_TEXT.Text))
                        {
                            // DB既登録の場合
                            Item item = db.Get_Item(JANCODE_TEXT.Text);
                            item._num = 1;
                            last_jan  = JANCODE_TEXT.Text;
                            Items.Add(item);
                        }
                        else
                        {
                            // DB未登録の場合
                            Item item = new Item(JANCODE_TEXT.Text, "", 0, 0, 1);
                            last_jan = JANCODE_TEXT.Text;
                            Items.Add(item);
                        }
                    }
                }catch {
                    DatabaseAccess db = new DatabaseAccess();
                    if (db.Search_Item(JANCODE_TEXT.Text))
                    {
                        // DB既登録の場合
                        Item item = db.Get_Item(JANCODE_TEXT.Text);
                        item._num = 1;
                        last_jan  = JANCODE_TEXT.Text;
                        Items.Add(item);
                    }
                    else
                    {
                        // DB未登録の場合
                        Item item = new Item(JANCODE_TEXT.Text, "", 0, 0, 1);
                        last_jan = JANCODE_TEXT.Text;
                        Items.Add(item);
                    }
                }

                //DatabaseAccess db = new DatabaseAccess();
                //db.Insert_Item(item);

                // 処理完了後
                JANCODE_TEXT.Text       = "";
                JANCODE_TEXT.IsReadOnly = false;
            }
        }
コード例 #19
0
        private void Registration_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            Enable_Toggle();
            if (!int.TryParse(Use_Price.Text, out StaticParam._usePrice) || Use_Price.Text == "")
            {
                CheckFunction.Message_Show("Error", "正しい仕入れ額を入力して下さい");
                Enable_Toggle();
                return;
            }
            if (Items.Count <= 0)
            {
                CheckFunction.Message_Show("Error", "商品が入力されていません");
                Enable_Toggle();
                return;
            }
            // Items整合性チェック
            foreach (Item item in Items)
            {
                // 入力パラメータチェック
                if (item._janCode == "")
                {
                    // JANコードが未入力です。
                    CheckFunction.Message_Show("Error", item._janCode + "\nJANコードが未入力です。");
                    Enable_Toggle();
                    return;
                }
                else if (item._itemName == "")
                {
                    // 商品名が未入力です。
                    CheckFunction.Message_Show("Error", item._janCode + "\n商品名が未入力です。");
                    Enable_Toggle();
                    return;
                }
                else if (item._price.ToString() == "")
                {
                    // 価格が未入力です。
                    CheckFunction.Message_Show("Error", item._janCode + "\n価格が未入力です。");
                    Enable_Toggle();
                    return;
                }
                else if (item._num.ToString() == "")
                {
                    // 在庫が未選択です。
                    CheckFunction.Message_Show("Error", item._janCode + "\n在庫が未入力です。");
                    Enable_Toggle();
                    return;
                }
                else if (item._categoryId == 0)
                {
                    // カテゴリが未選択です。
                    CheckFunction.Message_Show("Error", item._janCode + "\nカテゴリが未選択です。");
                    Enable_Toggle();
                    return;
                }

                // フォーマットチェック
                if (!CheckFunction.JANCODE_Integrity_Check(item._janCode))
                {
                    CheckFunction.Message_Show("Error", item._janCode + "\nJANコードのフォーマットが間違っています。なんでこのエラー出たの?");
                    Enable_Toggle();
                    return;
                }
                else if (!CheckFunction.itemName_Integrity_Check(item._itemName))
                {
                    CheckFunction.Message_Show("Error", item._janCode + "\n登録できる商品名は50文字以下です。");
                    Enable_Toggle();
                    return;
                }
                else if (!CheckFunction.price_Integrity_Check(item._price.ToString()))
                {
                    CheckFunction.Message_Show("Error", item._janCode + "\n登録できる価格は1~5000の値です。");
                    Enable_Toggle();
                    return;
                }
                else if (!CheckFunction.num_Integrity_Check(item._num.ToString()))
                {
                    CheckFunction.Message_Show("Error", item._janCode + "\n登録できる在庫数は0~200の値です。");
                    Enable_Toggle();
                    return;
                }
            }
            Frame.Navigate(typeof(ProductRegistrationConfirmationScreen), Items);
        }
コード例 #20
0
        private void Edit_Decide_Button_Click(object sender, RoutedEventArgs e)
        {
            // 入力パラメータチェック
            if (janCode_TEXT.Text == "")
            {
                // JANコードが未入力です。
                CheckFunction.Message_Show("Error", "JANコードが未入力です。");
                return;
            }
            else if (itemName_TEXT.Text == "")
            {
                // 商品名が未入力です。
                CheckFunction.Message_Show("Error", "商品名が未入力です。");
                return;
            }
            else if (price_TEXT.Text == "")
            {
                // 価格が未入力です。
                CheckFunction.Message_Show("Error", "価格が未入力です。");
                return;
            }
            else if (num_TEXT.Text == "")
            {
                // 在庫が未選択です。
                CheckFunction.Message_Show("Error", "在庫が未入力です。");
                return;
            }
            else if (category_TEXT.SelectedIndex == 0)
            {
                // カテゴリが未選択です。
                CheckFunction.Message_Show("Error", "カテゴリが未選択です。");
                return;
            }

            // フォーマットチェック
            if (!CheckFunction.JANCODE_Integrity_Check(janCode_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "JANコードのフォーマットが間違っています。なんでこのエラー出たの?");
                return;
            }
            else if (!CheckFunction.itemName_Integrity_Check(itemName_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "登録できる商品名は50文字以下です。");
                return;
            }
            else if (!CheckFunction.price_Integrity_Check(price_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "登録できる価格は0~5000の値です。");
                return;
            }
            else if (!CheckFunction.num_Integrity_Check(num_TEXT.Text))
            {
                CheckFunction.Message_Show("Error", "登録できる在庫数は0~200の値です。");
                return;
            }

            Enable_Toggle();
            DatabaseAccess db = new DatabaseAccess();

            if (db.Search_Item(item._janCode))
            {
                db.Delete_Item(item._janCode);
                Item add_item = new Item(janCode_TEXT.Text, itemName_TEXT.Text, category_TEXT.SelectedIndex, int.Parse(price_TEXT.Text), int.Parse(num_TEXT.Text));
                db.Insert_Item(add_item);
                db.Insert_Operation_Log(StaticParam._mID, "商品情報更新(JANコード = " + add_item._janCode + ", 商品名 = " + item._itemName + "→" + add_item._itemName + ", 価格 = " + item._price + "→" + add_item._price + ", 在庫数 = " + item._num + "→" + add_item._num + ")");
                CheckFunction.Message_Show(add_item._itemName + " の情報を更新しました。", "");
                Frame.Navigate(typeof(ProductListEditScreen));
            }
            else
            {
                CheckFunction.Message_Show("Error", "DB上に対象となるJANコードが存在しません。");
                Enable_Toggle();
                return;
            }
        }