// 총금액 조회 private void SellGridMoney() { int j = 0; SellTotMoney = new int[SellDate.Length]; for (int i = 0; i < SellDate.Length; i++) { using (var con = DbMan.Dbcon(sqlcon)) { using (var cmd = new SqlCommand("SellBarcodeSelect3", con)) { cmd.Parameters.AddWithValue("@sellbar", sellBar[i].ToString()); cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { SellTotMoney[j] += int.Parse(ed[0].ToString()); } j++; } } } }
private void ProdImage(string barcodeNum) { pictureBox1.Image = null; var con = DbMan.Dbcon(picSqlcon); var cmd = new SqlCommand("ReturnImage", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", barcodeNum); con.Open(); picAdapter = DbMan.DbAdap(picAdapter); picAdapter.SelectCommand = cmd; picDs = DbMan.DbDs(picDs); picAdapter.Fill(picDs); DataTable pro = picDs.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow er in rows) { object pic = er[0]; if (pic.GetType().ToString() == "System.DBNull") { return; } else { pictureBox1.Image = new Bitmap(new MemoryStream((byte[])pic)); } } con.Close(); rows.Clear(); picDs = null; picAdapter = null; pro.Clear(); }
private void CardPayDB() { int j = 0; for (int i = 0; i < itemGrid.Rows.Count; i++) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SellCardInsert", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); cmd.Parameters.AddWithValue("@selldate", DateTime.Now); cmd.Parameters.AddWithValue("@barcode", itemGrid.Rows[i].Cells[2].Value.ToString()); cmd.Parameters.AddWithValue("@count", itemGrid.Rows[i].Cells[4].Value.ToString()); cmd.Parameters.AddWithValue("@cardCom", cp.txtCardCom.Text); cmd.Parameters.AddWithValue("@cardDate", DateTime.Parse(cp.txtYear.Text + "-" + cp.txtMonth.Text + "-01")); //DateTime.Parse(cp.txtYear.Text + "-" + cp.txtMonth.Text + "-01") cmd.Parameters.AddWithValue("@cardNum", cp.txtCardNum.Text); cmd.Parameters.AddWithValue("@empnum", 1); cmd.Parameters.AddWithValue("@age", this.lblAge.Text); cmd.Parameters.AddWithValue("@gender", this.lblGender.Text); cmd.Parameters.AddWithValue("@sellBarcode", sellbarcode.ToString()); cmd.Parameters.AddWithValue("@money", int.Parse(cp.txtMoney.Text) - int.Parse(cp.txtDiscount.Text)); j = cmd.ExecuteNonQuery(); } AutoClosingMessageBox.Show("정상처리되었습니다.", "GD편의점", 2000); }
// 주문 클릭 private void btnOrder_Click(object sender, EventArgs e) { for (int i = 0; i < itemListGrid.RowCount; i++) { if (itemListGrid.Rows[i].Cells[4].Value == null) { MessageBox.Show("수량을 선택해 주세요!"); return; } var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("OrdersInsert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@date", DateTime.Parse(lblDate.Text)); cmd.Parameters.AddWithValue("@barcode", itemListGrid.Rows[i].Cells[0].Value.ToString()); cmd.Parameters.AddWithValue("@count", int.Parse(itemListGrid.Rows[i].Cells[4].Value.ToString())); cmd.Parameters.AddWithValue("@price", int.Parse(itemListGrid.Rows[i].Cells[3].Value.ToString()) /** int.Parse(itemListGrid.Rows[i].Cells[4].Value.ToString())*/); cmd.Parameters.AddWithValue("@empNum", 1); //cmd.Parameters.AddWithValue("@dispodate", DateTime.Parse(DateTime.Now.Year + "-" + DateTime.no)); con.Open(); var exr = cmd.ExecuteNonQuery(); } MessageBox.Show("주문이 완료되었습니다!"); this.Close(); }
// 바코드 번호 조회 그리드뷰 띄우기 private void SellGrid() { using (var con = DbMan.Dbcon(sqlcon)) { using (var cmd = new SqlCommand("SellBarcodeSelect", con)) { cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { ReceiptGridView.Rows.Add(ed[0].ToString()); } for (int i = 0; i < ReceiptGridView.Rows.Count; i++) { sellBar[i] = ReceiptGridView.Rows[i].Cells[0].Value.ToString(); } ReceiptGridView.Rows.Clear(); } } }
// 날짜 띄우기 및 결제수단판별 private void ReceiptView() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SellBarcodeSelect2", con); cmd.Parameters.AddWithValue("@sellbar", ReceiptGridView.CurrentRow.Cells[0].Value.ToString()); cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { txtReceipt.Text += txtReceipt.GetHashCode().ToString() + " " + ed[0].ToString() + "\r\n"; if (ed[1].ToString() != "money") { pay = true; } else { pay = false; } } }
private void DiscountEvent() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("EventDiscount", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@eventNum", eventNum); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow er in rows) { if (er[0].ToString() == "") { return; } else { priceDis = double.Parse(price.ToString()) * (double.Parse((100 - int.Parse(er[0].ToString())).ToString()) / 100); MessageBox.Show(priceDis.ToString()); EventDr.Cells[3].Value = priceDis * double.Parse(EventDr.Cells[4].Value.ToString()); } } }
private void ProdMinus() { for (int i = 0; i < itemGrid.Rows.Count; i++) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SellProduct", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); cmd.Parameters.AddWithValue("@prodcount", int.Parse(itemGrid.Rows[i].Cells[4].Value.ToString())); cmd.Parameters.AddWithValue("@barcode", itemGrid.Rows[i].Cells[2].Value.ToString()); cmd.ExecuteNonQuery(); } }
// 수량 업데이트 private void ProdCountUpdate(DataGridViewRow row) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("ProdCountUpdate", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", row.Cells[2].Value.ToString()); cmd.Parameters.AddWithValue("@count", int.Parse(row.Cells[4].Value.ToString())); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }
// 현금결제 영수증 표출 private void MoneyPayReceipt() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("ReceiptMoneyPay", con); cmd.Parameters.AddWithValue("@sellbar", ReceiptGridView.CurrentRow.Cells[0].Value.ToString()); cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; string view = ""; foreach (DataRow ed in rows) { if ((ed[0].ToString() + " ").Length > 18) { view = (ed[0].ToString() + " ").Substring(0, 20); } txtReceipt.Text += view + " " + ed[1].ToString() + " " + ed[2].ToString() + "\r\n"; } txtReceipt.Text += "\r\n"; txtReceipt.Text += "********************현 금******************\r\n"; txtReceipt.Text += "총 구 매 액 "; int count = 0; foreach (DataRow ed in rows) { count += int.Parse(ed[4].ToString()); gender = ed[3].ToString(); } txtReceipt.Text += count.ToString(); txtReceipt.Text += " " + ReceiptGridView.CurrentRow.Cells[3].Value.ToString(); txtReceipt.Text += "\r\n--------------------------------------------\r\n"; txtReceipt.Text += "내 실 돈 " + ReceiptGridView.CurrentRow.Cells[3].Value.ToString(); txtReceipt.Text += "\r\n받 은 금 액 "; string givmoney = ""; foreach (DataRow ed in rows) { givmoney = ed[5].ToString(); } txtReceipt.Text += givmoney; txtReceipt.Text += "\r\n거 스 름 돈 " + (int.Parse(givmoney) - int.Parse(ReceiptGridView.CurrentRow.Cells[3].Value.ToString())).ToString(); }
// 데이터 타임 피커 private void btn_Confirm_Click(object sender, EventArgs e) { string[] sell_date = new string[arraySize]; string[] sell_all_amount = new string[arraySize]; string[] sell_pure = new string[arraySize]; string[] sell_select = new string[arraySize]; using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { con.Open(); dateTimePicker1.Value.ToShortDateString(); var cmd = new SqlCommand("SalesTimePicker", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@sell_date", dateTimePicker1.Value.ToShortDateString()); ds = new DataSet(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; ds.Clear(); con.Close(); List <Sales> temp = new List <Sales>(); SStatusGridView.DataSource = null; foreach (var item in Slist) { int flag = DateTime.Compare(DateTime.Parse(item.Sell_Date.ToShortDateString()), DateTime.Parse(dateTimePicker1.Value.ToShortDateString())); if (flag == 0) { temp.Add(new Sales { Sell_Date = item.Sell_Date, Sell_All_Amount = item.Sell_All_Amount, Sell_pure_Money = item.Sell_pure_Money, Sell_Select = item.Sell_Select }); } } SStatusGridView.DataSource = temp; SStatusGridView.Columns[0].HeaderText = "날짜"; SStatusGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; SStatusGridView.Columns[1].HeaderText = "판매액"; SStatusGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; SStatusGridView.Columns[2].HeaderText = "순수익"; SStatusGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; SStatusGridView.Columns[3].HeaderText = "결제수단"; SStatusGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } }
// 주문목록 그리드뷰 private void OrderListView() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("OrderTotal", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { OrderListGrid.Rows.Add(false, ed[0].ToString(), ed[1].ToString(), ed[2].ToString(), ed[3].ToString(), ed[4].ToString(), ed[5].ToString(), ed[6].ToString()); } }
private void SellProdInsert() { for (int i = 0; i < itemGrid.Rows.Count; i++) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SellLMoneyInsert", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); cmd.Parameters.AddWithValue("@selldate", DateTime.Now); cmd.Parameters.AddWithValue("@barcode", itemGrid.Rows[i].Cells[2].Value.ToString()); cmd.Parameters.AddWithValue("@count", itemGrid.Rows[i].Cells[4].Value.ToString()); cmd.Parameters.AddWithValue("@age", lblAge.Text); cmd.Parameters.AddWithValue("@gender", lblGender.Text); cmd.Parameters.AddWithValue("@empnum", 1); cmd.Parameters.AddWithValue("@sellBarcode", sellbarcode.ToString()); cmd.Parameters.AddWithValue("@sellgivmoney", int.Parse(txtMoney.Text)); cmd.ExecuteNonQuery(); con.Close(); } }
// 재고조회(바코드) private void SearchStockBarcode() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SearchStockProdBacode", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@bacode", "%" + StockInfoTxt.Text + "%"); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { ProdStockView.Rows.Add(false, ed[0].ToString(), ed[1].ToString(), ed[2].ToString(), ed[3].ToString(), ed[4].ToString()); } }
// 발주목록 바코드 검색 private void OrderBarcode() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("OrderBarcodeSearch", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", "%" + txtSearch.Text + "%"); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { OrderListGrid.Rows.Add(false, ed[0].ToString(), ed[1].ToString(), ed[2].ToString(), ed[3].ToString(), ed[4].ToString(), ed[5].ToString(), ed[6].ToString()); } }
// 상품조회(상품명) private void SearchProdName() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SearchProdName", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@prodName", "%" + prodInfoTxt.Text + "%"); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { itemListGrid.Rows.Add(false, ed[0].ToString(), ed[1].ToString(), ed[2].ToString(), ed[3].ToString(), ed[4].ToString(), (int.Parse(ed[4].ToString()) - int.Parse(ed[3].ToString()))); } }
// 바코드 번호로 시간 지불방법 조회 띄우기 private void SellGridTime() { int j = 0; int count = 0; for (int i = 0; i < sellBar.Length; i++) { if (sellBar[i] != null) { count = i + 1; } } SellDate = new string[count]; SellSelect = new string[count]; //MessageBox.Show(sellBar[0].ToString()); for (int i = 0; i < SellDate.Length; i++) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("SellBarcodeSelect2", con); cmd.Parameters.AddWithValue("@sellbar", sellBar[i].ToString()); cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { SellDate[j] = ed[0].ToString(); SellSelect[j] = ed[1].ToString(); } j++; } }
private void BonusEvent() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("EventBonus", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@eventNum", eventNum); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow er in rows) { if (er[0].ToString() == "") { return; } else { int bonus = 0; //EventDr = itemGrid.Rows[itemGrid.RowCount - 1]; bonus = int.Parse(EventDr.Cells[4].Value.ToString()) / (int.Parse(er[0].ToString()) + 1); //MessageBox.Show(EventDr.Cells[4].Value.ToString()); //MessageBox.Show(bonus.ToString()); //MessageBox.Show(price.ToString()); if (bonus >= 1) { //MessageBox.Show(EventDr.Index.ToString()); EventDr.Cells[3].Value = int.Parse(EventDr.Cells[3].Value.ToString()) - (price * bonus); } } } }
// 업데이트 버튼 클릭 private void btnUpdate_Click(object sender, EventArgs e) { try { for (int i = 0; i < ProdStockView.RowCount; i++) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("UpdateStock", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", ProdStockView.Rows[i].Cells[1].Value.ToString()); cmd.Parameters.AddWithValue("@count", int.Parse(ProdStockView.Rows[i].Cells[5].Value.ToString())); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } MessageBox.Show("재고가 수정되었습니다."); } catch (Exception) { MessageBox.Show("수량은 숫자로 입력해 주세요~!"); return; } }
// 로드시 장바구니 내역 그리드뷰 띄우기 private void OrderList() { foreach (var item in basketList.Items) { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("OrderConfirm", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", item.ToString().Substring(5, item.ToString().IndexOf("상품명 :", 0) - 5).Trim()); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; foreach (DataRow ed in rows) { itemListGrid.Rows.Add(ed[0].ToString(), ed[1].ToString(), ed[2].ToString(), ed[3].ToString()); } con.Close(); } }
private void InputInfo() { txtProdInfo.Text = ""; if (cursor == txtMoney) { txtReturnMoney.Text = (int.Parse(txtMoney.Text) - int.Parse(txtPrice.Text)).ToString(); } var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("ProdRegist", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@prodNum", txtBacode.Text); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; if (rows.Count.ToString() == "0") { cmd = new SqlCommand("ProdRegistNoEvent", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", txtBacode.Text); adapter.SelectCommand = cmd; adapter.Fill(ds); pro = ds.Tables[0]; rows = pro.Rows; foreach (DataRow er in rows) { string[] row = { noCount.ToString(), er[0].ToString(), er[1].ToString(), er[2].ToString(), "1" }; itemGrid.Rows.Add(row); price = int.Parse(er[2].ToString()); bacode = er[1].ToString(); txtProdInfo.Text += "<상품 명>\r\n"; txtProdInfo.Text += er[0] + "\r\n\r\n"; eventPrice = price; } } else { foreach (DataRow er in rows) { string[] row = { noCount.ToString(), er[0].ToString(), er[1].ToString(), er[2].ToString(), "1", er[3].ToString() }; itemGrid.Rows.Add(row); price = int.Parse(er[2].ToString()); bacode = er[1].ToString(); txtProdInfo.Text += "<상품 명>\r\n"; txtProdInfo.Text += er[0] + "\r\n\r\n"; txtProdInfo.Text += "<이벤트 명>\r\n"; txtProdInfo.Text += er[3] + "\r\n\r\n"; txtProdInfo.Text += "<이벤트 기간>\r\n"; txtProdInfo.Text += er[4] + "~\r\n" + er[5] + "\r\n\r\n"; txtProdInfo.Text += "<이벤트 내용>\r\n"; txtProdInfo.Text += er[6] + "\r\n\r\n"; eventNum = int.Parse(er[9].ToString()); eventPrice = price; } } EventDr = itemGrid.CurrentRow; string barcodeNum = txtBacode.Text; ProdImage(barcodeNum); //DiscountEvent(); for (int i = 0; i < itemGrid.Rows.Count - 1; i++) { if (itemGrid.Rows[i].Cells[2].Value.ToString() == bacode) { itemGrid.Rows[i].Cells[4].Value = int.Parse(itemGrid.Rows[i].Cells[4].Value.ToString()) + 1; itemGrid.Rows[i].Cells[3].Value = (price * int.Parse(itemGrid.Rows[i].Cells[4].Value.ToString())).ToString(); //qq itemGrid.Rows.Remove(itemGrid.Rows[itemGrid.Rows.Count - 1]); noCount--; itemGrid.Rows[i].Selected = true; } else { for (int f = 0; f < itemGrid.RowCount; f++) { itemGrid.Rows[f].Selected = false; } itemGrid.Rows[itemGrid.RowCount - 1].Selected = true; } } for (int f = 0; f < itemGrid.RowCount; f++) { if (itemGrid.Rows[f].Selected == true) { EventDr = itemGrid.Rows[f]; } } //try //{ // itemGrid.CurrentRow.Cells[3].Value = (price * int.Parse(itemGrid.CurrentRow.Cells[4].Value.ToString())).ToString(); //} //catch (FormatException) //{ // MessageBox.Show("항목선택 후 수량을 입려해 주세요"); // txtBacode.Text = ""; // prodCount = ""; // return; //} txtBacode.Text = ""; noCount++; con.Close(); GiveMoney(); for (int i = 0; i < itemGrid.Rows.Count; i++) { itemGrid.Rows[i].Cells[0].Value = i + 1; } prodCount = ""; rows.Clear(); //BonusEvent(); }
private void itemGrid_CellClick(object sender, DataGridViewCellEventArgs e) { using (var conn = DbMan.Dbcon(sqlcon)) { conn.Open(); using (var cmdd = new SqlCommand("ProCount", conn)) { cmdd.CommandType = CommandType.StoredProcedure; cmdd.Parameters.AddWithValue("@barcode", itemGrid.CurrentRow.Cells[2].Value.ToString()); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmdd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable proo = ds.Tables[0]; DataRowCollection rowss = proo.Rows; foreach (DataRow er in rowss) { eventPrice = int.Parse(er[0].ToString()); } } } for (int i = 0; i < itemGrid.RowCount; i++) { if (itemGrid.Rows[i].Selected == true) { EventDr = itemGrid.Rows[i]; price = eventPrice; } } button1.Enabled = true; txtProdInfo.Text = ""; cursor = null; var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("ProdRegist", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@prodNum", itemGrid.CurrentRow.Cells[2].Value.ToString()); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; if (rows.Count.ToString() == "0") { cmd = new SqlCommand("ProdRegistNoEvent", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@barcode", itemGrid.CurrentRow.Cells[2].Value.ToString()); adapter.SelectCommand = cmd; adapter.Fill(ds); pro = ds.Tables[0]; rows = pro.Rows; foreach (DataRow er in rows) { txtProdInfo.Text += "<상품 명>\r\n"; txtProdInfo.Text += er[0] + "\r\n\r\n"; } } else { foreach (DataRow er in rows) { txtProdInfo.Text += "<상품 명>\r\n"; txtProdInfo.Text += er[0] + "\r\n\r\n"; txtProdInfo.Text += "<이벤트 명>\r\n"; txtProdInfo.Text += er[3] + "\r\n\r\n"; txtProdInfo.Text += "<이벤트 기간>\r\n"; txtProdInfo.Text += er[4] + "~\r\n" + er[5] + "\r\n\r\n"; txtProdInfo.Text += "<이벤트 내용>\r\n"; txtProdInfo.Text += er[6] + "\r\n\r\n"; } } con.Close(); rows.Clear(); string barcodeNum = itemGrid.CurrentRow.Cells[2].Value.ToString(); ProdImage(barcodeNum); }
// 카드결제 영수증 표출 private void CardPayReceipt() { var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("ReceiptCardPay", con); cmd.Parameters.AddWithValue("@sellbar", ReceiptGridView.CurrentRow.Cells[0].Value.ToString()); cmd.CommandType = CommandType.StoredProcedure; con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; string view = ""; foreach (DataRow ed in rows) { if ((ed[2].ToString() + " ").Length > 18) { view = (ed[2].ToString() + " ").Substring(0, 20); } txtReceipt.Text += view + " " + ed[3].ToString() + " " + ed[4].ToString() + "\r\n"; } txtReceipt.Text += "\r\n*****************신 용 카 드***************\r\n"; string cardnum = ""; string cardcom = ""; foreach (DataRow ed in rows) { cardnum = ed[0].ToString(); cardcom = ed[1].ToString(); } txtReceipt.Text += "카드번호 : " + cardnum; txtReceipt.Text += "\r\n카드회사 : " + cardcom; txtReceipt.Text += "\r\n할부개월 : 00 승인번호 : " + Math.Abs(cardnum.GetHashCode()); txtReceipt.Text += "\r\n--------------------------------------------\r\n"; txtReceipt.Text += "총 구 매 액 "; int count = 0; foreach (DataRow ed in rows) { count += int.Parse(ed[6].ToString()); gender = ed[5].ToString(); } txtReceipt.Text += count.ToString(); txtReceipt.Text += " " + ReceiptGridView.CurrentRow.Cells[3].Value.ToString(); txtReceipt.Text += "\r\n--------------------------------------------\r\n"; txtReceipt.Text += "내 실 돈 "; CardSelectCase(cardcom); string givcard = ""; foreach (DataRow ed in rows) { givcard = ed[7].ToString(); } txtReceipt.Text += givcard + "\r\n"; txtReceipt.Text += "신 용 카 드 " + givcard; txtReceipt.Text += "\r\n\t\t" + cardcom + cardcomDis + "\r\n"; }
private void button1_Click(object sender, EventArgs e) { if (txtCardNum.Text == "" || txtYear.Text == "" || txtMonth.Text == "") { MessageBox.Show("카드 정보를 모두 입력해주세요"); return; } else if (txtYear.Text.Length != 4) { MessageBox.Show("년도는 4자를 입력해야 합니다. Ex)2018"); return; } else if (txtMonth.Text.Length != 2) { MessageBox.Show("월은 2자를 입력해야 합니다. Ex)01"); return; } else if (int.Parse(txtYear.Text) < int.Parse(DateTime.Now.Year.ToString())) { MessageBox.Show("카드 유효기간은 현재날짜보다 적을수 없습니다"); return; } else if (!(int.Parse(txtMonth.Text) < 13 && int.Parse(txtMonth.Text) >= int.Parse(DateTime.Now.Month.ToString()))) { MessageBox.Show("카드 유효기간은 현재날짜보다 적거나 1~12월 사이여야 합니다"); } string cardNumSix = txtCardNum.Text.Substring(0, 6); var con = DbMan.Dbcon(sqlcon); var cmd = new SqlCommand("CardSearch", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@cardNum", cardNumSix); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; ds = DbMan.DbDs(ds); adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; groupBox1.Visible = true; if (txtCardNum.Text.Length != 16) { MessageBox.Show("카드번호는 16자리 입니다."); return; } foreach (DataRow er in rows) { txtCardCom.Text = er["card_name"].ToString(); txtCardSilp.Text = er["card_slip"].ToString(); txtCardBrand.Text = er["card_brand"].ToString(); txtCardC_C.Text = er["card_c_c"].ToString(); txtCardP_C.Text = er["card_p_c"].ToString(); } if (txtCardCom.Text == "") { MessageBox.Show("잘못된 카드정보입니다."); return; } switch (txtCardCom.Text) { case "신한카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "3% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.03).ToString(); break; case "BC카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "2% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.02).ToString(); break; case "비씨카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "5% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.05).ToString(); break; case "NH농협카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "2% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.02).ToString(); break; case "KB카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "1% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.01).ToString(); break; case "롯데카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "3% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.03).ToString(); break; case "삼성카드": lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "1% 할인!"; txtDiscount.Text = (int.Parse(txtMoney.Text) * 0.01).ToString(); break; default: lblCardType.Text = txtCardCom.Text; lblDiscountPer.Text = "할인 없음"; break; } }
// 매출 현황 그리드뷰에 띄우기 private void SalesStatus_Load(object sender, EventArgs e) { DateTime current = DateTime.Now; using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { using (var cmd = new SqlCommand("SellCount", con)) { cmd.CommandType = CommandType.StoredProcedure; ds = new DataSet(); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pro = ds.Tables[0]; rows = pro.Rows; foreach (DataRow er in rows) { arraySize = int.Parse(er[0].ToString()); } } } string[] sell_date = new string[arraySize]; string[] sell_all_amount = new string[arraySize]; string[] sell_pure = new string[arraySize]; string[] sell_select = new string[arraySize]; // 판매 날짜 using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { using (var cmd = new SqlCommand("SalesDate", con)) { cmd.CommandType = CommandType.StoredProcedure; ds = new DataSet(); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; for (int i = 0; i < rows.Count; i++) { sell_date[i] = rows[i].ItemArray[0].ToString(); } } } // 판매 총액 using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { con.Open(); for (int i = 1; i <= sell_date.Length; i++) { var cmd = new SqlCommand("SalesAll", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@i", i); ds = new DataSet(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; sell_all_amount[i - 1] = rows[0].ItemArray[0].ToString(); ds.Clear(); } } // 판매 순수익 using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { con.Open(); for (int i = 1; i <= sell_date.Length; i++) { var cmd = new SqlCommand("SalesPure", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@i", i); ds = new DataSet(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; sell_pure[i - 1] = rows[0].ItemArray[0].ToString(); ds.Clear(); } } // 결제 수단 using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { using (var cmd = new SqlCommand("SalesSelect", con)) { cmd.CommandType = CommandType.StoredProcedure; ds = new DataSet(); con.Open(); adapter = DbMan.DbAdap(adapter); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pro = ds.Tables[0]; DataRowCollection rows = pro.Rows; for (int i = 0; i < rows.Count; i++) { sell_select[i] = rows[i].ItemArray[0].ToString(); } } } // 리스트에 넣기 for (int i = 0; i < sell_all_amount.Length; i++) { Slist.Add(new Sales { Sell_Date = DateTime.Parse(sell_date[i].ToString()), Sell_All_Amount = int.Parse(sell_all_amount[i]), Sell_pure_Money = int.Parse(sell_pure[i]), Sell_Select = sell_select[i].ToString() }); } SStatusGridView.DataSource = Slist; SStatusGridView.Columns[0].HeaderText = "날짜"; SStatusGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; SStatusGridView.Columns[1].HeaderText = "판매액"; SStatusGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; SStatusGridView.Columns[2].HeaderText = "순수익"; SStatusGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; SStatusGridView.Columns[3].HeaderText = "결제수단"; SStatusGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; for (int i = 0; i < SStatusGridView.RowCount; i++) { if (SStatusGridView.Rows[i].Cells[3].Value.ToString() == "money") { moneyList.Add(new Sales { Sell_Date = DateTime.Parse(SStatusGridView.Rows[i].Cells[0].Value.ToString()), Sell_All_Amount = int.Parse(SStatusGridView.Rows[i].Cells[1].Value.ToString()), Sell_pure_Money = int.Parse(SStatusGridView.Rows[i].Cells[2].Value.ToString()), Sell_Select = SStatusGridView.Rows[i].Cells[3].Value.ToString() }); } else if (SStatusGridView.Rows[i].Cells[3].Value.ToString() == "card") { cardList.Add(new Sales { Sell_Date = DateTime.Parse(SStatusGridView.Rows[i].Cells[0].Value.ToString()), Sell_All_Amount = int.Parse(SStatusGridView.Rows[i].Cells[1].Value.ToString()), Sell_pure_Money = int.Parse(SStatusGridView.Rows[i].Cells[2].Value.ToString()), Sell_Select = SStatusGridView.Rows[i].Cells[3].Value.ToString() }); } } }