void PrintBlock(int left, int y, int start, int end, int height) { ListView.ListViewItemCollection items = this.listViewBrowse.Items; string[] header = new string[] { "編號", "台號", "人數", "金額" }; int[] colWidth = new int[] { 50, 50, 50, 60 }; int x = left; for (int j = 0; j < header.Length; j++) { PrintColumn(header[j], x, y, colWidth[j], true); x += colWidth[j]; } for (int i = start; i < end; i++) { BasicDataSet.OrderRow row = items[i].Tag as BasicDataSet.OrderRow; y += height; x = left; PrintColumn(row.OrderID.ToString(), x, y, colWidth[0], true); x += colWidth[0]; PrintColumn(row.TableID.ToString(), x, y, colWidth[1], true); x += colWidth[1]; PrintColumn(row.PeopleNo.ToString(), x, y, colWidth[2], true); x += colWidth[2]; PrintColumn(row.Income.ToString(), x, y, colWidth[3], true); x += colWidth[3]; if (!row.IsCreditIDNull() && row.CreditID != 0) { PrintColumn("*", x - 4, y, 10, false); } } }
private void listViewBrowse_ItemChecked(object sender, ItemCheckedEventArgs e) { if (ListViewItemCheck == false) { return; } BasicDataSet.OrderRow Row = (BasicDataSet.OrderRow)e.Item.Tag; if (CanModify) { Row.Checked = e.Item.Checked; try { m_OrderAdapter.Update(Row); } catch { MessageBox.Show("Order資料庫寫入有誤"); } } else { ListViewItemCheck = false; // 防止重複進入 e.Item.Checked = Row.Checked; ListViewItemCheck = true; } }
void LoadData(int year, int month, int from, int to, bool Use12) { string sql; try { if (Use12) { TimeSpan oneDay = new TimeSpan(24, 0, 0); DateTime prev = new DateTime(year, month, from).Subtract(oneDay); DateTime next = new DateTime(year, month, to); sql = "Where (INT(ID/10000)>=" + DateStr(prev) + " And INT(ID/10000)<=" + DateStr(next) + ")"; BasicDataSet.OrderDataTable temp = new BasicDataSet.OrderDataTable(); m_OrderAdapter.FillBySelectStr(temp, "Select * From [Order] " + sql + " Order by ID"); int nextID = IDTagHead(next.Year, next.Month, next.Day); int prevID = IDTagHead(prev.Year, prev.Month, prev.Day); basicDataSet.Order.Clear(); foreach (BasicDataSet.OrderRow r in temp) { int idHead = r.ID / 10000; if (idHead == nextID) { if (r.PrintTime.Hour < 7) { continue; } } else if (idHead == prevID) { if (r.PrintTime.Hour >= 7) { continue; } } BasicDataSet.OrderRow oRow = basicDataSet.Order.NewOrderRow(); oRow.ItemArray = r.ItemArray; basicDataSet.Order.AddOrderRow(oRow); } } else { sql = "Where (INT(ID/10000)>=" + DateStr(year, month, from) + " And INT(ID/10000)<=" + DateStr(year, month, to) + ")"; m_OrderAdapter.FillBySelectStr(basicDataSet.Order, "Select * From [Order] " + sql + " Order by ID"); } m_OrderItemAdapter.FillBySelectStr(basicDataSet.OrderItem, "Select * From [OrderItem] " + sql); } catch (Exception ex) { string str = ex.Message; MessageBox.Show("訂菜單資料庫讀取錯誤!"); } }
private void listViewBrowse_DoubleClick(object sender, EventArgs e) { ListView view = (ListView)sender; if (view.SelectedItems.Count < 1) { return; } BasicDataSet.OrderRow Row1 = (BasicDataSet.OrderRow)view.SelectedItems[0].Tag; FormOrder Form1 = new FormOrder(basicDataSet1, Row1, this, "None", true); Form1.Show(); this.Visible = false; Form1.Focus(); }
public FormOrder(BasicDataSet DS1, BasicDataSet.OrderRow Row, FormBrowse Browse, string PortName, bool CheckOnly) { DataSet1 = DS1; CurrentOrder = Row; BrowseForm = Browse; ComPortName = PortName; FormOnlyForCheck = CheckOnly; // if (Row.RowState != DataRowState.Detached) OrderDetail = Row.GetOrderItemRows(); // else // OrderDetail = null; InitializeComponent(); InitializeMenu(); // 必需放後面,因為有用到前面設定 if (OrderDetail == null) { return; // 即使沒資料會是 OrderItemRow[0] 不會是null } comboBoxGuoDi.SelectedIndex = MyConstant.MaxNo; }
private void DeletetoolStripButton_Click(object sender, EventArgs e) { if (!this.Validate()) { MessageBox.Show("有資料錯誤, 請改好再作刪除操作!"); return; } productBindingSource.EndEdit(); string str = this.productIDTextBox.Text.Trim(); int productID = 0; string name; try { productID = Convert.ToInt32(str); name = nameTextBox.Text.Trim(); } catch { MessageBox.Show("要刪除的產品代碼必需是數字!"); return; } string strProductID = "產品 <" + productID.ToString() + ">"; if (MessageBox.Show("能刪除的產品必需是本年度從來沒有被客人點過的\r\n按'確定', 開始載入並檢查全年度點菜單!", "刪除" + strProductID + name, MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } if (!m_OrderItemLoaded) { try { orderTableAdapter.Fill(basicDataSet.Order); orderItemTableAdapter.Fill(basicDataSet.OrderItem); } catch (Exception ex) { MessageBox.Show("載入客人點菜細項時,資料庫發生錯誤:" + ex.Message); return; } m_OrderItemLoaded = true; } foreach (BasicDataSet.OrderItemRow row in basicDataSet.OrderItem) { if (row.ProductID == productID) { BasicDataSet.OrderRow order = row.OrderRow; MessageBox.Show("點菜單" + order.ID.ToString() + " 己經點了" + strProductID + " 無法刪除"); return; } } if (MessageBox.Show(strProductID + " 本年度沒有人點過,可以被刪除\r\n按'確定' 刪除", strProductID, MessageBoxButtons.OKCancel) == DialogResult.OK) { try { productBindingSource.RemoveCurrent(); productTableAdapter.Update(basicDataSet.Product); } catch (Exception ex) { MessageBox.Show("刪除" + strProductID + "及存檔過程錯誤:" + ex.Message); return; } MessageBox.Show("己刪除" + strProductID + name + " 並存檔成功!"); return; } MessageBox.Show("沒有刪除 " + strProductID + name); }
void LoadData(int year, int month, int day) { string sql = "80101"; int count = basicDataSet1.Header.Rows.Count; if (count != 0) { BasicDataSet.HeaderRow row = (BasicDataSet.HeaderRow)basicDataSet1.Header.Rows[count - 1]; // 沒指定用最後一個 if (month != 0 && day > 0) // 有指定找到那天 { foreach (BasicDataSet.HeaderRow r in basicDataSet1.Header.Rows) { if (r.DataDate.Month != month) { continue; } if (r.DataDate.Year != year) { continue; } if (r.DataDate.Day == day) { row = r; break; } } } else { SetupSelectCombo(row.DataDate.Month); } sql = CreateSql(row.DataDate.Year, row.DataDate.Month, row.DataDate.Day); // "Where INT(ID/10000)=" + (row.DataDate.Year % 100).ToString() + row.DataDate.Month.ToString("d2") + row.DataDate.Day.ToString("d2"); SetTitle(row.DataDate, row.Closed); } else { sql = CreateSql(2000, 1, 1); SetTitle(new DateTime(2000, 1, 1), false); } MaxID = 0; try { // orderTableAdapter1.Fill(basicDataSet1.Order); // orderItemTableAdapter1.Fill(basicDataSet1.OrderItem); if (checkBoxUse12.Checked) { BasicDataSet.OrderDataTable temp = new BasicDataSet.OrderDataTable(); m_OrderAdapter.FillBySelectStr(temp, "Select * From [Order] " + sql + " Order by ID"); int todayID = WorkingDay.IDTagHead(year, month, day); DateTime d = new DateTime(year, month, day); d = d.Subtract(new TimeSpan(24, 0, 0)); int prevID = WorkingDay.IDTagHead(d.Year, d.Month, d.Day); basicDataSet1.Order.Clear(); foreach (BasicDataSet.OrderRow r in temp) { int idHead = r.ID / 10000; if (idHead == todayID) { if (r.PrintTime.Hour < 7) { continue; } } else if (idHead == prevID) { if (r.PrintTime.Hour >= 7) { continue; } } BasicDataSet.OrderRow oRow = basicDataSet1.Order.NewOrderRow(); oRow.ItemArray = r.ItemArray; basicDataSet1.Order.AddOrderRow(oRow); } } else { m_OrderAdapter.FillBySelectStr(basicDataSet1.Order, "Select * From [Order] " + sql + " Order by ID"); } m_OrderItemAdapter.FillBySelectStr(basicDataSet1.OrderItem, "Select * From [OrderItem] " + sql); foreach (BasicDataSet.OrderRow R in basicDataSet1.Order.Rows) { int id = R.ID % 10000; if (id > MaxID) { MaxID = id; } } } catch (Exception ex) { string str = ex.Message; MessageBox.Show("訂菜單資料庫讀取錯誤!"); } Table2ListView(); }
public bool LoadData(BasicDataSet basicDataSet1, int year, int month, int day, bool Use12) { int count = basicDataSet1.Header.Rows.Count; if (count == 0) { return(false); } if (month < 1 || month > 12) { return(false); } if (day < 1 || day > 31) { return(false); } if (year < 2008 || year > 2020) { return(false); } BasicDataSet.HeaderRow row; foreach (BasicDataSet.HeaderRow r in basicDataSet1.Header.Rows) { if (r.DataDate.Month != month) { continue; } if (r.DataDate.Year != year) { continue; } if (r.DataDate.Day == day) { row = r; goto Yes; } } return(false); Yes: string sql = CreateSql(row.DataDate.Year, row.DataDate.Month, row.DataDate.Day, Use12); try { if (Use12) { BasicDataSet.OrderDataTable temp = new BasicDataSet.OrderDataTable(); m_OrderAdapter.FillBySelectStr(temp, "Select * From [Order] " + sql + " Order by ID"); int todayID = WorkingDay.IDTagHead(year, month, day); DateTime d = new DateTime(year, month, day); d = d.Subtract(new TimeSpan(24, 0, 0)); int prevID = WorkingDay.IDTagHead(d.Year, d.Month, d.Day); basicDataSet1.Order.Clear(); foreach (BasicDataSet.OrderRow r in temp) { int idHead = r.ID / 10000; if (idHead == todayID) { if (r.PrintTime.Hour < 7) { continue; } } else if (idHead == prevID) { if (r.PrintTime.Hour >= 7) { continue; } } BasicDataSet.OrderRow oRow = basicDataSet1.Order.NewOrderRow(); oRow.ItemArray = r.ItemArray; basicDataSet1.Order.AddOrderRow(oRow); } } else { m_OrderAdapter.FillBySelectStr(basicDataSet1.Order, "Select * From [Order] " + sql + " Order by ID"); } // m_OrderItemAdapter.FillBySelectStr(basicDataSet1.OrderItem, "Select * From [OrderItem] " + sql); m_WorkingDay.Set(row.DataDate); return(true); } catch (Exception ex) { LastErrorString = ex.Message; } return(false); }