public override void PageRefresh() { //写真選択フォームをすべて閉じる selectPanel.Controls.Clear(); //写真格納フォルダ取得 photoDirList = DB.t_shooting_data.getPhotoDir(MainForm.session_t_reception.reception_code); //二次選択フォルダ取得 DB.t_selection selection = DB.t_selection.getFirst(MainForm.session_t_reception.reception_code); if (selection == null) { int index = 1; DB.m_customer customer = DB.m_customer.getSingle(MainForm.session_t_reception.customer_code); Save_dir = DateTime.Now.Date.ToString("yyyyMMdd") + "-" + index.ToString() + "-" + customer.surname; StringBuilder sb = new StringBuilder(); while (sb.Length == 0) { using (var dbc = new DB.DBConnect()) { dbc.npg.Open(); sb.Append("select count(s.folder_name) as count "); sb.Append("from t_selection as s "); sb.Append("where s.folder_name = '@folder_name'".Replace("@folder_name", Save_dir)); NpgsqlCommand command = new NpgsqlCommand(sb.ToString(), dbc.npg); var dataReader = command.ExecuteReader(); while (dataReader.Read()) { if ((long)dataReader["count"] != 0) { index++; Save_dir = DateTime.Now.Date.ToString("yyyyMMdd") + index.ToString() + customer.name; sb.Clear(); } } } } } else { Save_dir = selection.folder_name; } //サムネイル一覧初期化 thumbnailListRefresh(); //DBからタグ一覧へ格納 db2tag(); //サムネイル一覧タグ付け thumbnailListTagRefresh(); }
private void collect() { foreach (tagControl tc in this.tagsPanel.Controls) { //写真コピー ///フォルダ初期化 var folderPath = System.IO.Path.Combine(Secondary_Select_dir, Save_dir.Trim(), tc.tagId.ToString()); folderPath = System.IO.Path.GetFullPath(folderPath); if (System.IO.Directory.Exists(folderPath)) { System.IO.DirectoryInfo target = new System.IO.DirectoryInfo(folderPath); foreach (System.IO.FileInfo ftarget in target.GetFiles()) { ftarget.Delete(); } } else { System.IO.Directory.CreateDirectory(folderPath); } if (tc.d_tag.Checked & tc.thumbnailList.Items.Count != 0) { ///コピー foreach (var key in tc.imageList1.Images.Keys) { var moto = System.IO.Path.Combine(Photographer_Select_dir, key); var saki = System.IO.Path.Combine(folderPath, key.Replace("/", "_")); System.IO.File.Copy(moto, saki, true); } } //DB登録 DB.t_selection selection = new DB.t_selection(); selection.reception_code = MainForm.session_t_reception.reception_code; selection.color = tc.tagId; selection.product_name = tc.d_tagName.SelectedItem.ToString(); selection.folder_name = Save_dir; selection.images = tc.thumbnailList.Items.Count; selection.order_code = null; selection.store_code = MainForm.session_m_staff.store_code; selection.Command(); } }