//显示订单详情 private void dgv_CurrentCellChanged(object sender, EventArgs e) { if (dgv.CurrentCell == null) { return; } int act_id = Convert.ToInt32(dgv.CurrentRow.Cells[0].Value); var orders = db.HisOrders.Where(x => x.accountId == act_id && x.deleteEmployee == null); dgvOrders.DataSource = from x in orders orderby x.id select new { 系统账号 = x.systemId, 手牌号 = x.text, 房间 = x.roomId, 录入员工 = x.inputEmployee, 项目名称 = x.menu, 单价 = db.Menu.FirstOrDefault(y => y.name == x.menu) == null ? 0 : db.Menu.FirstOrDefault(y => y.name == x.menu).price, 数量 = x.number, 金额 = x.money, 技师号 = x.technician, 消费时间 = x.inputTime }; dgvOrders.Columns[2].Visible = use_pad; BathClass.set_dgv_fit(dgvOrders); }
//打印 private void printTool_Click(object sender, EventArgs e) { try { dgv_show(); var dc = new BathDBDataContext(LogIn.connectionString); string companyName = dc.Options.FirstOrDefault().companyName; List<string> printColumns = new List<string>(); foreach (DataGridViewColumn dgvCol in dgv.Columns) { printColumns.Add(dgvCol.HeaderText); } dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; if (ptTimeList.SelectedIndex == 0) { CashPrintTime cpt = new CashPrintTime(); cpt.macAdd = macAdd; cpt.time = GeneralClass.Now; dc.CashPrintTime.InsertOnSubmit(cpt); dc.SubmitChanges(); } PrintReceipt.Print_DataGridView(dgv, lastTime.ToString("yyyy-MM-dd HH:mm:ss"), thisTime.ToString("yyyy-MM-dd HH:mm:ss"), companyName); BathClass.set_dgv_fit(dgv); } catch { BathClass.printErrorMsg("打印出错,请重新打印!"); } }
private void dgvUsed_show() { dgvUsed.Rows.Clear(); string errorDesc = ""; var coupons = WxCouponManagement.queryCouponRecords(LogIn.connectionIP, LogIn.options.company_Code, openId, DPStart.Value.ToString("yyyy-MM-dd HH:mm:ss"), DPEnd.Value.ToString("yyyy-MM-dd HH:mm:ss"), out errorDesc); if (coupons == null) { BathClass.printErrorMsg(errorDesc); return; } int i = 1; foreach (var coupon in coupons) { dgvUsed.Rows.Add(i, coupon.id, coupon.title, coupon.value, PCUtil.converJavaTimeToNetTime(coupon.consumeTime)); i++; } BathClass.set_dgv_fit(dgvUsed); dgvUsed.CurrentCell = null; }
//消费情况列表 private void dgvOrders_Show() { if (dgvActList.CurrentCell == null) { return; } int act_id = Convert.ToInt32(dgvActList.CurrentRow.Cells[0].Value); var act = db.Account.FirstOrDefault(x => x.id == act_id); var orders = db.HisOrders.Where(x => x.accountId == act_id && x.deleteEmployee == null && x.paid); dgvOrders.DataSource = from x in orders orderby x.systemId, x.inputTime select new { 系统账号 = x.systemId, 台号 = x.text, 房间 = x.roomId, 单据号 = x.billId, 录入员工 = x.inputEmployee, 项目名称 = x.menu, 单价 = db.Menu.FirstOrDefault(y => y.name == x.menu) == null ? 0 : db.Menu.FirstOrDefault(y => y.name == x.menu).price, 数量 = x.number, 金额 = (x.priceType == "每小时") ? (Math.Ceiling((act.payTime - x.inputTime).TotalHours) * x.money) : x.money, 技师号 = x.technician, 消费时间 = x.inputTime }; dgvOrders.Columns[2].Visible = use_pad; dgvOrders.Columns[3].Visible = input_order_id; BathClass.set_dgv_fit(dgvOrders); }
//查询 private void dgv_show() { dgv.Rows.Clear(); var dc = new BathDBDataContext(LogIn.connectionString); var all_his_orders = dc.HisOrders.Where(x => x.inputTime >= lastTime && x.inputTime <= thisTime && x.deleteEmployee == null); var orderLst = dc.Orders.Where(x => x.inputTime >= lastTime && x.inputTime <= thisTime && x.deleteEmployee == null); all_his_orders = all_his_orders.Where(x => x.technician != null); orderLst = orderLst.Where(x => x.technician != null); if (catgory.Text != "所有类别") { var catgoryId = dc.Catgory.FirstOrDefault(x => x.name == catgory.Text).id; var menus = dc.Menu.Where(x => x.technician && x.catgoryId == catgoryId).Select(x => x.name); orderLst = orderLst.Where(x => menus.Contains(x.menu)); all_his_orders = all_his_orders.Where(x => menus.Contains(x.menu)); } foreach (var order in all_his_orders) { dgv.Rows.Add(order.technician, order.text, order.menu, order.number, order.inputTime.ToString("MM-dd HH:mm")); } foreach (var order in orderLst) { dgv.Rows.Add(order.technician, order.text, order.menu, order.number, order.inputTime.ToString("MM-dd HH:mm")); } BathClass.set_dgv_fit(dgv); }
//消费情况显示 private void dgvDetails_show() { if (dgv.CurrentCell == null) { return; } var id = dgv.CurrentRow.Cells[0].Value.ToString(); var account = db.Account.FirstOrDefault(x => x.id.ToString() == id && x.abandon == null); var ids = account.systemId.Split('|'); var orders = db.HisOrders.Where(x => ids.Contains(x.systemId)); dgvDetails.DataSource = from x in orders orderby x.inputTime select new { 手牌号 = x.text, 项目名称 = x.menu, 数量 = x.number, 金额 = x.money, 技师号 = x.technician, 务类型 = x.techType, 录入时间 = x.inputTime, 录入工号 = x.inputEmployee }; BathClass.set_dgv_fit(dgvDetails); }
private void dgv_show() { var db = new BathDBDataContext(LogIn.connectionString); var ct = db.ClearTable.OrderByDescending(x => x.clearTime).FirstOrDefault(); var lastTime = DateTime.Parse("2013-01-01 00:00:00"); if (ct != null) { lastTime = ct.clearTime; } var acts = db.Account.Where(x => x.text.Contains(m_seat_text) && x.payTime > lastTime && x.abandon == null); dgv.DataSource = from x in acts orderby x.payTime select new { 账单号 = x.id, 手牌号 = x.text, 结账时间 = x.payTime, 结账员工 = x.payEmployee }; BathClass.set_dgv_fit(dgv); }
//显示信息 private void dgvCustomer_show() { dgvCustomerList.Rows.Clear(); foreach (var c in db.Customer) { double ts = 0; var acts = db.Account.Where(x => x.zero != null && x.abandon == null && x.name == c.id.ToString()); if (acts.Any()) { ts = acts.Sum(x => x.zero).Value; } double paid = 0; var cash = db.CustomerPays.Where(x => x.customerId == c.id && x.cash != null); if (cash.Any()) { paid += cash.Sum(x => x.cash).Value; } var bank = db.CustomerPays.Where(x => x.customerId == c.id && x.bank != null); if (bank.Any()) { paid += bank.Sum(x => x.bank).Value; } dgvCustomerList.Rows.Add(c.name, ts, paid, ts - paid, c.contact, c.mobile, c.phone, c.address, c.note); } BathClass.set_dgv_fit(dgvCustomerList); }
//显示信息 private void dgv_show() { dgv.Rows.Clear(); var ops = db.Operation.Where(x => x.explain == "手工打折"); ops = ops.Where(x => x.opTime >= startTime.Value && x.opTime <= endTime.Value); if (cEmployee.Checked) { ops = ops.Where(x => x.employee == employee.Text); } foreach (var op in ops) { var x = db.Account.FirstOrDefault(a => a.systemId == op.note2); if (x == null) { continue; } string[] row = { x.id.ToString(), x.text, x.systemId, x.payTime.ToString(), x.payEmployee, op.employee, op.note1, BathClass.get_account_money(x).ToString() }; dgv.Rows.Add(row); } BathClass.set_dgv_fit(dgv); }
//显示信息 private void dgv_show() { foreach (var room in db.Room) { if (room.status != null && room.status.Contains("等待服务")) { var tmp_s = room.status.Split('|'); var tmp_o = room.orderTime.Split('|'); var tmp_e = room.seat.Split('|'); var tmp_d = room.orderTechId.Split('|'); for (int i = 0; i < tmp_s.Length; i++) { if (tmp_s[i] == "等待服务") { try { var st = Convert.ToDateTime(tmp_o[i]); var tm = (int)(DateTime.Now - st).TotalMinutes; if (tm >= wait_delay) { dgv.Rows.Add(room.name, tmp_e[i], tmp_o[i], tmp_d[i], tm); } } catch { } } } } } BathClass.set_dgv_fit(dgv); }
//显示售卖消耗信息 private void dgv_orderstockout_show() { if (stock == null) { return; } var so = db.OrderStockOut.Where(x => x.stockId == stock.id && x.deleteEmployee == null); so = so.Where(x => x.date >= orderStockOut_start.Value && x.date <= orderStockOut_end.Value); if (cb_orderStockOut_item.Checked) { so = so.Where(x => x.name == orderStockOut_item.Text); } dgvOrderStockOut.DataSource = from x in so orderby x.id select new { 称 = x.name, 数量 = x.amount, 日期 = x.date, 销售人员 = x.sales, 订单号 = x.orderId }; BathClass.set_dgv_fit(dgvOrderStockOut); }
//查询 private void dgv_show() { dgv.Rows.Clear(); var seats = db.Seat.Where(x => x.status == 2); seats = seats.Where(x => db.SeatType.FirstOrDefault(y => y.id == x.typeId).department == "客房部"); seats = seats.OrderBy(x => x.openTime); double deposit = 0; double depositBank = 0; foreach (var seat in seats) { double tmp_deposit = MConvert <double> .ToTypeOrDefault(seat.deposit, 0); double tmp_deposit_bank = MConvert <double> .ToTypeOrDefault(seat.depositBank, 0); dgv.Rows.Add(seat.text, seat.name, seat.phone, tmp_deposit, tmp_deposit_bank); deposit += tmp_deposit; depositBank += tmp_deposit_bank; } dgv.Rows.Add(); dgv.Rows.Add("现金押金汇总", deposit); dgv.Rows[dgv.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightSkyBlue; dgv.Rows.Add("银联预授汇总", depositBank); dgv.Rows[dgv.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightSkyBlue; BathClass.set_dgv_fit(dgv); }
//显示出库信息 private void dgv_stockout_show() { if (stock == null) { return; } var so = db.StockOut.Where(x => x.stockId == stock.id); //var so = db.StockOut.Where(x => x.receiver == m_user.name); so = so.Where(x => x.date >= startTimeSi.Value && x.date <= endTimeSi.Value); if (ciSi.Checked) { so = so.Where(x => x.name == itemSo.Text); } dgvStockOut.DataSource = from x in so orderby x.id select new { 单号 = x.id, 称 = x.name, 数量 = x.amount, 仓库 = stock.name, 接受仓库 = db.Stock.FirstOrDefault(s => s.id == x.toStockId).name, 日期 = x.date, 领料人 = x.receiver, 经手人 = x.transactor, 审核 = x.checker, 备注 = x.note }; BathClass.set_dgv_fit(dgvStockOut); }
//显示信息 private void dgv_show() { var orders = db.Orders.Where(x => x.inputEmployee == m_user.id.ToString() && x.inputTime >= startTime.Value && x.inputTime <= endTime.Value && ((cboxSeat.Checked && x.text == seat.Text) || !cboxSeat.Checked) && ((cboxMenu.Checked && x.menu == menu.Text) || !cboxMenu.Checked)); orders = orders.OrderBy(x => x.inputTime); foreach (var x in orders) { var price = db.Menu.FirstOrDefault(y => y.name == x.menu).price; dgv.Rows.Add(x.text, x.systemId, x.id, price, x.number, x.menu, x.money, x.technician, x.inputTime); } var Horders = db.HisOrders.Where(x => x.inputEmployee == m_user.id.ToString() && x.inputTime >= startTime.Value && x.inputTime <= endTime.Value && ((cboxSeat.Checked && x.text == seat.Text) || !cboxSeat.Checked) && ((cboxMenu.Checked && x.menu == menu.Text) || !cboxMenu.Checked)); Horders = Horders.OrderBy(x => x.inputTime); foreach (var x in Horders) { var price = db.Menu.FirstOrDefault(y => y.name == x.menu).price; dgv.Rows.Add(x.text, x.systemId, x.id, price, x.number, x.menu, x.money, x.technician, x.inputTime); } BathClass.set_dgv_fit(dgv); }
//显示清单 private void dgvProviderList_show() { dgvCustomerList.Rows.Clear(); foreach (var p in db.Provider) { double ts = 0; var sis = db.StockIn.Where(x => x.providerId == p.id).Where(x => x.money != null); if (sis.Any()) { ts = sis.Sum(x => x.money).Value; } double ps = 0; var pps_cash = db.ProviderPays.Where(x => x.providerId == p.id).Where(x => x.cash != null); var pps_bank = db.ProviderPays.Where(x => x.providerId == p.id).Where(x => x.bank != null); if (pps_cash.Any()) { ps += pps_cash.Sum(x => x.cash).Value; } if (pps_bank.Any()) { ps += pps_bank.Sum(x => x.bank).Value; } dgvCustomerList.Rows.Add(p.name, ts, ps, ts - ps, p.contactor, p.mobile, p.tel, p.address, p.note); } BathClass.set_dgv_fit(dgvCustomerList); }
//显示入库信息 private void dgv_stockin_show() { if (stock == null) { return; } var s = db.StockIn.Where(x => x.stockId == stock.id); //var s = db.StockIn.Where(x => x.transactor == m_user.name); s = s.Where(x => x.date >= startTimeSi.Value && x.date <= endTimeSi.Value); if (ciSi.Checked) { s = s.Where(x => x.name == itemSi.Text); } dgvStockIn.DataSource = from x in s orderby x.id select new { 单号 = x.id, 称 = x.name, 进价 = x.cost, 数量 = x.amount, 仓库 = db.Stock.FirstOrDefault(y => y.id == x.stockId).name, 日期 = x.date, 经手人 = x.transactor, 审核 = x.checker, 备注 = x.note }; BathClass.set_dgv_fit(dgvStockIn); }
//显示台位消费信息 public void dgvExpense_show() { BathDBDataContext dc = new BathDBDataContext(LogIn.connectionString); dgvExpense.Rows.Clear(); List <string> ids = new List <string>(); ids.Add(m_Seat.systemId); var orders = dc.Orders.Where(x => ids.Contains(x.systemId) && x.deleteEmployee == null && !x.paid); orders = orders.OrderBy(x => x.inputTime); foreach (var o in orders) { string[] row = new string[10]; row[0] = o.id.ToString(); row[1] = o.text; row[2] = o.menu; row[3] = o.technician; row[4] = o.techType; row[6] = o.number.ToString(); row[8] = o.inputTime.ToString(); row[9] = o.inputEmployee; var m = db.Menu.FirstOrDefault(x => x.name == o.menu); bool redRow = false; if (m == null) { row[5] = ""; row[7] = o.money.ToString(); redRow = true; } else { if (o.priceType == "每小时") { row[5] = o.money.ToString() + "/时"; row[7] = (Math.Ceiling((DateTime.Now - o.inputTime).TotalHours) * o.money).ToString(); } else { row[5] = m.price.ToString(); row[7] = o.money.ToString(); } } dgvExpense.Rows.Add(row); if (redRow) { dgvExpense.Rows[dgvExpense.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Red; } } BathClass.set_dgv_fit(dgvExpense); }
private void dgvProviderPays_show(Provider p) { dgvProviderPays.Rows.Clear(); var pps = db.ProviderPays.Where(x => x.providerId == p.id); foreach (var pp in pps) { dgvProviderPays.Rows.Add(pp.id, pp.cash, pp.bank, pp.date, pp.payer, pp.receiver, pp.confirmer, pp.note); } BathClass.set_dgv_fit(dgvProviderPays); }
private void dgvStockIn_show(Provider p) { dgvProviderStockIn.Rows.Clear(); var sis = db.StockIn.Where(x => x.providerId == p.id); foreach (var si in sis) { dgvProviderStockIn.Rows.Add(si.name, si.cost, si.amount, si.money, si.unit, si.date, si.transactor, si.checker); } BathClass.set_dgv_fit(dgvProviderStockIn); }
//显示现有库存信息 private void dgv_storageList_show() { if (stock == null) { return; } dgvStorageList.Rows.Clear(); var stockIns = db.StockIn.Where(x => x.stockId == stock.id); var stockOuts = db.StockOut.Where(x => x.stockId == stock.id); var orderStockOuts = db.OrderStockOut.Where(x => x.stockId == stock.id && x.deleteEmployee == null); var pans = db.Pan.Where(x => x.stockId == stock.id); var name_Ins = stockIns.Select(x => x.name); var name_outs = stockOuts.Select(x => x.name); var name_OOuts = orderStockOuts.Select(x => x.name); var name_all = name_Ins.Union(name_outs).Union(name_OOuts).Distinct(); foreach (var name in name_all) { double number_Ins = 0; double number_Outs = 0; double number_OrderOuts = 0; double number_pans = 0; var name_stockIns = stockIns.Where(x => x.name == name).Where(x => x.amount != null); if (name_stockIns.Any()) { number_Ins = name_stockIns.Sum(x => x.amount).Value; } var name_stockOuts = stockOuts.Where(x => x.name == name).Where(x => x.amount != null); if (name_stockOuts.Any()) { number_Outs = MConvert <double> .ToTypeOrDefault(name_stockOuts.Sum(x => x.amount), 0); } var name_orderStockOuts = orderStockOuts.Where(x => x.name == name).Where(x => x.amount != null); if (name_orderStockOuts.Any()) { number_OrderOuts = MConvert <double> .ToTypeOrDefault(name_orderStockOuts.Sum(x => x.amount), 0); } var name_pans = pans.Where(x => x.name == name).Where(x => x.amount != null); if (name_pans.Any()) { number_pans = MConvert <double> .ToTypeOrDefault(name_pans.Sum(x => x.amount), 0); } dgvStorageList.Rows.Add(name, number_Ins + number_pans - number_Outs - number_OrderOuts, stock.name); } BathClass.set_dgv_fit(dgvStorageList); }
private void dgvActs_show(Customer c) { dgvActs.Rows.Clear(); var acts = db.Account.Where(x => x.zero != null && x.abandon == null && x.name == c.id.ToString()); foreach (var a in acts) { dgvActs.Rows.Add(a.id, a.text, a.payTime, a.payEmployee, a.zero); } BathClass.set_dgv_fit(dgvActs); }
private void dgvPays_show(Customer c) { dgvCustomerPays.Rows.Clear(); var pays = db.CustomerPays.Where(x => x.customerId == c.id); foreach (var p in pays) { dgvCustomerPays.Rows.Add(p.id, p.cash, p.bank, p.date, p.payEmployee, p.note); } BathClass.set_dgv_fit(dgvCustomerPays); }
private void dgv_show() { //var db = new BathDBDataContext(LogIn.connectionString); //var ct = db.ClearTable.OrderByDescending(x => x.clearTime).FirstOrDefault(); var ct = dao.get_last_clear_time(); var lastTime = DateTime.Parse("2013-01-01 00:00:00"); if (ct != null) { lastTime = ct.Value; } //var acts = db.Account.Where(x => x.text.Contains(m_seat_text) && x.payTime > lastTime && x.abandon == null); //dgv.DataSource = from x in acts // orderby x.payTime // select new // { // 账单号 = x.id, // 手牌号 = x.text, // 结账时间 = x.payTime, // 结账员工 = x.payEmployee // }; SqlConnection sqlCn = null; string cmd_str = ""; try { sqlCn = new SqlConnection(LogIn.connectionString); sqlCn.Open(); cmd_str = "Select * from [Account] where (abandon is null and payTime>'" + lastTime.ToString() + "' and text like" + "'%" + m_seat_text + "%')"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { dgv.Rows.Add(dr["id"], dr["text"], dr["payTime"], dr["payEmployee"]); } } } catch (System.Exception e) { IOUtil.insert_file(DateTime.Now.ToString() + "=" + cmd_str); BathClass.printErrorMsg(e.ToString()); } finally { dao.close_connection(sqlCn); } BathClass.set_dgv_fit(dgv); }
//单项项目统计 private void find_0() { dgv.Columns.Clear(); add_cols_to_dgv(dgv, "编号"); add_cols_to_dgv(dgv, "发生时间"); add_cols_to_dgv(dgv, "项目名称"); add_cols_to_dgv(dgv, "手牌号"); add_cols_to_dgv(dgv, "数量"); add_cols_to_dgv(dgv, "金额"); add_cols_to_dgv(dgv, "输入员工"); add_cols_to_dgv(dgv, "技师号"); add_cols_to_dgv(dgv, "账单号"); add_cols_to_dgv(dgv, "单据号"); var orderLst = db.Orders.Where(x => x.menu == menu.Text && x.inputTime >= lastTime && x.inputTime <= thisTime && x.deleteEmployee == null); var paid_orderLst = db.HisOrders.Where(x => x.menu == menu.Text && x.inputTime >= lastTime && x.inputTime <= thisTime && x.deleteEmployee == null); if (cboxBill.Checked && tbBill.Text != "") { orderLst = db.Orders.Where(x => x.billId == tbBill.Text); paid_orderLst = db.HisOrders.Where(x => x.billId == tbBill.Text); if (!orderLst.Any() && !paid_orderLst.Any()) { BathClass.printErrorMsg("输入单据号不存在!"); return; } } double number = 0; double money = 0; foreach (Orders order in orderLst) { number += order.number; money += Convert.ToDouble(order.money); dgv.Rows.Add(order.id, order.inputTime, order.menu, order.text, order.number, order.money, order.inputEmployee, order.technician, order.accountId, order.billId); } foreach (var order in paid_orderLst) { number += order.number; money += Convert.ToDouble(order.money); dgv.Rows.Add(order.id, order.inputTime, order.menu, order.text, order.number, order.money, order.inputEmployee, order.technician, order.accountId, order.billId); } dgv.Rows.Add("合计", "", menu.Text, "", number, money); BathClass.set_dgv_fit(dgv); }
private void dgv_show() { get_timeSpan(); if (details) { find_details(); } else { find_summery(); } BathClass.set_dgv_fit(dgv); }
//显示套餐清单 private void dgvCombo_show() { dgvCombo.DataSource = from x in db.BigCombo orderby x.id select new { 套餐号 = x.id, 称 = db.Menu.FirstOrDefault(y => y.id == x.menuid).name, 单价 = x.price, }; BathClass.set_dgv_fit(dgvCombo); }
//显示清单 public void dgv_show() { dgv.DataSource = from x in db.WaiterItem orderby x.id select new { 编号 = x.id, 称 = x.name, 备注 = x.note }; BathClass.set_dgv_fit(dgv); }
//显示信息 private void dgv_show() { dgv.DataSource = from x in db.BarMsg where x.time >= startTime.Value && x.time <= endTime.Value select new { 编号 = x.id, 时间 = x.time, 包厢 = x.roomId, 信息 = x.msg }; BathClass.set_dgv_fit(dgv); }
//显示套餐清单 private void dgvCombo_show() { dgvCombo.DataSource = from x in db.Combo orderby x.id select new { 套餐号 = x.id, 原价 = x.originPrice, 单价 = x.price, 优惠价格 = x.freePrice }; BathClass.set_dgv_fit(dgvCombo); }
//查询退单 private void findDeleteOrders() { dgv.Rows.Clear(); var orders = db.Orders.Where(x => x.inputTime >= startTime.Value && x.inputTime <= endTime.Value); var paid_orders = db.HisOrders.Where(x => x.inputTime >= startTime.Value && x.inputTime <= endTime.Value); orders = orders.Where(x => x.deleteEmployee != null); paid_orders = paid_orders.Where(x => x.deleteEmployee != null); if (cboxSeat.Checked) { orders = orders.Where(x => x.text == seat.Text); paid_orders = paid_orders.Where(x => x.text == seat.Text); } if (cboxMenu.Checked) { orders = orders.Where(x => x.menu == menu.Text); paid_orders = paid_orders.Where(x => x.menu == menu.Text); } if (cboxEmployee.Checked) { orders = orders.Where(x => x.deleteEmployee == employee.Text); paid_orders = paid_orders.Where(x => x.deleteEmployee == employee.Text); } foreach (var x in orders) { double price = 0; var menu = db.Menu.FirstOrDefault(y => y.name == x.menu); if (menu != null) { price = menu.price; } dgv.Rows.Add(x.billId, x.text, x.systemId, x.menu, price, x.number, x.money, x.technician, x.inputTime, x.inputEmployee, x.deleteEmployee, x.deleteExplain, x.deleteTime); } foreach (var x in paid_orders) { double price = 0; var menu = db.Menu.FirstOrDefault(y => y.name == x.menu); if (menu != null) { price = menu.price; } dgv.Rows.Add(x.billId, x.text, x.systemId, x.menu, price, x.number, x.money, x.technician, x.inputTime, x.inputEmployee, x.deleteEmployee, x.deleteExplain, x.deleteTime); } BathClass.set_dgv_fit(dgv); }