Пример #1
0
        protected void btnJiezhang_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lbCardID.Text.Trim() == "")
                {
                    Common.ShowMsg("请刷卡!");
                    return;
                }
                if (this.lbAccount.Text.Trim() == "")
                {
                    Common.ShowMsg("账户错误!");
                    return;
                }
                double dAccount = Convert.ToDouble(this.lbAccount.Text.Trim());

                dAccount -= Convert.ToDouble(this.txtSumMoney.Text.Trim());
                if (dAccount < 0)
                {
                    Common.ShowMsg("余额不足,购买失败!");
                    return;
                }
                string strSql = "update Mem_Card set Account = '" + dAccount + "'  where cardid = '" + this.lbCardID.Text.Trim() + "'";


                DBManager db = DBManager.Instance();
                int       i  = 0;
                db.Transact(strSql, out i);
                if (i > 0)
                {
                    Common.ShowMsg("结账完成!");
                    //记录操作员操作
                    //RecordOperate.SaveRecord(Session["UserID"].ToString(), "会员消费", "卡号【" + this.txtCardID2.Text + "】消费" + this.txtSumMoney.Text + "元");


                    dtGoods = ViewState["dtGoods"] as DataTable;
                    DataTable dt1 = dtGoods;
                    for (int j = 0; j < this.dtGoods.Rows.Count; j++)
                    {
                        MemCardLevelOperate.SaveRecord(Session["UserId"].ToString(), this.lbCardID.Text.Trim(), "消费", "买商品【" + dtGoods.Rows[j]["GoodsName"].ToString() + "】数量:" + dtGoods.Rows[j]["Count"].ToString(), Convert.ToDouble(dtGoods.Rows[j]["Money"].ToString()), 0);
                    }
                    var user = new[] { lbCardID.Text, lbUserName.Text, txtSumMoney.Text, lbAccount.Text };
                    this.lbAccount.Text    = "";
                    this.txtCardID2.Text   = "";
                    this.txtPwd2.Text      = "";
                    this.txtSumMoney.Text  = "";
                    this.lbUserName.Text   = "";
                    this.txtSum.Text       = "";
                    this.txtGoodsCode.Text = "";
                    this.lbCardID.Text     = "";
                    DataTable dt = new DataTable();
                    dt.Columns.Add("idno");
                    dt.Columns.Add("GoodsCode");
                    dt.Columns.Add("GoodsName");
                    dt.Columns.Add("Price");
                    dt.Columns.Add("Count");
                    dt.Columns.Add("Money");
                    ViewState["dtGoods"] = dt;
                    BindDataGrid();

                    this.txtCardID2.Enabled = true;
                    SetFocus("txtCardID2");
                    //StringBuilder sb = new StringBuilder();
                    //sb.Append("           美奥口腔  \n");
                    //sb.Append("*************************************\n");
                    //sb.Append("会员卡号:" + user[0] + "\n");
                    //sb.Append("会员名称:" + user[1] + "\n");
                    //sb.Append("项目" + "\t\t" + "数量" + "\t" + "单价" + "\t" + "小计" + "\n");
                    //for (int j = 0; j < dt1.Rows.Count; j++)
                    //{
                    //    sb.Append(dt1.Rows[j]["GoodsName"].ToString() + "\t" + dt1.Rows[j]["Count"].ToString() + "\t" + Convert.ToDouble(dt1.Rows[j]["Money"].ToString()) + "\t" + Convert.ToDouble(dt1.Rows[j]["Money"].ToString()) + "\n");
                    //}
                    //sb.Append("总计消费:\t\t\t" + user[2] + "\n");
                    //sb.Append("当前余额:\t\t\t" + (Convert.ToDecimal(user[3]) - Convert.ToDecimal(user[2])) + "\n");

                    //sb.Append("\n消费人\n\n");
                    //sb.Append("*************************************\n");
                    //sb.Append("     谢谢惠顾欢迎下次光临  ");

                    //Print(sb.ToString());
                }
                else
                {
                    Common.ShowMsg("结账失败!");
                }
            }
            catch (Exception ex)
            {
                Common.ShowMsg("未知异常!");
            }
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strCardId = this.lbCardID.Text.ToString();

            string strMoney = this.txtMoney.Text.ToString();
            string dir      = this.ddlOperate.SelectedValue.ToString();


            if (strCardId == "")
            {
                UtilLib.Common.ShowMsg("请先查询卡号!");
                this.txtCardID2.Focus();
                return;
            }

            if (strMoney == "")
            {
                Common.ShowMsg("请输入金额!");
                this.txtMoney.Focus();
                return;
            }

            double money = 0.00;

            if (!Double.TryParse(strMoney, out money))
            {
                Common.ShowMsg("金额输入不合法!");
                this.txtMoney.Focus();
                return;
            }
            if (dir == "2")
            {
                money = -money;
            }
            Member   m   = new Member();
            MemberDB mem = m.FindMemByCardId(strCardId);

            if (mem == null)
            {
                Common.ShowMsg("用户不存在!");
                return;
            }
            if (mem.Status == 0)
            {
                Common.ShowMsg("会员卡尚未激活!请与系统管理员联系");
                return;
            }
            string msg = "";

            m.UpdateMoney(strCardId, money, "充值", out msg);
            Common.ShowMsg(msg);

            //RecordOperate.SaveRecord(Session["UserID"].ToString(), "会员卡充值", "充值卡号:" + strCardId + ";充值金额:" + money);
            if (dir == "1")
            {
                MemCardLevelOperate.SaveRecord(Session["UserId"].ToString(), strCardId, "充值", "充值 " + strMoney + " 元", money, 1);
            }
            else if (dir == "2")
            {
                MemCardLevelOperate.SaveRecord(Session["UserId"].ToString(), strCardId, "扣除", "扣除" + strMoney + " 元", money, 1);
            }


            this.lbAccount.Text  = "";
            this.txtCardID2.Text = "";

            this.lbUserName.Text = "";

            //this.txtCardID2.Enabled = true;

            this.lbCardID.Text = "";
            this.txtMoney.Text = "";
        }
