private void btn_return_Click(object sender, EventArgs e) { if (grid_detail.SelectedRows.Count == 1 || grid_detail.SelectedRows.Count == 0) { if (grid_detail.SelectedRows[0].Cells[0].Value == null) { MessageBox.Show("환불할 도서를 선택하세요.", "주의!"); return; } } if (grid_detail.SelectedRows.Count > 0) { for (int i = 0; i < grid_detail.SelectedRows.Count; ++i) { if (grid_detail.SelectedRows[i].Cells[0].Value == null) { continue; } Sell item = DBC.GetInstance().SelectRecord <Sell>("sell", "영수증번호 = " + grid_record.SelectedRows[0].Cells[0].Value + " and ISBN = " + grid_detail.SelectedRows[i].Cells[0].Value)[0]; item.returns = "True"; DBC.GetInstance().UpdateRecord <Sell>(item); } } this.Close(); }
private void grid_record_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { grid_detail.Rows.Clear(); List <Sell> sell_list; try { string query = "Select book.ISBN, book.도서명, sell.수량, sell.가격 from sell, book where sell.영수증번호 = " + grid_record.SelectedRows[0].Cells[0].Value + " and sell.ISBN = book.ISBN"; OleDbCommand cmd = new OleDbCommand(query, DBC.GetInstance().conn); cmd.CommandType = System.Data.CommandType.Text; OleDbDataReader read = cmd.ExecuteReader(); sell_list = new List <Sell>(); while (read.Read()) { grid_detail.Rows.Add(new object[] { read["ISBN"].ToString(), read["도서명"].ToString(), read["수량"].ToString(), string.Format("{0:#,###}", Int32.Parse(read["가격"].ToString())) + "\\" }); } read.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnNew_Click(object sender, EventArgs e) { Customer cs = new Customer(); cs.name = txt_Name.Text; cs.phone = txt_Phone.Text; DBC.GetInstance().InsertRecord <Customer>(cs); FillList("", ""); }
private void FIll_List(string combo, string search) { grid_record.Rows.Clear(); List <Sell> sell_list; try { string query = ""; if (combo == "" || search == "") { query = "Select 영수증번호, Sum(가격) as price, 고객번호, 날짜, 포인트사용 from sell, customer Group by 영수증번호, 고객번호, 날짜, 포인트사용"; } else if (combo == "이름") { query = "Select 영수증번호, Sum(가격) as price, 고객번호, 날짜, 포인트사용 from sell, customer where customer.ID = sell.고객번호 and " + combo + " Like '%" + search + "%' Group by 영수증번호, 고객번호, 날짜, 포인트사용"; } else { query = "Select 영수증번호, Sum(가격) as price, 고객번호, 날짜, 포인트사용 from sell, customer where " + combo + " Like '%" + search + "%' Group by 영수증번호, 고객번호, 날짜, 포인트사용"; } OleDbCommand cmd = new OleDbCommand(query, DBC.GetInstance().conn); cmd.CommandType = System.Data.CommandType.Text; OleDbDataReader read = cmd.ExecuteReader(); sell_list = new List <Sell>(); while (read.Read()) { if (read["영수증번호"].ToString() == "0") { continue; } grid_record.Rows.Add(new object[] { read["영수증번호"].ToString(), string.Format("{0:#,###}", Int32.Parse(read["price"].ToString())) + "\\", read["고객번호"].ToString() == "0" ? "" : read["고객번호"].ToString(), read["고객번호"].ToString() == "0" ? "" : DBC.GetInstance().SelectRecord <Customer>("customer", "ID = " + read["고객번호"].ToString())[0].name, read["날짜"].ToString(), read["포인트사용"].ToString() }); } read.Close(); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void btnChange_Click(object sender, EventArgs e) { if (lbl_ID.Text == "") { MessageBox.Show("수정할 정보를 선택해주세요.", "주의"); return; } Customer cs = DBC.GetInstance().SelectRecord <Customer>("customer", "ID = " + lbl_ID.Text)[0]; cs.point = Int32.Parse(txt_Point.Text); cs.phone = txt_Phone.Text; cs.name = txt_Name.Text; DBC.GetInstance().UpdateRecord <Customer>(cs); }
private void FillList(string category, string search) { list_customer.Rows.Clear(); List <Customer> cusList; if (category == "" || search == "") { cusList = DBC.GetInstance().SelectRecord <Customer>("customer", ""); } else { cusList = DBC.GetInstance().SelectRecord <Customer>("customer", category + " Like " + "'%" + search + "%'"); } foreach (Customer cs in cusList) { list_customer.Rows.Add(new object[] { cs.number, cs.name, cs.phone, cs.sales, cs.point }); } }
private void FillList(string category, string search) { list_book.Controls.Clear(); List <Book> bookList; if (category == "" || search == "") { bookList = DBC.GetInstance().SelectRecord <Book>("book", ""); } else { bookList = DBC.GetInstance().SelectRecord <Book>("book", category + " Like " + "'%" + search + "%'"); } foreach (Book b in bookList) { book_item item = new book_item(b); item.Click += new System.EventHandler(this.item_click); item.DoubleClick += new System.EventHandler(this.item_double_click); list_book.Controls.Add(item); } }
private void btn_delete_Click(object sender, EventArgs e) { DBC.GetInstance().DeleteRecord("customer", lbl_ID.Text); }