private void PrintSelections() { var rows = this.dataGridView1.SelectedRows; List <int> items = new List <int>(); if (rows.Count == 0) { return; } DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); for (int i = 0; i < rows.Count; i++) { var list = from n in context.item where n.item_receipt_id == int.Parse(rows[i].Cells[0].Value.ToString().Substring(1, 4)) select n; foreach (var item in list) { items.Add(item.item_id); } } ItemsPrintDocument.PrintItems(items); context.SubmitChanges(); }
private void timer_refresh_Tick(object sender, EventArgs e) { List <item> items = new List <item>(); var list = LoadItem(); itemsGridView1.Load(list); itemsGridView1.AutoResizeColumns(); toolStripStatusLabel_count.Text = string.Format("印刷待機中{0}件", itemsGridView1.Rows.Count); if (list.Count() >= numericUpDown_count.Value) { int count = 0; int volume_count = 0; bool end = false; pPrint.Clear(); foreach (item data in list) { //タグ枚数カウント if (data.item_volumes.HasValue && data.item_volumes >= 2) { count += data.item_volumes.Value; volume_count += data.item_volumes.Value - 1; end = true; } else { count++; end = false; } items.Add(data); } int n = (count - (count % (int)numericUpDown_count.Value)) / (int)numericUpDown_count.Value; foreach (var item in items.Take(n * (int)numericUpDown_count.Value - volume_count)) { pPrint.Add(item.item_id); } //最後が分冊ありだった場合 if (end) { pPrint.Remove(pPrint.Last()); } //印刷 try { ItemsPrintDocument.PrintItems(pPrint); } catch { } } }
private void button_forceprint_Click(object sender, EventArgs e) { pPrint.Clear(); var list = LoadItem(); itemsGridView1.Load(list); itemsGridView1.AutoResizeColumns(); foreach (item data in list) { pPrint.Add(data.item_id); } //印刷 ItemsPrintDocument.PrintItems(pPrint); }
private void タグを印刷ToolStripMenuItem_Click(object sender, EventArgs e) { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); List <int> items = new List <int>(); for (int i = 0; i < this.itemsGridView1.SelectedRows.Count; i++) { DataGridViewRow row = this.itemsGridView1.SelectedRows[i]; if (row.Cells[0].Value == null) { } else { var data = (from n in context.item where n.item_id == (Int32)row.Cells[0].Value select n).First(); items.Add(data.item_id); } } items.Sort(); ItemsPrintDocument.PrintItems(items); }