//删除 private void btnDelete_Click(object sender, EventArgs e) { if (dgvExpense.CurrentCell == null) { BathClass.printErrorMsg("需要输入订单!"); return; } string orderId = dgvExpense.CurrentRow.Cells[0].Value.ToString(); //var order = db.Orders.FirstOrDefault(x => x.id == orderId); //if (order == null) //{ // BathClass.printErrorMsg("输入订单编号错误!"); // return; //} if (m_Orders.Contains(orderId)) { BathClass.printErrorMsg("已点订单,不能删除!"); return; } if (!dao.execute_command("delete from [Orders] where id=" + orderId)) { BathClass.printErrorMsg("删除订单失败!"); return; } //db.Orders.DeleteOnSubmit(order); //db.SubmitChanges(); BathClass.find_combo(m_con_str, m_Seat.systemId, m_Seat.text); //m_Orders.Remove(order); //BathClass.find_combo(db, m_Seat, m_Orders); dgvExpense_show(); }
//点击台位按钮 private void btn_Click(object sender, EventArgs e) { var btn = sender as Button; var strs = btn.Text.Split('\n'); var str = strs.FirstOrDefault(x => x.Contains("房间")); var roomId = str.Split(':')[1]; var room = db.Room.FirstOrDefault(x => x.name == roomId); if (room.status != "服务") { BathClass.printErrorMsg("客房不在服务状态,不能催钟"); return; } if (BathClass.printAskMsg("确定催钟?") != DialogResult.Yes) { return; } var roomCall = new RoomCall(); roomCall.roomId = roomId; roomCall.read = false; roomCall.msg = "催钟"; db.RoomCall.InsertOnSubmit(roomCall); db.SubmitChanges(); this.Close(); }
//添加备注 private void CtxAddNote_Click(object sender, EventArgs e) { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); if (!BathClass.getAuthority(db_new, LogIn.m_User, "添加备注")) { BathClass.printErrorMsg("权限不够!"); return; } Seat seat = getContextSenderSeat(db_new, sender); if (seat.status != 2 && seat.status != 6) { BathClass.printErrorMsg("手牌未使用,不能添加备注"); return; } NoteForm noteForm = new NoteForm(); if (noteForm.ShowDialog() != DialogResult.OK) { return; } seat.note = noteForm.note; db_new.SubmitChanges(); }
//打印 private void printTool_Click(object sender, EventArgs e) { try { if (dgv.Rows.Count == 0) { 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; PrintReceipt.Print_DataGridView("技师对账单汇总", dgv, lastTime.ToString("yyyy-MM-dd HH:mm:ss"), thisTime.ToString("yyyy-MM-dd HH:mm:ss"), companyName); } catch { BathClass.printErrorMsg("打印出错,请重新打印!"); } }
//显示信息 private void dgv_show() { dgv.Rows.Clear(); if (month.Text == "" && averageMax.Text == "" && averageMin.Text == "" && totalMax.Text == "" && totalMin.Text == "" && timesMax.Text == "" && timesMin.Text == "") { BathClass.printErrorMsg("需要输入至少一项条件!"); return; } month_Text = month.Text; averageMax_Text = averageMax.Text; averageMin_Text = averageMin.Text; totalMax_Text = totalMax.Text; totalMin_Text = totalMin.Text; timesMax_Text = timesMax.Text; timesMin_Text = timesMin.Text; dt_st = DateTime.Parse(st.Value.Date.ToString("yyyy-MM-dd") + " 00:00:00"); dt_et = DateTime.Parse(et.Value.Date.ToString("yyyy-MM-dd") + " 23:59:59"); if (m_thread != null && m_thread.IsAlive) { m_thread.Abort(); } m_thread = new Thread(new ThreadStart(do_dgv_show)); m_thread.Start(); }
//确定 private void btnOk_Click(object sender, EventArgs e) { m_SeatType.name = name.Text; m_SeatType.population = Convert.ToInt32(population.Text); m_SeatType.depositeRequired = depositRequired.Checked; m_SeatType.department = seatDepart.Text; if (depositRequired.Checked) { if (depositMin.Text == "") { depositMin.Focus(); BathClass.printErrorMsg("需要输入最低押金金额"); return; } m_SeatType.depositeAmountMin = Convert.ToInt32(depositMin.Text); } if (menuId.Text != "") { m_SeatType.menuId = db.Menu.FirstOrDefault(x => x.name == menuId.Text).id; } else { m_SeatType.menuId = null; } if (newSeatType) { db.SeatType.InsertOnSubmit(m_SeatType); } db.SubmitChanges(); this.DialogResult = DialogResult.OK; }
//确定 private void btnOk_Click(object sender, EventArgs e) { m_Stock.name = name.Text; m_Stock.note = note.Text; m_Stock.phone = phone.Text; var ips = new List <string>(); foreach (var i in pcList.CheckedItems) { ips.Add(i.ToString()); } m_Stock.ips = string.Join("|", ips.ToArray()); if (newStock) { if (db.Stock.FirstOrDefault(x => x.ips == m_Stock.ips) != null) { BathClass.printErrorMsg("此ip地址对应电脑已经定义仓库,请重新选择!"); return; } db.Stock.InsertOnSubmit(m_Stock); } else { if (db.Stock.FirstOrDefault(x => x.ips == m_Stock.ips && x.id != m_Stock.id) != null) { BathClass.printErrorMsg("此ip地址对应电脑已经定义仓库,请重新选择!"); return; } } db.SubmitChanges(); this.DialogResult = DialogResult.OK; }
//确定 private void btnOk_Click(object sender, EventArgs e) { int money = 0; int money_a = MConvert <int> .ToTypeOrDefault(m_Seat.deposit, 0); if (!int.TryParse(deposit.Text, out money)) { BathClass.printErrorMsg("押金应输入整数"); return; } if (money + money_a <= Convert.ToDouble(moneyExpense.Text)) { deposit.Focus(); BathClass.printErrorMsg("押金金额必须大于消费金额!"); return; } string cmd_str = @"update [Seat] set deposit=" + (money_a + money).ToString() + ", status=7 where text='" + m_Seat.text + "'"; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("押金离场失败,请重试!"); return; } m_Seat.deposit = money_a + money; //m_Seat.status = 7; PrintDepositReceipt.Print_DataGridView(m_Seat, m_Seat.deposit.ToString(), moneyExpense.Text, db.Options.FirstOrDefault().companyName); //db.SubmitChanges(); this.DialogResult = DialogResult.OK; }
//确定 private void btnOk_Click(object sender, EventArgs e) { if (btnOk.Text == "读卡") { get_member(); } else if (btnOk.Text == "会员打折") { if (m_member.state == "挂失") { BathClass.printErrorMsg("打折卡已挂失,无法使用!"); return; } find_promotion(); foreach (var seat in m_Seats) { seat.memberPromotionId = m_member.CI_CardNo; seat.memberDiscount = true; } db.SubmitChanges(); this.DialogResult = DialogResult.OK; } }
//对话框载入 private void MemberCardUsingForm_Load(object sender, EventArgs e) { try { memberSetting = dao.get_MemberSetting(); cardType = memberSetting.cardType; if (cardType != "CT") { get_member(); } else { id.Enabled = true; } if (!MConvert <bool> .ToTypeOrDefault(LogIn.options.启用会员卡密码, false) || LogIn.options.会员卡密码类型 != "指纹") { m_use_finger_pwd = false; } } catch (System.Exception ex) { BathClass.printErrorMsg(ex.Message); } }
//对话框载入 private void MemberCardUsingForm_Load(object sender, EventArgs e) { int rt = axZKFPEngX1.InitEngine(); if (rt == 1) { BathClass.printErrorMsg("指纹识别驱动程序加载失败"); return; } else if (rt == 2) { BathClass.printErrorMsg("没有连接指纹识别仪"); return; } else if (rt == 3) { BathClass.printErrorMsg("属性SensorIndex指定的指纹仪不存在"); return; } if (axZKFPEngX1.IsRegister) { axZKFPEngX1.CancelEnroll(); } if (m_member.CI_Password == null || m_member.CI_Password == "") { axZKFPEngX1.BeginEnroll(); } else { axZKFPEngX1.BeginCapture(); } LableInfo.Text = "登记指纹,请放手指"; }
//消费录入 private void orderTool_Click(object sender, EventArgs e) { //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); if (!dao.get_authority(LogIn.m_User, "完整点单") && !dao.get_authority(LogIn.m_User, "可见本人点单")) { BathClass.printErrorMsg("权限不够!"); return; } List <int> sLst = new List <int>(); sLst.Add(2); sLst.Add(6); InputSeatForm inputSeatForm = new InputSeatForm(sLst); if (inputSeatForm.ShowDialog() != DialogResult.OK) { return; } //var seat = dao.get_seat("text", inputSeatForm.m_Seat.text); //var seat = db_new.Seat.FirstOrDefault(x => x.text == inputSeatForm.m_Seat.text); //seat.ordering = true; //db_new.SubmitChanges(); OrderForm orderForm = new OrderForm(inputSeatForm.m_Seat, LogIn.m_User, LogIn.connectionString, false); orderForm.ShowDialog(); //seat.ordering = false; //db_new.SubmitChanges(); }
//收到消息 private void btnReceived_Click(object sender, EventArgs e) { try { //var dc_new = new BathDBDataContext(connectionString); //var msg = dao.get_techMsg("select * from [TechMsg] where id=" + m_msg.id); ////var msg = dc_new.TechMsg.FirstOrDefault(x => x.id == m_msg.id); //msg.read = true; string cmd_str = @"update [TechMsg] set [read]=1 where id=" + m_msg.id; int count = dao.get_entities_count("select count(*) from [TechMsg]"); if (count > msgMaximum) { cmd_str += @" delete top(" + (count - msgMaximum).ToString() + ") from [TechMsg]"; } //dc_new.TechMsg.DeleteAllOnSubmit(dc_new.TechMsg.ToList().Take(dc_new.TechMsg.Count() - msgMaximum)); if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("记录更新失败,请重试!"); return; } //dc_new.SubmitChanges(); btnReceived.Enabled = false; m_player.Stop(); techId.Focus(); //_thread_pause = false; } catch { } }
//宾客转账 private void transferTool_Click(object sender, EventArgs e) { if (m_Seat == null) { BathClass.printErrorMsg("未选择手牌!"); return; } //TransferSelectForm transferSelectForm = new TransferSelectForm(m_Seat); //if (transferSelectForm.ShowDialog() != DialogResult.OK) // return; List <string> printCols = new List <string>(); printCols.Add("手牌"); printCols.Add("项目名称"); printCols.Add("技师"); printCols.Add("单价"); printCols.Add("数量"); printCols.Add("金额"); //PrintSeatBill.Print_DataGridView(m_seat, "转账确认单", dgvExpense, printCols, moneyPayable.Text, // db.Options.FirstOrDefault().companyName); paid = true; this.DialogResult = DialogResult.OK; }
//点击登陆 private void okBtn_Click(object sender, EventArgs e) { if (name.Text == "") { return; } if (m_User == null) { id.SelectAll(); id.Focus(); BathClass.printErrorMsg("该员工号不存在!"); return; } if (BathClass.GetMD5(pwd.Text) != m_User.password) { pwd.SelectAll(); pwd.Focus(); BathClass.printErrorMsg("密码不对!"); return; } write_user(); this.Hide(); MainWindow mainWindow = new MainWindow(); mainWindow.ShowDialog(); this.Close(); }
private void okBtn_Click(object sender, EventArgs e) { if (name.Text == "") { return; } if (pwd.Text == "") { pwd.Focus(); return; } if (employee == null) { id.SelectAll(); id.Focus(); BathClass.printErrorMsg("该员工号不存在!"); return; } if (IOUtil.GetMD5(pwd.Text) != employee.password) { pwd.SelectAll(); pwd.Focus(); BathClass.printErrorMsg("密码不对!"); return; } this.DialogResult = DialogResult.OK; }
//通过读数据库获取会员卡 private bool get_member_by_db() { if (phone.Text != "") { m_Member = db.CardInfo.FirstOrDefault(x => x.CI_Telephone == phone.Text); } else if (name.Text != "") { var members = db.CardInfo.Where(x => x.CI_Name == name.Text); if (members.Count() != 1) { BathClass.printErrorMsg("名称不唯一或者不存在!"); return(false); } m_Member = members.FirstOrDefault(); } else if (memberId.Text != "") { m_Member = db.CardInfo.FirstOrDefault(x => x.CI_CardNo == memberId.Text); } if (m_Member == null) { BathClass.printErrorMsg("该会员卡不在本店登记!"); return(false); } return(true); }
private void MainForm_Load(object sender, EventArgs e) { var code_str = IOUtil.get_config_by_key(ConfigKeys.KEY_COMPANY_CODE); companyCodes = code_str.Split(Constants.SplitChar).ToList(); DgvDateTotal.ColumnHeadersDefaultCellStyle.Font = new Font("SimSun", 11f); DgvDateStores.ColumnHeadersDefaultCellStyle.Font = new Font("SimSun", 11f); DgvMonthTotal.ColumnHeadersDefaultCellStyle.Font = new Font("SimSun", 11f); DgvMonthStores.ColumnHeadersDefaultCellStyle.Font = new Font("SimSun", 11f); DgvDateTotal.DefaultCellStyle.Font = new Font("SimSun", 13f); DgvDateStores.DefaultCellStyle.Font = new Font("SimSun", 13f); DgvMonthTotal.DefaultCellStyle.Font = new Font("SimSun", 13f); DgvMonthStores.DefaultCellStyle.Font = new Font("SimSun", 13f); int year = DateTime.Now.Year; while (year >= 2005) { CBYear.Items.Add(year); year--; } CBYear.SelectedIndex = 0; CBMonth.Text = DateTime.Now.Month.ToString().PadLeft(2, '0'); companyCodes.RemoveAll(x => x.Trim() == ""); if (companyCodes.Count == 0) { BathClass.printErrorMsg("未定义连锁店铺,请先到连锁店铺定义!"); BTDateFind.Enabled = false; BTMonthFind.Enabled = false; return; } }
//增加 private void btnAdd_Click(object sender, EventArgs e) { var seat = db.HotelRoom.FirstOrDefault(x => x.text == seatBox.Text || x.oId == seatBox.Text); seatBox.Text = ""; if (seat == null) { seatBox.SelectAll(); seatBox.Focus(); BathClass.printErrorMsg("手牌不存在!"); return; } if (m_open && seat.status != 1 && seat.status != 3) { seatBox.SelectAll(); seatBox.Focus(); BathClass.printErrorMsg("手牌不可用!"); return; } if (!m_open && seat.status != 2 && seat.status != 6 && seat.status != 7) { seatBox.SelectAll(); seatBox.Focus(); BathClass.printErrorMsg("手牌不在使用中,不能联排!"); return; } if (!m_Seats.Contains(seat)) { m_Seats.Add(seat); } dgv_show(); seatBox.Text = ""; seatBox.Focus(); }
//确定 private void btnOk_Click(object sender, EventArgs e) { if (rbtnAll.Checked) { var seats = db.HotelRoom.Where(x => x.status == 2 || x.status == 6 || x.status == 7 || x.status == 8); foreach (var seat in seats) { print_seat_bill(seat); } } else if (radioshoe.Checked) { var seats = db.HotelRoom.Where(x => x.status == 2 || x.status == 6 || x.status == 7); PrintCheckSeatBills.Print_DataGridView(seats.Select(x => x.text).ToList(), db.Options.FirstOrDefault().companyName); } else if (rBtnSeat.Checked) { var seat = db.HotelRoom.FirstOrDefault(x => x.text == seatBox.Text); if (seat == null) { BathClass.printErrorMsg("手牌号不存在"); return; } if (seat.status != 2 && seat.status != 6 && seat.status != 7 && seat.status != 8) { BathClass.printErrorMsg("手牌号不在使用中,不能预打账单"); return; } print_seat_bill(seat); } }
//打印 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 delProviderTool_Click(object sender, EventArgs e) { if (dgvCustomerList.CurrentCell == null) { BathClass.printErrorMsg("需要选择行!"); return; } var p = db.Provider.FirstOrDefault(x => x.name == dgvCustomerList.CurrentRow.Cells[0].Value.ToString()); if (db.StockIn.Any(x => x.providerId == p.id) || db.ProviderPays.Any(x => x.providerId == p.id)) { BathClass.printErrorMsg("与供应商已有账务往来,不能删除!"); return; } if (BathClass.printAskMsg("确认删除供应商" + p.name) != DialogResult.Yes) { return; } db.Provider.DeleteOnSubmit(p); db.SubmitChanges(); dgvProviderList_show(); }
//确定 private void BtnOK_Click(object sender, EventArgs e) { BtnOK.Enabled = false; BtnOK.Enabled = true; m_Seat = db.Seat.FirstOrDefault(x => x.text == text.Text || x.oId == text.Text); if (m_Seat == null) { BathClass.printErrorMsg("所选择台位不存在"); return; } if (m_Status != -1) { if (m_Status != m_Seat.status) { BathClass.printErrorMsg("所选择台位不可用"); return; } } else if (!m_StatusList.Contains(m_Seat.status)) { BathClass.printErrorMsg("所选择台位不可用"); return; } this.DialogResult = DialogResult.OK; }
//删除付款信息 private void delPayTool_Click(object sender, EventArgs e) { if (dgvProviderPays.CurrentCell == null) { BathClass.printErrorMsg("未选择供应商付款信息!"); return; } if (BathClass.printAskMsg("确认删除供应商付款信息?") != DialogResult.Yes) { return; } var p = db.Provider.FirstOrDefault(x => x.name == dgvCustomerList.CurrentRow.Cells[0].Value.ToString()); var pp = db.ProviderPays.FirstOrDefault(x => x.id.ToString() == dgvProviderPays.CurrentRow.Cells[0].Value.ToString()); db.ProviderPays.DeleteOnSubmit(pp); db.SubmitChanges(); int r = dgvCustomerList.CurrentCell.RowIndex; int c = dgvCustomerList.CurrentCell.ColumnIndex; dgvProviderList_show(); dgvCustomerList.CurrentCell = dgvCustomerList[c, r]; dgvProviderPays_show(p); }
//对话框载入 private void OrderMainForm_Load(object sender, EventArgs e) { connectionIP = IOUtil.get_config_by_key(ConfigKeys.KEY_CONNECTION_IP); if (connectionIP == "") { PCListForm pCListForm = new PCListForm(); if (pCListForm.ShowDialog() != DialogResult.OK) { this.Close(); return; } connectionIP = pCListForm.ip; IOUtil.set_config_by_key(ConfigKeys.KEY_CONNECTION_IP, connectionIP); } db = new BathDBDataContext(connectionString); if (!db.DatabaseExists()) { BathClass.printErrorMsg("连接IP不对或者网络不通,请重试!"); connectionIP = ""; IOUtil.set_config_by_key(ConfigKeys.KEY_CONNECTION_IP, connectionIP); this.Close(); return; } }
//打印 private void printTool_Click(object sender, EventArgs e) { try { if (dgv.Rows.Count == 0) { dgv_show(); } var dc = new BathDBDataContext(LogIn.connectionString); string companyName = LogIn.options.companyName; List <string> printColumns = new List <string>(); foreach (DataGridViewColumn dgvCol in dgv.Columns) { printColumns.Add(dgvCol.HeaderText); } dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); PrintReceipt.Print_DataGridView("客房押金表", dgv, now, now, companyName); //BathClass.set_dgv_fit(dgv); dgv.Rows.Clear(); } catch { BathClass.printErrorMsg("打印出错,请重新打印!"); } }
//消费录入 private void orderTool_Click(object sender, EventArgs e) { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); if (!BathClass.getAuthority(db_new, LogIn.m_User, "完整点单") && !BathClass.getAuthority(db_new, LogIn.m_User, "可见本人点单")) { BathClass.printErrorMsg("权限不够!"); return; } List <int> sLst = new List <int>(); sLst.Add(2); sLst.Add(6); var inputSeatForm = new InputRoomForm(sLst); if (inputSeatForm.ShowDialog() != DialogResult.OK) { return; } var seat = db_new.HotelRoom.FirstOrDefault(x => x.text == inputSeatForm.m_Seat.text); seat.ordering = true; db_new.SubmitChanges(); var orderForm = new HotelRoomOrderForm(inputSeatForm.m_Seat); orderForm.ShowDialog(); seat.ordering = false; db_new.SubmitChanges(); }
//发卡 public static bool destribute_card_4442(string company_code, string cardCode) { if (!connect_card_machine("SLE4442")) { return(false); } if (verify_pwd() != 0) { BathClass.printErrorMsg("密码验证失败!"); return(false); } string str = company_code + cardCode; byte[] data = Encoding.ASCII.GetBytes(str); byte[] buff = new byte[16]; int st = IC4442.my_encrypt(data, buff); st = IC4442.swr_4442(icdev, 32, 16, buff); if (st != 0) { BathClass.printErrorMsg("写卡失败!"); return(false); } st = IC.dv_beep(icdev, 20); st = IC.ic_exit(icdev); return(true); }
//取消打折 private void btnUndoDiscount_Click(object sender, EventArgs e) { var pars = new List <string>(); var vals = new List <string>(); vals.AddRange(m_Seats.Select(x => x.systemId).ToList()); int count = m_Seats.Count; for (int i = 0; i < count; i++) { pars.Add("systemId"); } var orders = dao.get_orders(pars, vals, "or"); StringBuilder sb = new StringBuilder(); foreach (var order in orders) { reset_order_money(order); sb.Append(@" update [Orders] set money="); sb.Append(order.money.ToString()); sb.Append(" , donorEmployee=null, donorExplain=null, donorTime=null where id="); sb.Append(order.id.ToString()); } if (!dao.execute_command(sb.ToString())) { BathClass.printErrorMsg("取消打折失败,请重试!"); return; } }
//退单 private void return_order(string orderId, Employee del_employee) { var form = new DeleteExplainForm(); if (form.ShowDialog() != DialogResult.OK) { return; } string deleteExpalin = form.txt; string cmd_str = @"update [Orders] set deleteEmployee='" + del_employee.id + "', deleteExplain='" + deleteExpalin + "', deleteTime=getdate() where id=" + orderId; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("退单失败!"); return; } BathClass.find_combo(m_con_str, m_Seat.systemId, m_Seat.text); dgvExpense_show(); if (!dao.execute_command("update [OrderStockOut] set deleteEmployee='" + del_employee.id + "' where orderId=" + orderId)) { BathClass.printErrorMsg("退换消耗品失败!"); } }