Exemplo n.º 1
0
 public CashTimeSharing(Customer customer, TariffInfo ti)
 {
     this.customer = customer;
     this.ti       = ti;
 }
Exemplo n.º 2
0
        private void jz()//结账
        {
            TariffInfo ti = new TariffInfo(ismember());
            //TariffInfo highti = new TariffInfo(ismember());

            string commstr = "select begdatetime from card_consumption where cardid='" + CardNo + "' and begdatetime>='" + start_date.ToString() + "' and enddatetime is null";

            begdatetime = Convert.ToDateTime(db.ExecuteScalar(commstr));
            enddatetime = DateTime.Now;
            double xf_money = 0.0;

            commstr = "select isnull(sum(xf_point),0) from card_consumption where cardid='" + CardNo + "'and enddatetime>='" + DateTime.Now.Date + "' group by cardid";
            int pay_already = Convert.ToInt16(db.ExecuteScalar(commstr));


            CashSuper cs;

            if (ti.key_hour.IndexOf(-1) < 0)
            {
                cs       = new CashTimeSharing(this, ti);
                xf_money = cs.Cacl();
            }
            else
            {
                cs       = new CashNormal(begdatetime, enddatetime, ti.cph[0], ti.max_money[0], ti.min_money[0]);
                xf_money = cs.Cacl();
            }

            //if (DateTime.Now.Hour < ti.key_hour[0])
            //{
            //    CashTimeSharing cts = new CashTimeSharing(this, ti);
            //    xf_money = Math.Round(cts.Cacl());
            //}
            //else
            //{


            //    if (!ismember())
            //    {
            //        highti.cph = 8;
            //        highti.min_money = 16;
            //    }
            //    if (begdatetime.Hour >= 17)
            //    {
            //        CashTimeSharing cts = new CashTimeSharing(this, highti);
            //        xf_money = Math.Round(cts.Cacl());
            //    }
            //    else
            //    {

            //        CashTimeSharing cts = new CashTimeSharing(this,ti,highti);
            //        xf_money = Math.Round(cts.Cacl());
            //    }
            //}



            string filed = "xf_money";

            if (ismember())
            {
                filed    = "xf_point";
                xf_money = (xf_money + pay_already) > cs.maxMoney ? cs.maxMoney - pay_already : xf_money;
            }
            else
            {
                if (xf_money < cs.minMoney)
                {
                    xf_money = cs.minMoney;
                }
            }

            commstr = "select top 1 ball_number from card_consumption where cardid='" + CardNo + "' order by enddatetime desc";
            string ball_number = db.ExecuteScalar(commstr).ToString();//所借球号

            string mes = "本次消费" + xf_money.ToString() + "元";

            if (ball_number != "")
            {
                mes = mes + "\n\n" + "应归还" + ball_number + "号球";
            }
            mes = mes + "\n\n是否要结账?";
            if (MessageBox.Show(mes, "结账卡提醒", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string sql = "update card_consumption set enddatetime='" + DateTime.Now + "'," + filed + "='" + xf_money + "' where cardid='" + CardNo + "' and " + filed + " is null";
                db.InsertUpdateDel(sql);
                if (filed == "xf_point")
                {
                    if (xf_money > cs.maxMoney)
                    {
                        xf_money = cs.maxMoney;
                    }
                    double integral = xf_money * 1;//计算消费积分

                    sql = "update vipcard set point=point-" + xf_money + ",xf_integral=xf_integral+" + integral + " where cardid='" + CardNo + "'";
                    db.InsertUpdateDel(sql);

                    sql = "select point,integral,xf_integral,shop_integral from vipcard where cardid='" + CardNo + "'";
                    SqlDataReader rs = db.ExecuteSqlDataReader(sql);
                    rs.Read();
                    string point = rs[0].ToString();
                    integral = double.Parse(rs[1].ToString()) + double.Parse(rs[2].ToString()) + double.Parse(rs[3].ToString());
                    double user_point = double.Parse(point);
                    mes = "本次消费" + xf_money.ToString() + "元\n\n";
                    if (user_point < 0)
                    {
                        mes = mes + "应收款" + Math.Abs(user_point).ToString() + "元\n\n";
                        sql = "update vipcard set point=0 where cardid='" + CardNo + "'";
                        db.InsertUpdateDel(sql);
                    }
                    else
                    {
                        mes = mes + "卡内还剩:" + point + "元\n\n";
                    }
                    rs.Close();
                    mes = mes + "\n\n当前积分:" + integral.ToString();
                    if (ball_number != "")
                    {
                        mes = mes + "应归还" + ball_number + "号球";
                    }
                }
                else
                {
                    double smoney = ti.deposit - xf_money;
                    if (smoney > 1)
                    {
                        mes = "本次消费" + xf_money.ToString() + "元\n\n应找零" + smoney.ToString() + "元";
                    }
                    else
                    {
                        mes = "本次消费" + xf_money.ToString() + "元\n\n应收款" + Math.Abs(smoney).ToString() + "元";
                    }
                    if (ball_number != "")
                    {
                        mes = mes + "\n\n" + "应归还" + ball_number + "号球";
                    }
                }
                MessageBox.Show(mes, "刷卡消费", MessageBoxButtons.OK);
            }
            parametersf.dgf1 = true;
            parametersf.dgf2 = true;
        }