G3518_And_note_物品登録の追加

2025727

12:05

G3518_andoroid_and_note_goods_registration_add

 

参考コード

Version:0.9 StartHTML:00000000 EndHTML:00000000 StartFragment:00000000 EndFragment:00000000 G3518-プロジェクト

 

 

 

 

 

 

 

 

物品管理のデータ登録に使いたくなった

 

 

 

 

 

 

 

 

 

 

 

 

 

 

整理整頓のお助けアプリ

 

 

 

 

物品名のサブフォルダを追加します

 

public static string Path_goods = "";

Path_goods = Path_files + @"/goods";

if (System.IO.Directory.Exists(Path_goods) == false) Directory.CreateDirectory(Path_goods);

 

ボタン配置を検討する前に、不要な機能を調査します

 

 

 

 

 

ボタン処理の調査

 

 

 

ボタン⑧のGPS表示は、音声コマンドに変更します

 

 

 

 

 

 

 

 

 

 

新しいボタン配置を作ります

 

 

 

 

プロジェクトコードのバックアップを忘れていました

 

コマンドモードに関する処理をコメントにします

 

 

音声変換、実行保存、取消ボタンにおいて

 

 

 

private async void Button8_Click(object? sender, EventArgs e)

{

// 本日表示

Main_name_set("本日表示");

dsp_note(0, 0, 0);

 

// GPS取得

// ボタン⑧役割変更のためGPSは停止します

//await get_GPS();

//Gps_cst_tmp = Gps_cst;

}

 

private void Button7_Click(object? sender, EventArgs e)

{

// 物品検索

Main_name_set("物品検索");

Edt_tbl[0].Text = "";

}

 

private void Button6_Click(object? sender, EventArgs e)

{

// 収納記録

Main_name_set("収納記録");

Edt_tbl[0].Text = "";

}

 

音声変換ボタンの定義を変更します

 

 

 

 

実行/保存が動かず、下記修正をして、保存が直りました

 

 

物品検索モードでの音声変換タイミング確認

 

 

 

物品検索モードでの音声変換タイミング確認②

 

 

 

 

 

 

 

物品検索で、当面品目ファイルが蓄積されるか確認します

 

 

このように、音声変換のたびに、新しい品名ファイルが生成されます

 

 

いちいち「保存/実行」ボタンを押さなくてよいので、登録は早くできます

 

 

 

収納管理の落とし穴

 

 

物品検索の基本設計

 

 

収納の基本設計

 

 

収納

半透明バッグ

ケース400

ケース500

ゼブラ

 

連番の付与

 

 

収納の登録処理

 

 

 

 

 

収納名称の登録で躓いています

 

 

 

物品管理ボタン

 

 

「収納タイプ」入力後の動き

 

 

 

 

 

ひーーー 頭がパンクしました

 

 

ボタン名の変更

 

 

グローバル変数を追加します

 

 

ボタン処理を変更します

 

 

ストレージタイプは手作業でテキストファイルを作ります

 

 

 

 

ストレージタイプ一覧表示関数を作成します

 

// ストレージタイプ一覧表示

private void Storage_type_dsp(string prm_type_name)

{

// 一覧表示と検索を兼用します

string[] name = new string[200];

string[] sta_cod = new string[200];

int tbl_max,i;

bool find_flg = false;

 

 

string txt_path = Path_goods + @"/storage.txt";

 

if (File.Exists(txt_path) == false)

{

dsp_info("strage.txt ファイルが見つかりません");

return;

}

 

tbl_max = com_txt_tbl_red(txt_path, 1, sta_cod);

tbl_max = com_txt_tbl_red(txt_path, 0, name);

 

if (prm_type_name == "")

{

// 一覧表示

Edt_tbl[0].Text = "";

for(i=0;i<tbl_max;i++)

{

Edt_tbl[0].Text += name[i] + "  " + sta_cod[i] + "\r\n";

}

}

else

{

// タイプ名検索

for (i = 0; i < tbl_max; i++)

{

if(prm_type_name == name[i].Trim())

{

find_flg = true;

Storage_type = name[i];

Storage_no_sta = int.Parse(sta_cod[i].Trim());

break;

}

}

if (find_flg == false) dsp_info("入力された収納タイプは登録されていません");

 

}

 

}

 

 

 

 

ストレージタイプを音声入力します

 

 

 

 

 

タイプの配下に登録される名称一覧を表示します

 

 

// ストレージ内訳表示

private bool Storage_name_dsp(string prm_name)

{

// 名称指示があれば検索として機能します

 

string txt_path = Path_goods_storage + @"/" + Storage_type.Trim() + ".txt";

string msg_cst = "";

string[] name = new string[500];

string[] cod = new string[500];

int i, tbl_max;

bool find_flg = false;

 

Edt_tbl[0].Text = "";

if (File.Exists(txt_path) == false) return false;

 

tbl_max = com_txt_tbl_red(txt_path, 1, name);

tbl_max = com_txt_tbl_red(txt_path, 0, cod);

 

if (prm_name == "")

{

// 名称がないので、一覧表示です

msg_cst = "[" + Storage_type + "]  " + "音声入力で入れ物のタイトルを入力します";

dsp_info(msg_cst);

 

for (i = 0; i < tbl_max; i++)

{

Edt_tbl[0].Text += "[" + cod[i] + "]  " + name[i] + "\r\n";

Storage_no_sta = int.Parse(cod[i].Trim());

}

}

else

{

// 名称があるので検索です

for (i = 0; i < tbl_max; i++)

{

if(prm_name.Trim() == name[i])

{

find_flg = true;

break;

}

}

 

}

 

return find_flg;

}

 

