private void btnSave_Click(object sender, EventArgs e) { String msg = null; if (String.IsNullOrEmpty(this.txtPrice.Text.Trim())) { msg = "请填写交易金额"; } else if (this.cmbGoods.SelectedItem == null) { msg = "请选择商品信息"; } else if (String.IsNullOrEmpty(this.txtSummary.Text.Trim())) { msg = "请填写交易描述"; } if (msg != null) { MessageBox.Show(msg, "数据不完整", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Models.SaleLog log = new SaleLog(); log.CreatedAt = Tools.TimeStamp.ConvertDateTimeInt(DateTime.Now); log.GoodsId = Convert.ToInt32(this.cmbGoods.SelectedValue); log.Money = Convert.ToDecimal(this.txtPrice.Text.Trim()); log.Summary = this.txtSummary.Text.Trim(); bll.AddLog(log); }
private void btnSubmit_Click(object sender, System.EventArgs e) { if (String.IsNullOrEmpty(this.txtMoney.Text.Trim())) { MessageBox.Show("请先选择充值次数及金额!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (this.card.Record == null || this.card.Record.Status == Status.Disabled) { this.card.Record = new MemberCardRecord(); this.card.Record.MemberCardId = this.card.Id; this.card.Record.CreatedAt = TimeStamp.GetNowTimeStamp(); } MemberCardCategoryValue cat = this.cmbMoney.SelectedItem as MemberCardCategoryValue; this.card.Record.Balance += cat.ValueNum; this.card.Record.BeginAt = TimeStamp.ConvertDateTimeInt(DateTime.Now.Date); this.card.Record.ExpiredAt = TimeStamp.ConvertDateTimeInt(this.validTime.Value.Date.AddHours(23)); if (this.card.Record.Id > 0 ? recordBll.EditMemberCardRecord(this.card.Record) : recordBll.AddMemberCardRecord(this.card.Record)) { SaleLog log = new SaleLog(); log.CreatedAt = TimeStamp.ConvertDateTimeInt(DateTime.Now); log.MemberId = this.card.Id; log.MemberNo = this.card.CardNo; log.GoodsId = cat.GoodsId; log.Money = Convert.ToDecimal(this.txtMoney.Text.Trim()); log.Summary = String.Format("卡号:{0}在{1}充值{2}元", this.card.CardNo, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), cat.Money); saleBll.AddLog(log); Callback(log.Summary); this.labMoney.Text = String.Format("帐户剩余次数:{0}次", this.card.Record.Balance.ToString()); } this.btnSubmit.Enabled = false; this.validTime.Visible = false; this.labTip.Visible = false; this.card = null; this.cmbMoney.DataSource = null; this.txtMoney.Clear(); MessageBox.Show("充值成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// 添加交易记录 /// </summary> private void AddRecord() { if (card.Record.Balance <= 0) { this.setLabelStatus("此卡次数不足,请充值后再试!", Color.Red, "AudioCardArrearage"); return; } this.btnSearch.Enabled = false; this.btnSubmit.Enabled = false; this.numValue.Enabled = false; Decimal num = this.numValue.Value; for (int i = 0; i < num; i++) { SaleLog log = new SaleLog(); log.CreatedAt = TimeStamp.GetNowTimeStamp(); log.Money = 0; log.GoodsId = Convert.ToInt32(ConfigurationManager.AppSettings["RecordGoodsID"]); log.MemberNo = this.card.CardNo; log.Summary = String.Format("卡号:{0}({1})在{2}进行了一笔消费", this.labNo.Text.Trim(), this.labType.Text.Trim(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); logBll.AddLog(log); } this.AddRecordToDataGridView(String.Format("卡号:{0}({1})在{2}进行了{3}笔消费", this.labNo.Text.Trim(), this.labType.Text.Trim(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToInt32(num))); this.card.Record.Balance -= num; recordBll.EditMemberCardRecord(this.card.Record); this.btnSearch.Enabled = true; this.btnSubmit.Enabled = true; this.numValue.Enabled = true; this.numValue.Maximum = this.card.Record.Balance; this.numValue.Value = this.numValue.Value > this.numValue.Maximum ? this.numValue.Maximum : this.numValue.Value; if (!this.timer.Enabled) { this.timer.Interval = 1000 * 20; this.timer.Start(); } }
private void btnSubmit_Click(object sender, System.EventArgs e) { String msg = null; if (String.IsNullOrEmpty(this.txtFee.Text.Trim())) { msg = "请填写销售金额!"; } else if (Convert.ToDecimal(this.txtFee.Text.Trim()) < 1) { msg = "销售金额必须大于0元!"; } if (!String.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "保存失败", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SaleLog log = new SaleLog(); log.CreatedAt = TimeStamp.GetNowTimeStamp(); log.Money = Convert.ToDecimal(this.txtFee.Text.Trim()); log.GoodsId = this.goods.Id; log.MemberNo = ""; log.Summary = String.Format("{0}出售了{1}元的{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), this.txtFee.Text.Trim(), this.goods.Name); ISaleLogBLL logBll = BllFactory.GetSaleLogBll(); if (!logBll.AddLog(log)) { MessageBox.Show("商品销售记录失败!", "保存失败", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } callback(log.Summary); this.Close(); }
private void synData() { if (isSyn) { return; } isSyn = true; if (bll == null) { bll = BLLLoader.GetSaleLogBll(); } IniFile ini = new IniFile(Application.StartupPath + "/" + "syn.ini"); String last_id = ini.IniReadValue("data", "LastID"); int lastId = String.IsNullOrEmpty(last_id) ? 0 : Convert.ToInt32(last_id); //生成文件名 DateTime now = DateTime.Now; String fileName = String.Format("{0}/runtime/logs/{1}/{2}/{3}.log", Application.StartupPath, now.Year, now.Month, now.Day); //获取数据 List <SaleLog> logs = bll.GetSaleLogsByLastId(lastId); FileTools.Writer(fileName, String.Format("[{0}]本次共加载数据 {1} 条", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), logs.Count)); for (int i = 0; i < logs.Count; i++) { switch (logs[i].GoodsId) { case 0: logs[i].GoodsId = 24; break; case -1: logs[i].GoodsId = 18; break; case -2: logs[i].GoodsId = 19; break; case -3: switch (Convert.ToInt32(logs[i].Remark)) { case 6: logs[i].GoodsId = 21; break; case 7: logs[i].GoodsId = 22; break; case 8: logs[i].GoodsId = 23; break; } break; } } if (logs.Count < 1) { return; } //添加至Mysql String result = "失败"; if (bll.AddLog(logs)) { ini.IniWriteValue("data", "LastID", logs[logs.Count - 1].Id.ToString()); result = "成功"; } //FileTools.Writer(fileName, String.Format("[{0}]同步ID为 {1} 的数据结果为:{2}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), log.Id, result)); isSyn = false; }