Пример #3
0
        protected void btnJiezhang_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lbCardID.Text.Trim() == "")
                {
                    Common.ShowMsg("请刷卡!");
                    return;
                }
                if (this.lbAccount.Text.Trim() == "")
                {
                    Common.ShowMsg("账户错误!");
                    return;
                }
                double dAccount = Convert.ToDouble(this.lbAccount.Text.Trim());

                dAccount -= Convert.ToDouble(this.txtSumMoney.Text.Trim());
                if (dAccount < 0)
                {
                    Common.ShowMsg("余额不足,购买失败!");
                    return;
                }
                string strSql = "update Mem_Card set Account = '" + dAccount + "'  where cardid = '" + this.lbCardID.Text.Trim() + "'";


                DBManager db = DBManager.Instance();
                int       i  = 0;
                db.Transact(strSql, out i);
                if (i > 0)
                {
                    Common.ShowMsg("结账完成!");
                    //记录操作员操作
                    //RecordOperate.SaveRecord(Session["UserID"].ToString(), "会员消费", "卡号【" + this.txtCardID2.Text + "】消费" + this.txtSumMoney.Text + "元");


                    dtGoods = ViewState["dtGoods"] as DataTable;
                    for (int j = 0; j < this.dtGoods.Rows.Count; j++)
                    {
                        MemCardLevelOperate.SaveRecord(Session["UserId"].ToString(), this.lbCardID.Text.Trim(), "消费", "买商品【" + dtGoods.Rows[j]["GoodsName"].ToString() + "】数量:" + dtGoods.Rows[j]["Count"].ToString(), Convert.ToDouble(dtGoods.Rows[j]["Money"].ToString()), 0);
                    }
                    this.lbAccount.Text    = "";
                    this.txtCardID2.Text   = "";
                    this.txtPwd2.Text      = "";
                    this.txtSumMoney.Text  = "";
                    this.lbUserName.Text   = "";
                    this.txtSum.Text       = "";
                    this.txtGoodsCode.Text = "";
                    this.lbCardID.Text     = "";
                    DataTable dt = new DataTable();
                    dt.Columns.Add("idno");
                    dt.Columns.Add("GoodsCode");
                    dt.Columns.Add("GoodsName");
                    dt.Columns.Add("Price");
                    dt.Columns.Add("Count");
                    dt.Columns.Add("Money");
                    ViewState["dtGoods"] = dt;
                    BindDataGrid();

                    this.txtCardID2.Enabled = true;
                    SetFocus("txtCardID2");
                }
                else
                {
                    Common.ShowMsg("结账失败!");
                }
            }
            catch (Exception ex)
            {
                Common.ShowMsg("未知异常!");
            }
        }