タイプ別名称は音声入力、フリック入力のあと「実行/保存」ボタンで登録します

 

 

 

 

 

 

 

 

 

収納名称を確定するためのグローバル変数を追加します

 

 

入れ物のタイトルを「実行/保存」ボタンで確定します

 

 

 

 

// 収納されている物品名の一覧を表示します

private bool Storage_goods_name_dsp(string prm_goods_name)

{

// パラメータが空白なら、一覧表示です

 

string txt_path = Path_goods_storage + @"/" + Storage_type.Trim() + "_" + Storage_goods_title.Trim() + ".txt";

string msg_cst = "";

string[] name = new string[500];

int i, tbl_max;

bool find_flg = false;

string key;

 

// パラメータのスペース判定はしません

 

if (File.Exists(txt_path) == false) return false;

tbl_max = com_txt_tbl_red(txt_path, 0, name);

 

if (prm_goods_name == "")

{

Edt_tbl[0].Text = "";

for (i = 0; i < tbl_max; i++)

{

Edt_tbl[0].Text += (i + 1).ToString() + " . " + name[i] + "\r\n";

}

}

else

{

// 名称があるので検索です

key = Regex.Replace(prm_goods_name, @"\s", "");        // 中間のスペース除外

for (i = 0; i < tbl_max; i++)

{

if (key == name[i]) { find_flg = true; break; }

}

 

}

return find_flg;

}

 

// 物品収納登録

private void Storage_goods_name_add(string prm_goods_name)

{

string key;

 

if (Str_space_chk(prm_goods_name) == true) return; // スペース判定

 

key = Regex.Replace(prm_goods_name, @"\s", ""); // 中間のスペース除外

 

// 収納する物品名の登録

string txt_path = Path_goods_storage + @"/" + Storage_type.Trim() + "_" + Storage_goods_title.Trim() + ".txt";

 

Txt_fil_rec_add(txt_path, key);     // 行追加

 

txt_path = Path_goods_name + @"/" + key + ".txt";

 

if (File.Exists(txt_path) == false)

{

// 新規生成

Txt_fil_rec_add(txt_path, key);

Txt_fil_rec_add(txt_path, Storage_type + " _ " + Storage_goods_title);

}

else

{

// 更新

Txt_fil_rec_add(txt_path, Storage_type + " _ " + Storage_goods_title);

}

 

}

 

 

物品の収納登録は「実行/保存」ボタンを使いません

 

 

 

 

中間のスペースを除外する処理が必用です

 

key = Regex.Replace(key, @"\s", "");

 

msg_cst = "1/3 [" + Storage_type + "]  " + "音声入力で入れ物のタイトルを入力します";

dsp_info(msg_cst);

 

 

msg_cst = "[" + Storage_type + " _ " + Storage_goods_title + "]  " + "収納する物品名を入力します";

dsp_info(msg_cst);

 

 

同じようなスペース判定があるので、関数化します

 

 

 

 

 

 

 

 

 

今は戻るがないので、頭から表示をやり直して、登録を確認します

 

 

 

一覧表示の1行目に、タイトルを追加する

 

 

 

 

 

案内メッセージは、Main_name_set() 関数の中に組み込みします

 

 

 

 

 

 

「取消し」ボタンの修正をします

 

 

 

 

 

 

 

入れ物のタイトルも、中間スペースを除去する必要があります

 

 

作成されたテキストファイルの表示

 

 

 

 

 

音声入力の中間スペースを除外します

 

 

物品検索の作成

 

 

 

 

 

 

 

 

 

ここからは使いながら改善点を検討します

 

 

マージントップ 380 420  460  500  540 

 

<TextView

android:text="Large Text"

android:textAppearance="?android:attr/textAppearanceSmall"

android:layout_width="280.0dp"

android:layout_height="wrap_content"

android:layout_below="@id/button4"

android:id="@+id/textView1"

        />

 

ボタンの追加および位置変更

 

ボタン 6   7   8   9   未使用 位置とサイズの変更

未使用の為、小さく折りたたみ、ボタン 5 の上にまとめて配置

将来の活用に備える

 

 

 

 

 

 

 

 

ボタン名の再配置

 

 

 

 

 

 

 

 

 

 

 

 

収納登録の一覧表示をボタンに代入してみます

 

 

 

 

ボタン10-19の処理を追加します

 

 

 

 

 

 

 

 

 

3/3物品名入力の時は、10-19ボタンを初期化します

 

 

 

検索ボタン、日誌ボタン、取消ボタンのあと、10-19ボタンの名称をクリアします

 

 

 

 

 

何らかのタイミングで 検索 収納 が消える問題の解決

 

 

 

確認されているバグ

 

 

登録されたデータの保守に関する考察

 

 

収納モードでの「取消し」ボタンの確認

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Yes/Noボタン操作の共用

 

 

 

 

 

一覧表のボタン化ページ移動