private void dgv_show() { dgv.Rows.Clear(); var companyCode = companies[ComboShopName.SelectedIndex].Split(Constants.SplitChar)[0]; if (companyCode == "") { MessageBox.Show("未定义连锁店铺,请先到连锁店铺定义!"); return; } string errorDesc = ""; var comments = ShopManagement.queryCommentByCompany(MainForm.ip, companyCode, out errorDesc); if (comments == null) { MessageBox.Show(errorDesc); return; } int i = 1; foreach (var comment in comments) { dgv.Rows.Add(i, comment.content, PCUtil.converJavaTimeToNetTime(comment.createTime).ToString("MM-dd HH:mm")); i++; } }
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 insert_account(ref Account account, string name) { account.text = m_Seat.text; account.systemId = m_Seat.systemId; account.openTime = m_Seat.openTime.ToString(); account.openEmployee = m_Seat.openEmployee; account.payTime = DateTime.Now; account.payEmployee = LogIn.m_User.id; account.server = BathClass.get_seat_expense(m_Seat, LogIn.connectionString); account.serverEmployee = name; account.macAddress = PCUtil.getMacAddr_Local(); db.Account.InsertOnSubmit(account); db.SubmitChanges(); }
/// <summary> /// 生成计算机码 /// </summary> /// <returns></returns> public static string GenerationCode() { string text = PCUtil.GetCPUID(); text += PCUtil.GetMacAddress(); text += PCUtil.GetSystemType(); byte[] b = Encoding.UTF8.GetBytes(text); SHA256 sh = SHA256.Create(); byte[] bytes = sh.ComputeHash(b); string base64string = Convert.ToBase64String(bytes); return(base64string); }
private void dgv_show() { string errorDesc = ""; var comments = ShopManagement.queryCommentByCompany(LogIn.connectionIP, LogIn.options.company_Code, out errorDesc); if (comments == null) { BathClass.printErrorMsg(errorDesc); return; } int i = 1; foreach (var comment in comments) { dgv.Rows.Add(i, comment.content, PCUtil.converJavaTimeToNetTime(comment.createTime).ToString("MM-dd HH:mm")); i++; } }
//对话框载入 private void CashierForm_Load(object sender, EventArgs e) { try { this.Size = new Size(this.Size.Width, Screen.GetWorkingArea(this).Height); this.Location = new Point(0, 0); ptTimeList.Items.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); macAdd = PCUtil.getMacAddr_Local(); var cpts = db.CashPrintTime.Where(x => x.macAdd == macAdd).OrderByDescending(x => x.time).Select(x => x.time); foreach (var cpt in cpts) { ptTimeList.Items.Add(cpt.ToString("yyyy-MM-dd HH:mm:ss")); } ptTimeList.SelectedIndex = 0; } catch (System.Exception ex) { BathClass.printErrorMsg(ex.Message); this.Close(); } }
//设置账单 private void set_account() { //account.text = string.Join("|", m_Seats_Real.OrderBy(x => x.text).Select(x => x.text).ToArray()); //account.systemId = string.Join("|", m_Seats_Real.OrderBy(x => x.text).Select(x => x.systemId).ToArray()); //account.openTime = string.Join("|", m_Seats_Real.OrderBy(x => x.text).Select(x => x.openTime.ToString()).ToArray()); //account.openEmployee = string.Join("|", m_Seats_Real.OrderBy(x => x.text).Select(x => x.openEmployee).ToArray()); account.text = string.Join("|", m_Seats.OrderBy(x => x.text).Select(x => x.text).ToArray()); account.systemId = string.Join("|", m_Seats.OrderBy(x => x.text).Select(x => x.systemId).ToArray()); account.openTime = string.Join("|", m_Seats.OrderBy(x => x.text).Select(x => x.openTime.ToString()).ToArray()); account.openEmployee = string.Join("|", m_Seats.OrderBy(x => x.text).Select(x => x.openEmployee).ToArray()); //account.payTime = now; account.payEmployee = LogIn.m_User.id.ToString(); account.macAddress = PCUtil.getMacAddr_Local(); if (m_promotion_Member != null) { account.promotionMemberId = m_promotion_Member.CI_CardNo; account.promotionAmount = m_discount_money; } if (m_Member_List != null) { account.memberId = string.Join("|", m_Member_List.Keys.ToArray()); } }
//在使用会员卡和优惠券结账时,发送消息给摄像头进行录像 public static bool sendMessageToCamera(DAO dao, string systemId) { string cmd_str = "insert into [PayMsg](systemId, ip) values('" + systemId + "','" + PCUtil.getLocalIp() + "')"; if (!dao.execute_command(cmd_str)) { return(false); } return(true); }
//宾客付款 private void payTool_Click(object sender, EventArgs e) { BathDBDataContext dc = new BathDBDataContext(LogIn.connectionString); HintForm hintForm = new HintForm("请插入会员卡..."); if (hintForm.ShowDialog() != DialogResult.OK) { return; } MemberCardUsingForm memberCardUsingForm = new MemberCardUsingForm(Convert.ToDouble(moneyPayable.Text)); if (memberCardUsingForm.ShowDialog() != DialogResult.OK) { return; } if (m_Member == null) { m_Member = memberCardUsingForm.m_member; } Account account = new Account(); account.text = m_Seat.text; account.systemId = m_Seat.systemId; account.openTime = m_Seat.openTime.ToString(); account.openEmployee = m_Seat.openEmployee; account.payTime = DateTime.Now; account.payEmployee = LogIn.m_User.id.ToString(); account.macAddress = PCUtil.getMacAddr_Local(); if (m_promotion_Member != null) { account.promotionMemberId = m_promotion_Member.CI_CardNo; account.promotionAmount = discount_money; } if (m_Member != null) { account.memberId = memberCardUsingForm.m_member.CI_CardNo; } account.creditCard = Convert.ToInt32(moneyPayable.Text); db.Account.InsertOnSubmit(account); db.SubmitChanges(); var orderList = db.Orders.Where(x => x.systemId == m_Seat.systemId && !x.paid); foreach (Orders order in orderList) { order.paid = true; order.accountId = account.id; } m_Seat.status = 3; var room = db.Room.FirstOrDefault(x => x.seat == m_Seat.text); if (room != null) { room.status = "等待清洁"; } insert_member_infor(account); db.SubmitChanges(); var act_old = dc.Account.FirstOrDefault(x => x.systemId == m_Seat.systemId && x.abandon != null); if (act_old == null) { printTool_Click("结账单"); printTool_Click("存根单"); } else { printTool_Click("补救单"); } var act = dc.Account.FirstOrDefault(x => x.systemId == m_Seat.systemId && x.abandon == null); }
//赠送卡 private void btn_free_Click(object sender, EventArgs e) { if (btnOk.Text == "读卡") { get_member(); } else if (btnOk.Text == "激活") { if (m_use_finder_pwd && m_finger == null) { if (BathClass.printAskMsg("系统指定需要使用指纹密码,是否确定放弃录入指纹?") != DialogResult.Yes) { return; } } if (tb_cash.Text.Trim() != "" || tb_bank.Text.Trim() != "") { BathClass.printErrorMsg("已经输入付款金额,请点击\"激活\"售卡激活!"); return; } string pars = "memberId"; string vals = "'" + m_member.CI_CardNo + "'"; pars += ",payEmployee"; vals += ",'" + LogIn.m_User.id + "'"; pars += ",payTime"; vals += ",getdate()"; pars += ",macAddress"; vals += ",'" + PCUtil.getMacAddr_Local() + "'"; if (balance.Text != "") { pars += ",balance"; vals += ",'" + balance.Text + "'"; } pars += ",note"; vals += ",'赠送卡'"; if (tb_seat.Text != "") { pars += ",seat"; vals += ",'" + tb_seat.Text + "'"; } string cmd_str = @"insert into [CardSale](" + pars + ") values(" + vals + ") "; if (m_finger == null || m_finger == "") { m_finger = "null"; } else { m_finger = "'" + m_finger + "'"; } cmd_str += @"update [CardInfo] set state='在用',CI_Password="******" where CI_CardNo='" + id.Text + "'"; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("赠送卡失败,请重试!"); return; } string seat = null; if (tb_seat.Text != "") { seat = tb_seat.Text; } PrintMemberActivateMsg.Print_DataGridView(id.Text, type.Text, balance.Text, LogIn.m_User.id, DateTime.Now.ToString("MM-dd HH:mm"), LogIn.options.companyName, null, seat); this.DialogResult = DialogResult.OK; } }
//确定 private void btnOk_Click(object sender, EventArgs e) { if (btnOk.Text == "读卡") { get_member(); } else if (btnOk.Text == "激活") { if (m_use_finder_pwd && m_finger == null) { if (BathClass.printAskMsg("系统指定需要使用指纹密码,是否确定放弃录入指纹?") != DialogResult.Yes) { return; } } var m_waiter = dao.get_Employee("id='" + tb_waiter.Text + "'"); if (m_waiter == null) { BathClass.printErrorMsg("输入服务员工号不存在!"); return; } if (tb_cash.Text.Trim() == "" && tb_bank.Text.Trim() == "") { BathClass.printErrorMsg("需要输入金额!"); return; } double card_val = find_card_value(MConvert <double> .ToTypeOrDefault(balance.Text, 0)); if (card_val != -1 && MConvert <double> .ToTypeOrDefault(tb_cash.Text, 0) + MConvert <double> .ToTypeOrDefault(tb_bank.Text, 0) < card_val) { BathClass.printErrorMsg("付款金额不足"); return; } string pars = ""; string vals = ""; pars = "memberId"; vals = "'" + m_member.CI_CardNo + "'"; pars += ",payEmployee"; vals += ",'" + m_waiter.id + "'"; pars += ",payTime"; vals += ",getdate()"; pars += ",macAddress"; vals += ",'" + PCUtil.getMacAddr_Local() + "'"; Dictionary <string, string> pay_info = new Dictionary <string, string>(); if (tb_bank.Text.Trim() != "") { pars += ",bankUnion"; vals += ",'" + tb_bank.Text + "'"; pay_info["银联"] = tb_bank.Text; } if (tb_cash.Text.Trim() != "") { pars += ",cash"; vals += ",'" + tb_cash.Text + "'"; pay_info["现金"] = tb_cash.Text; } if (balance.Text != "") { pars += ",balance"; vals += ",'" + balance.Text + "'"; } if (tb_seat.Text != "") { pars += ",seat"; vals += ",'" + tb_seat.Text + "'"; } string cmd_str = @"insert into [CardSale](" + pars + ") values(" + vals + ")"; if (m_finger == null || m_finger == "") { m_finger = "null"; } else { m_finger = "'" + m_finger + "'"; } cmd_str += @"update [CardInfo] set state='在用',CI_Password="******" where CI_CardNo='" + id.Text + "'"; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("会员激活失败,请重试!"); return; } string seat = null; if (tb_seat.Text != "") { seat = tb_seat.Text; } PrintMemberActivateMsg.Print_DataGridView(id.Text, type.Text, balance.Text, LogIn.m_User.id, DateTime.Now.ToString("MM-dd HH:mm"), LogIn.options.companyName, pay_info, seat); this.DialogResult = DialogResult.OK; } else if (btnOk.Text == "退卡") { if (BathClass.printAskMsg("确定退还卡号:" + m_member.CI_CardNo + "?") != DialogResult.Yes) { return; } if (dao.exist_instance("CardCharge", "CC_CardNo='" + m_member.CI_CardNo + "' and (CC_ItemExplain='会员刷卡' or CC_ItemExplain='会员打折')")) { BathClass.printErrorMsg("已有消费记录,不能退卡"); return; } string cmd_str = @" update cardSale set abandon='" + LogIn.m_User.id + "' where id in (select top 1 id from cardsale where memberId='" + id.Text + "' order by id desc)"; cmd_str += @"update [CardInfo] set state='入库' where CI_CardNo='" + id.Text + "'"; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("退卡失败,请重试!"); return; } this.DialogResult = DialogResult.OK; } }
//确定 private void btnOk_Click(object sender, EventArgs e) { if (btnOk.Text == "读卡") { get_member(); } else if (btnOk.Text == "充值") { string bank = tb_bank.Text.Trim(); string cash = tb_cash.Text.Trim(); string server = tb_server.Text.Trim(); if (cash == "" && bank == "" && server == "") { BathClass.printErrorMsg("需要输入充值金额"); return; } string serverEmployee = string.Empty; if (tb_server.Text.Trim() != "") { var form = new SignForFreeForm(); if (form.ShowDialog() != DialogResult.OK) { BathClass.printErrorMsg("需要输入赠送人姓名"); return; } serverEmployee = form.signature; } string pars = ""; string vals = ""; pars = "memberId"; vals = "'" + id.Text + "'"; if (balance.Text != "") { pars += ",balance"; vals += ",'" + balance.Text + "'"; } double money = 0; if (bank != "") { double b = Convert.ToDouble(bank); pars += ",bankUnion"; vals += ",'" + bank + "'"; money += b; } if (cash != "") { double c = Convert.ToDouble(cash); pars += ",cash"; vals += ",'" + cash + "'"; money += c; } if (server != "") { double s = Convert.ToDouble(server); pars += ",server"; vals += ",'" + server + "'"; money += s; pars += ",serverEmployee"; vals += ",'" + serverEmployee + "'"; } if (tb_seat.Text.Trim() != "") { pars += ",seat"; vals += ",'" + tb_seat.Text + "'"; } pars += ",macAddress"; vals += ",'" + PCUtil.getMacAddr_Local() + "'"; pars += ",explain"; vals += ",'会员充值'"; pars += ",payEmployee"; vals += ",'" + LogIn.m_User.id + "'"; pars += ",payTime"; vals += ",getdate()"; string cmd_str = @"insert into [CardSale](" + pars + ") values(" + vals + ") "; #region 会员充值 pars = "CC_CardNo"; vals = "'" + m_member.CI_CardNo + "'"; pars += ",CC_DebitSum"; vals += "," + money; pars += ",CC_ItemExplain"; vals += ",'会员卡充值-收'"; pars += ",CC_InputOperator"; vals += ",'" + LogIn.m_User.id + "'"; pars += ",CC_InputDate"; vals += ",getdate()"; if (m_Seat != null) { pars += ",systemId"; vals += ",'" + m_Seat.systemId + "'"; } cmd_str += @" insert into [CardCharge](" + pars + ") values(" + vals + ")"; #endregion #region 会员充值送 var sale_money = get_promotion_for_cardPop(money); if (sale_money != 0) { BathClass.printInformation("会员充值送" + sale_money.ToString()); pars = "CC_CardNo"; vals = "'" + m_member.CI_CardNo + "'"; pars += ",CC_DebitSum"; vals += "," + sale_money; pars += ",CC_ItemExplain"; vals += ",'会员卡充值-送'"; pars += ",CC_InputOperator"; vals += ",'" + LogIn.m_User.id + "'"; pars += ",CC_InputDate"; vals += ",getdate()"; if (m_Seat != null) { pars += ",systemId"; vals += ",'" + m_Seat.systemId + "'"; } cmd_str += @" insert into [CardCharge](" + pars + ") values(" + vals + ")"; } #endregion if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("会员充值失败,请重试!"); return; } Dictionary <string, string> pay_info = new Dictionary <string, string>(); if (bank != "") { pay_info["银联"] = bank; } if (cash != "") { pay_info["现金"] = cash; } if (server != "") { pay_info["招待"] = server + "$" + serverEmployee; } string bl = dao.get_member_balance(id.Text).ToString(); PrintMemberPopMsg.Print_DataGridView(id.Text, type.Text, bl, LogIn.m_User.id, DateTime.Now.ToString("MM-dd HH:mm"), LogIn.options.companyName, pay_info, tb_seat.Text); this.DialogResult = DialogResult.OK; this.Close(); } }