private void button_copyDatabase_Click(object sender, EventArgs e) { DatabaseAccess da = null; LoginForm lf = new LoginForm( delegate(DatabaseAccess obj) { da = obj; }, "コピー先のデータを選択"); lf.ShowDialog(); if (da == null) { return; } DialogResult dres = MessageBox.Show("コピー先データベースの内容を全て削除しますか?\n" + "削除しない場合、既に存在するデータとID等が被るとコピーが失敗します。\n" + "(選択によらず設定は上書きされます)", "データベースのコピー", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3); if (dres == DialogResult.Cancel) { return; } var tooDao = da.getIDao <IOperatorDao>(); var torDao = da.getIDao <IReceiptDao>(); var toiDao = da.getIDao <IItemDao>(); if (dres == DialogResult.Yes) { toiDao.DeleteAll(); torDao.DeleteAll(); tooDao.DeleteAll(); } //Configはどちらにせよ削除 var tocDao = da.getIDao <IConfigDao>(); tocDao.DeleteAll(); foreach (ConfigEntity c in GlobalData.getIDao <IConfigDao>().GetAll()) { tocDao.Insert(c); } foreach (Operator o in GlobalData.getIDao <IOperatorDao>().GetAll()) { tooDao.Insert(o); } foreach (Receipt r in GlobalData.getIDao <IReceiptDao>().GetAll()) { torDao.Insert(r); } foreach (Item i in GlobalData.getIDao <IItemDao>().GetAll()) { toiDao.Insert(i); } MessageBox.Show("完了しました。", "データベースのコピー"); }
private void DoPrint(bool printAll) { this.DeleteOldPrinted(); List <Item> items = new List <Item>(); uint printCount = 0; kaede2nd.Dao.IItemDao idao = GlobalData.getIDao <kaede2nd.Dao.IItemDao>(); for (int cnt = 0; cnt < this.recentList.Count; cnt++) { var itl = idao.GetItemById(this.recentList[cnt].item_id); if (itl.Count == 0) { continue; } if (printAll == false) { if ((printCount + itl[0].GetTagPrintCount()) > this.countPerPage) { break; } } items.Add(itl[0]); this.recentList[cnt].printed = true; printCount += itl[0].GetTagPrintCount(); } ItemsPrintDocument.PrintItems(items); this.ReDraw(); }
//[Receipts] private void renewReceipts() { this.dataGridView1.Enabled = false; this.dataGridView1.Rows.Clear(); IReceiptDao receiptDao = GlobalData.getIDao <IReceiptDao>(); IItemDao itemDao = GlobalData.getIDao <IItemDao>(); this.receiptlist = receiptDao.GetAll(); foreach (Receipt r in this.receiptlist) { DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()]; this.setRowValue(row, r); //個数 - のこす //row.Cells["個数"].Value = itemDao.CountReceiptItem(r.receipt_id); } dataGridView1.Sort(dataGridView1.Columns[ColumnName.hyouBan], ListSortDirection.Ascending); dataGridView1.Enabled = true; if (dataGridView1.Rows.Count > 0) { dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows.Count - 1; } this.RefreshStatusBar(); }
protected void dgv_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { if (this.IsEditable() == false) { return; } DataGridView dgv = (DataGridView)sender; if (!dgv.Enabled) { return; } if (this.itemList == null) { throw new InvalidOperationException(); } //if (dgv.RowCount <= e.RowIndex) { return; } //新規行のキャンセル if (e.Row.Cells[ColumnName.shinaBan].Value == null) { } else { Item it = this.GetItemFromList((UInt32)e.Row.Cells[ColumnName.shinaBan].Value); var itemDao = GlobalData.getIDao <IItemDao>(); //this.itemList.Remove(it); itemDao.Delete(it); } }
public void RefreshStatusBar() { System.Threading.Thread t = new System.Threading.Thread( (delegate() { try { IItemDao itemDao = GlobalData.getIDao <IItemDao>(); string itemcount = itemDao.CountAll().ToString() + "個の商品"; string sold = "売上 ¥" + itemDao.SumSellPrice().ToString("#,##0") + "- " + itemDao.CountSoldItem().ToString() + "個"; ControlUtil.SafelyOperated(this.statusStrip1, (MethodInvoker) delegate() { this.status_itemcount.Text = itemcount; }); ControlUtil.SafelyOperated(this.statusStrip1, (MethodInvoker) delegate() { this.status_sold.Text = sold; }); } catch { } })); t.Start(); }
private void SellForm_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.Z) { if (this.privItem == null) { return; } uint?priv_canceledsellprice = this.privItem.item_sellprice; this.privItem.item_sellprice = privItemSellPrice; this.privItem.item_selltime = privItemSellTime; this.privItem.item_sell_operator = privItemSellOperatorId; IItemDao idao = GlobalData.getIDao <IItemDao>(); idao.Update(this.privItem); this.setItem(this.privItem); this.textBox_baika.Text = priv_canceledsellprice.ToString(); this.textBox_baika.Focus(); this.textBox_baika.SelectAll(); this.privItem = null; } }
private void RefreshRemain() { System.Threading.Thread t = new System.Threading.Thread(delegate() { IItemDao itDao = GlobalData.getIDao <IItemDao>(); UInt32 cnt; cnt = itDao.CountNeedKansaItem_NotFlagged(); ControlUtil.SafelyOperated(this.textBox_remain, (MethodInvoker) delegate() { this.textBox_remain.Text = cnt.ToString(); }); UInt32 allcnt; allcnt = itDao.CountNeedKansaItem(); ControlUtil.SafelyOperated(this.textBox_allkansa, (MethodInvoker) delegate() { this.textBox_allkansa.Text = allcnt.ToString(); }); UInt32 sum; sum = itDao.SumNeedKansaItem_SellPrice(); ControlUtil.SafelyOperated(this.textBox_sum, (MethodInvoker) delegate() { this.textBox_sum.Text = sum.ToString("#,##0"); }); }); t.IsBackground = true; t.Start(); }
public void ReDraw() { this.dataGridView1.Rows.Clear(); uint kensuu = 0; kaede2nd.Dao.IItemDao idao = GlobalData.getIDao <kaede2nd.Dao.IItemDao>(); for (int cnt = this.recentList.Count - 1; cnt >= 0; cnt--) { if (this.recentList[cnt].printed == true) { continue; } var itl = idao.GetItemById(this.recentList[cnt].item_id); if (itl.Count == 0) { this.recentList.RemoveAt(cnt); continue; } DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()]; this.setRowValue(row, itl[0]); kensuu += itl[0].GetTagPrintCount(); } this.text_kensuu.Text = kensuu.ToString(); if (kensuu >= this.countPerPage) { this.text_kensuu.ForeColor = Color.HotPink; this.BackColor = Color.Red; } else { this.text_kensuu.ForeColor = SystemColors.WindowText; this.BackColor = SystemColors.Control; } }
private void 選択した商品を印刷SToolStripMenuItem_Click(object sender, EventArgs e) { this.dataGridView1.ExtendSelection(); List <Item> items = new List <Item>(); kaede2nd.Dao.IItemDao idao = GlobalData.getIDao <kaede2nd.Dao.IItemDao>(); for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++) { var itl = idao.GetItemById(this.recentList[i].item_id); if (itl.Count == 0) { continue; } items.Add(itl[0]); } items.Sort(delegate(Item a, Item b) { return(a.item_id.CompareTo(b.item_id)); }); foreach (Item it in items) { RecentItemSet ris = this.GetItemSetFromId(it.item_id); if (ris != null) { ris.printed = true; } } ItemsPrintDocument.PrintItems(items); this.ReDraw(); }
private void textBox_baika_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this.curItem == null) { return; } string s = this.textBox_baika.Text; uint baika; if (s == "-") { baika = curItem.item_tagprice; } else { if (!uint.TryParse(s, out baika)) { this.textBox_baika_err(); return; } if (baika > 999999) { this.textBox_baika_err(); return; } } if (curItem.item_sellprice.HasValue && curItem.item_sellprice.Value == baika) { } else { privItem = curItem; privItemSellPrice = curItem.item_sellprice; privItemSellTime = curItem.item_selltime; privItemSellOperatorId = curItem.item_sell_operator; curItem.item_sellprice = baika; curItem.item_selltime = DateTime.Now; curItem.item_sell_operator = this.nowOperator.operator_id; Item i = curItem; System.Threading.Thread t = new System.Threading.Thread( delegate(object item) { IItemDao idao = GlobalData.getIDao <IItemDao>(); idao.Update((Item)item); } ); t.Start(i); } this.textBox_ban_err("次の品番を入力してね"); } }
private void cSVで出力CToolStripMenuItem_Click(object sender, EventArgs e) { Form_ItemList f = new Form_ItemList(delegate() { var itemDao = GlobalData.getIDao <IItemDao>(); return(itemDao.GetAll()); }, "全商品", "allItems"); f.outCSV(); }
public ReceiptForm(uint rid) : this() { var receiptDao = GlobalData.getIDao <IReceiptDao>(); List <Receipt> rs = receiptDao.GetById(rid); if (rs.Count == 0) { throw new Exception("指定したReceiptが見つかりませんでした"); } this.SetReceipt(rs[0]); }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridView dgv = (DataGridView)sender; if (!dgv.Enabled) { return; } if (e.ColumnIndex == 0) { return; } if (dgv.Rows[e.RowIndex].IsNewRow) { return; } if (this.itemList == null) { throw new InvalidOperationException(); } if (dgv.Columns[e.ColumnIndex].Name == ColumnName.shouhinMei) { this.ConvBarcode(dgv[e.ColumnIndex, e.RowIndex]); } var itemDao = GlobalData.getIDao <IItemDao>(); Item it; if (dgv[ColumnName.shinaBan, e.RowIndex].Value == null) { return; } else { it = this.GetItemFromList((UInt32)dgv[ColumnName.shinaBan, e.RowIndex].Value); this.changeDBdata(dgv.Columns[e.ColumnIndex].Name, it, dgv[e.ColumnIndex, e.RowIndex].Value); try { itemDao.Update(it); } catch (Exception ex) { MessageBox.Show("更新できませんでした: " + ex.Message); return; } } }
private void button_teisei_Click(object sender, EventArgs e) { if (this.curItem == null) { return; } string def; if (this.curItem.item_sellprice.HasValue) { def = this.curItem.item_sellprice.ToString(); } else { def = "未売却"; } while (true) { string res; DialogResult dres = InputBox.ShowIntDialog("修正後の売価を入力してください\n商品名: " + this.curItem.item_name, "売価修正", def, out res); if (dres == DialogResult.Cancel) { return; } else { uint baika; if (!uint.TryParse(res, out baika)) { def = "不正な文字列です"; continue; } IItemDao itDao = GlobalData.getIDao <IItemDao>(); this.curItem.item_sellprice = baika; this.curItem.item_selltime = DateTime.Now; this.curItem.item_sell_operator = this.nowOperator.operator_id; itDao.Update(this.curItem); this.DoKansaItem(itDao.GetItemById(curItem.item_id).First()); this.label_error.Text = "金額訂正が完了しました"; return; } } }
private void button3_Click(object sender, EventArgs e) { if (this.allListForm == null || this.allListForm.IsDisposed) { this.allListForm = new Form_ItemList( (Form_ItemList.ItemReturnDelegate) delegate() { var itemDao = GlobalData.getIDao <IItemDao>(); return(itemDao.GetNeedKansaItem()); }, "監査対象", "監査対象"); } this.allListForm.Show(); this.allListForm.Activate(); }
private void button2_Click(object sender, EventArgs e) { if (this.listForm == null || this.listForm.IsDisposed) { this.listForm = new Form_ItemList( (Form_ItemList.ItemReturnDelegate) delegate() { var itemDao = GlobalData.getIDao <IItemDao>(); return(itemDao.GetNeedKansaItem_NotFlagged()); }, "未" + this.Text, "未監査"); } this.listForm.Show(); this.listForm.Activate(); }
//[AllItems] private void button5_Click(object sender, EventArgs e) { try { Form_ItemList f = new Form_ItemList(delegate() { var itemDao = GlobalData.getIDao <IItemDao>(); return(itemDao.GetAll()); }, "全商品リスト", "allItems"); f.Show(); } catch (Exception excep) { MessageBox.Show("全商品ウィンドウが生成できませんでした: " + excep.Message); } }
private void button_mibai_Click(object sender, EventArgs e) { if (curItem == null) { return; } curItem.item_sellprice = null; curItem.item_selltime = null; IItemDao idao = GlobalData.getIDao <IItemDao>(); idao.Update(curItem); this.DoKansaItem(idao.GetItemById(curItem.item_id).First()); this.label_error.Text = "商品を未売却にしました"; }
private const float fontheight = 4f; //mm public ReceiptPrintDocument(Receipt receipt, PageSettings pageSettings, PrinterSettings printerSettings) : base(pageSettings, printerSettings) { if (receipt == null) { throw new NullReferenceException("receipt"); } this.receipt = receipt; var itemDao = GlobalData.getIDao <kaede2nd.Dao.IItemDao>(); items = itemDao.GetReceiptItem(this.receipt.receipt_id); this.BeginPrint += new PrintEventHandler(ReceiptPrintDocument_BeginPrint); this.PrintPage += new PrintPageEventHandler(ReceiptPrintDocument_PrintPage); }
public SelectOperator() { InitializeComponent(); IOperatorDao opDao = GlobalData.getIDao <IOperatorDao>(); List <Operator> lop = opDao.GetAll(); foreach (Operator op in lop) { this.listBox1.Items.Add(op); } if (lop.Count == 0) { MessageBox.Show("先に[機能]→[オペレーターIDを管理]で設定を済ませてください"); } }
private void RefreshShowing() { if (this.isNewReceipt == true) { return; } var receiptDao = GlobalData.getIDao <IReceiptDao>(); List <Receipt> rs = receiptDao.GetById(this.receipt.receipt_id); if (rs.Count == 0) { throw new Exception("指定したReceiptが見つかりませんでした"); } this.SetReceipt(rs[0]); }
private void PrintSelections() { var rows = this.dataGridView1.SelectedRows; List <Item> items = new List <Item>(); var itemDao = GlobalData.getIDao <IItemDao>(); if (rows.Count == 0) { return; } for (int i = 0; i < rows.Count; i++) { items.AddRange(itemDao.GetReceiptItem((UInt32)rows[i].Cells[ColumnName.hyouBan].Value)); } ItemsPrintDocument.PrintItems(items); }
private void RefreshShowing() { this.dataGridView1.Enabled = false; this.dataGridView1.Rows.Clear(); IOperatorDao opDao = GlobalData.getIDao <IOperatorDao>(); this.oplist = opDao.GetAll(); foreach (Operator op in this.oplist) { DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()]; this.setRowValue(row, op); } dataGridView1.Sort(dataGridView1.Columns[ColumnName.operatorId], ListSortDirection.Ascending); this.dataGridView1.Enabled = true; }
private void SellerRadio_Changed(object sender, EventArgs e) { RadioButton rd = (RadioButton)sender; this.SuspendLayout(); this.SetZaigakuEnabled(false); this.label_external.Enabled = false; this.text_external.Enabled = false; if (rd == this.radio_zaigaku) { this.SetZaigakuEnabled(true); this.label_external.Enabled = true; this.text_external.Enabled = true; //this.text_Enter_SelectAll(this.text_zai_nen, null); this.text_zai_nen.SelectAll(); this.text_zai_nen.Focus(); } else if (rd == this.radio_external) { this.label_external.Enabled = true; this.text_external.Enabled = true; this.text_external.SelectAll(); this.text_external.Focus(); var receiptDao = GlobalData.getIDao <IReceiptDao>(); List <Receipt> reces = receiptDao.GetBySellerString(Receipt.seller_EXT); foreach (Receipt r in reces) { if (this.text_external.Items.Contains(r.receipt_seller_exname)) { //重複はスキップ continue; } this.text_external.Items.Add(r.receipt_seller_exname); } } this.ResumeLayout(); }
private void button_mibai_Click(object sender, EventArgs e) { if (curItem == null) { return; } privItem = curItem; privItemSellPrice = curItem.item_sellprice; privItemSellTime = curItem.item_selltime; privItemSellOperatorId = curItem.item_sell_operator; curItem.item_sellprice = null; curItem.item_selltime = null; IItemDao idao = GlobalData.getIDao <IItemDao>(); idao.Update(curItem); this.textBox_ban_err("次の品番を入力してね"); }
public static void setValue(string name, string value) { var cdao = GlobalData.getIDao <IConfigDao>(); var l1 = from d in cdao.GetAll() where d.config_name == name select d; if (l1.Count() > 0) { var ccl = l1.First(); ccl.config_value = value; cdao.Update(ccl); } else { var ccn = new ConfigEntity(name, value); cdao.Insert(ccn); } }
public void RefreshData() { IItemDao iDao = GlobalData.getIDao <IItemDao>(); List <Item> items = iDao.GetAll(); this.itemGroup = (from i in items group i by i.item__Receipt.getSellerString()) .OrderByDescending(g => this.countHenpinItems(g)); this.dataGridView1.Rows.Clear(); foreach (var g in this.itemGroup) { DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()]; this.setRowValue(row, g); } this.dataGridView1.VirtualMode = true; this.dataGridView1.VirtualMode = false; this.dataGridView1.Enabled = true; this.dataGridView1.Focus(); }
private void textBox_ban_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string s = this.textBox_ban.Text; if (s == null) { return; } uint shinaBan; if (Globals.TryParseBarcode(s, out shinaBan)) { } else { if (!uint.TryParse(this.textBox_ban.Text, out shinaBan)) { this.textBox_ban_err("不明な文字列です"); return; } } if (!(0 <= shinaBan && shinaBan <= 999999)) { this.textBox_ban_err("不正な品番です"); } IItemDao itemDao = GlobalData.getIDao <IItemDao>(); List <Item> its = itemDao.GetItemById(shinaBan); if (its.Count == 0) { this.textBox_ban_err("品番に該当する商品がありません"); return; } this.DoKansaItem(its[0]); } }
private void button1_Click(object sender, EventArgs e) { uint opid; if (uint.TryParse(this.textBox1.Text, out opid)) { IOperatorDao opDao = GlobalData.getIDao <IOperatorDao>(); List <Operator> lop = opDao.GetById(opid); if (lop.Count == 1) { this.retop = lop[0]; this.DialogResult = DialogResult.OK; this.Close(); return; } } this.textBox1.BackColor = Color.LightPink; this.textBox1.Focus(); this.textBox1.SelectAll(); }
protected void dgv_DeleteSelectedRow() { if (this.IsEditable() == false) { return; } if (this.formDGV.SelectedRows.Count == 0) { return; } if (MessageBox.Show("選択した " + this.formDGV.SelectedRows.Count.ToString() + "行を削除しますか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { for (int i = this.formDGV.SelectedRows.Count - 1; i >= 0; i--) { DataGridViewRow row = this.formDGV.SelectedRows[i]; //if (dgv.RowCount <= e.RowIndex) { return; } //新規行のキャンセル if (row.Cells[ColumnName.shinaBan].Value == null) { } else { Item it = this.GetItemFromList((UInt32)row.Cells[ColumnName.shinaBan].Value); var itemDao = GlobalData.getIDao <IItemDao>(); this.itemList.Remove(it); itemDao.Delete(it); } if (!row.IsNewRow) { this.formDGV.Rows.Remove(row); } } } }