private void button_Manage_Click(object sender, EventArgs e) { if (!CheckInput()) return; VipSoft.BLL.CardLevel cardL = new VipSoft.BLL.CardLevel(); string needP = this.textBox_needpoint.Text; VipSoft.Model.CardLevel level = new VipSoft.Model.CardLevel(); level.LevelName=this.textBox_LevelName.Text; level.NeedPoint=int.Parse(needP); level.Point=int.Parse(this.textBox_Point.Text); level.Percent=decimal.Parse(this.textBox_Percent.Text); if (this.label_Flag.Text == "add") { if (cardL.Exists(this.textBox_LevelName.Text)) { MessageBox.Show("等级名称重复,请重新输入!"); this.textBox_LevelName.Text = ""; this.textBox_LevelName.Focus(); return; } cardL.Add(level); // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master,"会员等级管理", string.Format("新增会员等级(名称{0}:所需积分{1}:兑换比例{2}:折扣比例{3}:)", this.textBox_LevelName.Text, needP, this.textBox_Point.Text, this.textBox_Percent.Text), DateTime.Now)); // 提示 MessageBox.Show("新等级录入成功。"); // 文本框数据清空 this.textBox_LevelName.Text = ""; this.textBox_Percent.Text = ""; this.textBox_Point.Text = ""; this.textBox_needpoint.Text = ""; } // 编辑 else { level.ID = int.Parse(this.label_Flag.Text); cardL.Update(level); // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master,"会员等级管理", string.Format("编辑会员等级(ID:{0}名称:{1}所需积分:{2}兑换比例:{3}折扣比例:{4})", this.label_Flag.Text, this.textBox_LevelName.Text, needP, this.textBox_Point.Text, this.textBox_Percent.Text), DateTime.Now)); // 提示 MessageBox.Show("等级修改成功。"); } // 绑定数据 BindList(); }
private void button_Delete_Click(object sender, EventArgs e) { if (this.dataGridView_List.SelectedRows.Count != 1) { MessageBox.Show("删除记录,请先选择需要删除的行。"); return; } VipSoft.BLL.CardLevel level = new VipSoft.BLL.CardLevel(); DataGridViewRow row = this.dataGridView_List.SelectedRows[0]; string ID = row.Cells["ID"].Value.ToString(); DataTable lst = level.GetListC(int.Parse(ID)); if (lst.Rows.Count > 0) { MessageBox.Show("对不起,当前等级已有会员信息,不能删除此等级!"); return; } else { DialogResult res = MessageBox.Show("确定要删除当前等级么?删除可能会影响到该等级会员卡的使用。", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (res.ToString() == "OK") { level.Delete(int.Parse(row.Cells["ID"].Value.ToString())); // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master,"会员等级管理", string.Format("删除会员等级(ID:{0}名称:{1}所需积分:{2}兑换比例:{3}折扣比例:{4})", row.Cells["ID"].Value.ToString(), row.Cells["LevelName"].Value.ToString(), row.Cells["NeedPoint"].Value.ToString(), row.Cells["Point"].Value.ToString(), row.Cells["Percent"].Value.ToString()),DateTime.Now)); // 提示 MessageBox.Show("数据已成功删除。"); // 重新绑定 BindList(); } } }
private void button_Add_Click(object sender, EventArgs e) { VipSoft.BLL.GoodsClass gc = new VipSoft.BLL.GoodsClass(); if (this.textBox_ClassName.Text == "新类别" || this.textBox_ClassName.Text == "") { MessageBox.Show("请输入分类名称。"); return; } if (this.label_ID.Text == "label_ID" && this.label_ParentID.Text == "label_ParentID") { MessageBox.Show("请先在左侧列表中选择对应操作!"); return; } if (this.button_Add.Text == "增加分类") { if (this.label_ParentID.Text == "") { MessageBox.Show("请先在左侧列表中选择对应操作!"); return; } VipSoft.Model.GoodsClass model = new Model.GoodsClass(); model.ClassName = this.textBox_ClassName.Text; model.ParentID = int.Parse(this.label_ParentID.Text); model.ShopID = PublicState.Master.ShopID; model.ShopName = PublicState.Master.ShopName; gc.Add(model); // 写入日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理", string.Format("增加分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text), DateTime.Now)); // 文本框清空 this.label_ID.Text = ""; this.label_ParentID.Text = ""; this.textBox_Parent.Text = ""; this.textBox_ClassName.Text = ""; } else { VipSoft.Model.GoodsClass gci = new VipSoft.Model.GoodsClass(); gci.ClassName = this.textBox_ClassName.Text.Trim(); gci.ID = int.Parse(this.label_ID.Text); gc.Update(gci); // 写入日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理", string.Format("修改分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text), DateTime.Now)); } // 重新绑定 BindClass(); }
//删除会员操作 private void delMem() { //那个选择的条数不是1条时返回 if (this.dataGridView_List.SelectedRows.Count != 1) return; //得到所选记录的主键 int memId = int.Parse(this.dataGridView_List.SelectedRows[0].Cells["ID"].Value.ToString()); string memCardId = this.dataGridView_List.SelectedRows[0].Cells["cardId"].Value.ToString(); string memName = this.dataGridView_List.SelectedRows[0].Cells["MemName"].Value.ToString(); DialogResult dRes = MessageBox.Show("您确定要删除此会员么?此操作不可恢复。", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dRes == DialogResult.No) return; VipSoft.BLL.MemCard mCard = new VipSoft.BLL.MemCard(); //查询该会员的记录,用于记录操作日志 VipSoft.Model.MemCard memModel = mCard.GetModel(memId); if (mCard.Delete(memId)) { // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "会员管理", string.Format("删除会员,ID:{0}会员卡号:{1} 名称:{2}", memId.ToString(), memModel.CardID, memModel.Name), DateTime.Now)); // 提示 MessageBox.Show("会员已被删除。"); // 重新绑定 BindList(); } }
private void toolStripMenuItem_Item_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; TreeNode node = this.treeView_Class.SelectedNode; int id = int.Parse(node.Name.Replace("class_", "")); switch (item.Name) { case "toolStripMenuItem_Edit": this.label_ID.Text = node.Name.Replace("class_", ""); this.textBox_Parent.Text = node.Parent != null ? node.Parent.Text : "根类别"; this.textBox_ClassName.Text = node.Text; this.button_Add.Text = "修改类别"; this.groupBox_manage.Text = "修改类别"; break; case "toolStripMenuItem_Delete": if (this.treeView_Class.SelectedNode.Text == "根类别") return; DialogResult res = MessageBox.Show("您确定要删除这个分类么?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (res == DialogResult.Yes) { VipSoft.BLL.GoodsClass gc = new VipSoft.BLL.GoodsClass(); DataTable listClass = gc.GetList("[ShopID]="+PublicState.Master.ShopID).Tables[0]; CheckHasGoods hasGoods = new CheckHasGoods(); if (hasGoods.Exist(listClass, id.ToString()) != 0) { MessageBox.Show("当前分类下面还有商品,要删除分类,请首先删除该分类下面的全部商品。"); return; } if (gc.Delete(id)) { MessageBox.Show("分类删除成功。"); // 移除节点 node.Remove(); // 写入日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理", string.Format("删除分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text), DateTime.Now)); } else MessageBox.Show("删除失败,请重试。"); } break; case "toolStripMenuItem_Add": this.label_ParentID.Text = id.ToString(); //查询该类别下是否有产品,如果有则不能再增加子类别 DataSet ds = new VipSoft.BLL.Goods().GetList("ClassId=" + id + ""); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("该类别下已有产品!不能再添加子类别"); return; } this.textBox_Parent.Text = node.Text; this.textBox_ClassName.Text = "新类别"; this.button_Add.Text = "增加分类"; this.groupBox_manage.Text = "增加下级分类"; break; } }
private void Button_Save_Click(object sender, EventArgs e) { totalPoint = 0; if (memInfo == null) { MessageBox.Show("您必须先选择会员!"); return; } exchangList = new List<VipSoft.Model.ExchangeLog>(); foreach (DataGridViewRow row in this.dataGridView_List.Rows) { Model.ExchangeLog info; Model.Gift gift; if (row.Cells[0].Value != null && bool.Parse(row.Cells[0].Value.ToString())) { int id = int.Parse(row.Cells["Column_ID"].Value.ToString()); string code = row.Cells["Column_Code"].Value.ToString(); string name = row.Cells["Column_Name"].Value.ToString(); int point = int.Parse(row.Cells["Column_Point"].Value.ToString()); int number = 1; try { number = int.Parse(row.Cells["Column_ENum"].Value.ToString()); } catch { MessageBox.Show("请输入正确的兑换数量!"); return; } if (number > int.Parse(row.Cells["Column_Number"].Value.ToString())) { MessageBox.Show("兑换数量超出礼品剩余数量!"); return; } gift = new Model.Gift(); gift.GiftCode=code; gift.Name=name; gift.Photo=""; gift.Point=point; gift.Number=number; gift.ID = id; info = new Model.ExchangeLog(); info.MemID=memInfo.ID; info.CardID=memInfo.CardID; info.Name=memInfo.Name; info.Number=number; info.Point = point * number; info.GiftID=id; info.GiftName=name; info.GiftCode=code; info.MasterID=PublicState.Master.ID; info.MasterName=PublicState.Master.Name; info.ShopID=PublicState.Master.ShopID; info.ShopName=PublicState.Master.ShopName; exchangList.Add(info); } } if (exchangList.Count == 0) { MessageBox.Show("请先选择需要兑换的礼品!"); return; } if (totalPoint > memInfo.Point) { MessageBox.Show("对不起,此会员账户积分不足!"); return; } if (new VipSoft.BLL.ExchangeLog().Add(exchangList)) { // 日志记录 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new Model.SysLog(PublicState.Master, "积分兑换", "积分兑换产品成功,会员卡号:" + memInfo.CardID + "姓名:" + memInfo.Name, DateTime.Now)); // 发送系统短信 memInfo = new BLL.MemCard().GetModel(memInfo.ID); Function.UpdateMemberLevel(2, memInfo);//兑换登记时候自动重新计算 // 提示 MessageBox.Show("兑换成功。"); // 界面 memInfo = null; this.label_M_Money.Text = ""; this.label_M_Name.Text = ""; this.label_M_Point.Text = ""; this.label_M_TotalMoney.Text = ""; this.searchMember1.CardID = ""; BindList(); } }
// 删除记录 private void DeleteItem() { if (this.dataGridView_List.SelectedRows.Count != 1) return; int goodsID = int.Parse(this.dataGridView_List.SelectedRows[0].Cells[1].Value.ToString()); string goodsCode = this.dataGridView_List.SelectedRows[0].Cells[2].Value.ToString(); string goodsName = this.dataGridView_List.SelectedRows[0].Cells[3].Value.ToString(); DialogResult dRes = MessageBox.Show("您确定要删除此产品么?此操作不可恢复。注意:删除后此产品相关的消费数据统计会出现错乱", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dRes == DialogResult.No) return; VipSoft.BLL.Goods goods = new VipSoft.BLL.Goods(); VipSoft.Model.Goods ginfo = goods.GetModel(goodsID); if (goods.Delete(goodsID)) { // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品管理", string.Format("删除产品,ID:{0}编号:{1}名称:{2}库存:{3}销售量:{4}售价:{5}积分:{6}最低折扣:{7}", goodsID.ToString(), goodsCode, goodsName, ginfo.Number, ginfo.SaleNumber, ginfo.Price, ginfo.Point, ginfo.MinPercent), DateTime.Now)); // 提示 MessageBox.Show("产品已被删除。"); // 重新绑定 BindList(); } }
private void button_Save_Click(object sender, EventArgs e) { if (!CheckInput()) return; VipSoft.BLL.Goods bllGoods = new BLL.Goods(); VipSoft.Model.Goods model = new Model.Goods(); model.GoodsCode=this.textBox_GoodsCode.Text.Trim(); model.Name = this.textBox_GoodsName.Text.Trim(); model.NameCode = this.textBox_NameCode.Text.Trim(); model.ClassID = int.Parse(this.comboBox_Class.SelectedValue.ToString()); model.Unit = this.comboBox_Unit.Text == null ? this.comboBox_Unit.SelectedItem.ToString() : this.comboBox_Unit.Text; model.Number = int.Parse(this.textBox_Number.Text); model.Point = int.Parse(this.textBox_Point.Text); model.Price = decimal.Parse(this.textBox_Price.Text.Replace("¥", "")); model.BuyPrice = decimal.Parse(this.myMoneyTextBox1.Text.Replace("¥", "")); model.MinPercent = decimal.Parse(this.textBox_MinPercent.Text); model.PointType = int.Parse(this.rdoIsPoint.Checked ? "1" : "0"); model.GoodsType = this.checkBox_GoodsType.Checked?(byte)0:(byte)1; model.ShopID = PublicState.Master.ShopID; model.ShopName = PublicState.Master.ShopName; if (CurrentGoodsID == 0) { if (bllGoods.Exists(this.textBox_GoodsCode.Text.Trim())) { MessageBox.Show("编号为" + this.textBox_GoodsCode.Text + "的产品或服务已经存在,请重新输入编号或增加其他的产品。"); this.textBox_GoodsCode.Focus(); this.textBox_GoodsCode.SelectAll(); } if (bllGoods.Add(model) > 0) { // 加入日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品入库", string.Format("产品添加,编号:{0}名称:{1}数量:{2}", model.GoodsCode, this.textBox_GoodsName.Text, this.textBox_Number.Text), DateTime.Now)); // 提示 MessageBox.Show("产品添加成功。"); // 刷新 if (GoodsListRefresh != null) GoodsListRefresh(); } else { MessageBox.Show("产品添加失败,请重试。"); return; } } else { model.ID = CurrentGoodsID; if (bllGoods.Update(model)) { // 日志记录 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品信息修改", "修改产品信息(编号:" + this.textBox_GoodsCode.Text + " 名称:" + this.textBox_GoodsName.Text + ")", DateTime.Now)); // 提示 MessageBox.Show("产品信息修改成功。"); // 刷新 if (GoodsListRefresh != null) GoodsListRefresh(); } else { MessageBox.Show("产品信息修改失败,请重试。"); return; } } // 窗口处理 if (this.checkBox_save.Checked) { this.checkBox_AutoCode.Checked = false; this.textBox_GoodsCode.Text = ""; this.textBox_GoodsName.Text = ""; this.textBox_Number.Text = "0"; this.textBox_Point.Text = "0"; this.textBox_MinPercent.Text = "0"; this.textBox_Price.Text = "¥0.00"; this.myMoneyTextBox1.Text = "¥0.00"; this.textBox_MinPercent.Text = "0"; } else this.Close(); }
// 确认结算时 // 订单表中插入记录、订单详细表、账户金额积分处理 // 系统日志 void exp_ExpenseResultSelected(OrderPayType expType, decimal payMoney, decimal payCard, decimal payCash, decimal payCredit, decimal payVoucher, decimal moneyZero) { string orderCode = CreateOrderCode(); payInfo = payCard + "|" + payCash + "|" + payCredit + "|" + payVoucher; // 如果修改了金额,积分需要重新计算一下的 int point = totalPoint; List<VipSoft.Model.OrderDetail> ListDetail = new List<VipSoft.Model.OrderDetail>(); VipSoft.Model.OrderDetail detail; foreach (TempOrderInfo temp in listOrder) { detail = new VipSoft.Model.OrderDetail(); detail.OrderCode=orderCode; detail.GoodsID=temp.GInfo.ID; detail.GoodsCode=temp.GInfo.GoodsCode; detail.GoodsName=temp.GInfo.Name; detail.OrderCode=orderCode; detail.Number=temp.Number; detail.Percent=temp.Discount; detail.IsService=temp.GInfo.GoodsType==(byte)0?true:false; detail.Price=temp.GInfo.Price; detail.DiscountPrice=temp.DiscountPrice; ListDetail.Add(detail); } VipSoft.BLL.OrderLog oLog = new VipSoft.BLL.OrderLog(); bool ok; string logStrType, logStrOk, logStrErr; if (IsTravelerMember) { order = new Model.OrderLog(); order.OrderCode = orderCode; order.OrderType = 0; order.MemID = 59; order.MemName = "散客消费"; order.CardID = "0"; order.CreateDateTime = DateTime.Now; order.DisCountMoney = discountPrice; order.MasterID = PublicState.Master.ID; order.MasterName = PublicState.Master.Name; order.PayInfo = payInfo; order.PayType = (int)expType; order.Point = totalPoint; order.ShopID = PublicState.Master.ShopID; order.ShopName = PublicState.Master.ShopName; order.TotalMoney = totalPrice; order.TotalNumber = totalNumber; ok = oLog.Add(order, ListDetail); logStrType = "散客消费"; logStrOk = string.Format("消费成功,订单号:{0}消费金额:{1}", order.OrderCode, order.DisCountMoney); logStrErr = string.Format("消费失败,消费金额:{0}", order.DisCountMoney); } else { order = new Model.OrderLog(); order.OrderCode = orderCode; order.OrderType = 0; order.MemID = memInfo.ID; order.MemName = memInfo.Name; order.CardID = memInfo.CardID; order.CreateDateTime = DateTime.Now; order.DisCountMoney = discountPrice; order.MasterID = PublicState.Master.ID; order.MasterName = PublicState.Master.Name; order.PayInfo = payInfo; order.PayType = (int)expType; order.Point = totalPoint; order.TotalMoney = totalPrice; order.TotalNumber = totalNumber; order.ShopID = PublicState.Master.ShopID; order.ShopName = PublicState.Master.ShopName; ok = oLog.Add(order, ListDetail); if (ok) { VipSoft.BLL.MemCard bllMemCard = new BLL.MemCard(); VipSoft.BLL.PointLog bllPointLog = new BLL.PointLog(); memInfo.Point += totalPoint; memInfo.TotalMoney += discountPrice; memInfo.LastTime = DateTime.Now; memInfo.Money -= payCard; bllMemCard.Update(memInfo); memInfo = bllMemCard.GetModel(memInfo.ID); VipSoft.Model.PointLog modelPointLog = new Model.PointLog(); modelPointLog.CardID = memInfo.CardID; modelPointLog.CreateDateTime = DateTime.Now; modelPointLog.MemName = memInfo.Name; modelPointLog.Point = totalPoint; modelPointLog.ShopID = PublicState.Master.ShopID; modelPointLog.ShopName = PublicState.Master.ShopName; modelPointLog.Type = (int)PointLogType.OrderPoint; bllPointLog.Add(modelPointLog); } logStrType = "会员消费"; logStrOk = string.Format("消费成功,订单号:{0}会员卡号:{1}姓名:{2}消费金额:{3}所得积分:{4}付费方式:{5}", order.OrderCode, order.CardID, order.MemName, order.DisCountMoney, order.Point, order.PayType.ToString()); logStrErr = string.Format("消费失败,会员卡号:{0}姓名:{1}消费金额:{2}所得积分:{3}付费方式:{4}", order.CardID, order.MemName, order.DisCountMoney, order.Point, order.PayType.ToString()); } if (ok) { VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, logStrType, logStrOk, DateTime.Now)); // 更新当前会员的财务信息,因为打印的时候和更新等级的时候都需要显示出来 if (!IsTravelerMember) { memInfo = new VipSoft.BLL.MemCard().GetModel(memInfo.ID); Function.UpdateMemberLevel(1, memInfo); } MessageBox.Show("消费成功。"); // 清除数据 this.label_OTMoney.Text = ""; this.label_OTMoney2.Text = ""; this.label_OTNumber.Text = ""; this.label_OTPoint.Text = ""; this.label_OTActivity.Text = ""; listOrder = new List<TempOrderInfo>(); order = null; this.dataGridView_List.Rows.Clear(); ClearFormText(); memInfo = null; } else { MessageBox.Show("系统错误导致消费失败,请重试。"); // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, logStrType, logStrErr, DateTime.Now)); } }