Esempio n. 1
0
        protected void btnBc_Click(object sender, EventArgs e)
        {
            try
            {
                string id = Request.QueryString["id"];

                if (!string.IsNullOrEmpty(id))
                {
                    System.Model.facility_type fs = _bll.ftbll.GetModel(Utility.Helper.gerInt(id));

                    if (fs != null)
                    {
                        fs.discount = Utility.Helper.gerDecimal(this.txtdiscount.Text);
                        fs.price    = Utility.Helper.gerDecimal(this.txtprice.Text);
                        fs.time     = Utility.Helper.gerInt(this.txttime.Text);
                        fs.tyoe     = this.txttyoe.Text;



                        if (_bll.ftbll.Update(fs))
                        {
                            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑成功!');window.location.href='admin_type.aspx';", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑失败!');window.location.href='admin_type.aspx';", true);
                        }
                    }
                }
                else
                {
                    System.Model.facility_type fs = new System.Model.facility_type();

                    fs.discount = Utility.Helper.gerDecimal(this.txtdiscount.Text);
                    fs.price    = Utility.Helper.gerDecimal(this.txtprice.Text);
                    fs.time     = Utility.Helper.gerInt(this.txttime.Text);
                    fs.tyoe     = this.txttyoe.Text;
                    fs.pudate   = System.DateTime.Now;
                    if (_bll.ftbll.Add(fs) > 0)
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('添加成功!');window.location.href='admin_type.aspx';", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('添加失败!');window.location.href='admin_type.aspx';", true);
                    }
                }
            }
            catch
            {
                Response.Redirect(ConfigurationManager.AppSettings["VirturlPath"] + "/error500.aspx?menu1=2&menu2=4");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.facility_type GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, tyoe, time, price, pudate, isdel, discount  ");
            strSql.Append("  from facility_type ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            System.Model.facility_type model = new System.Model.facility_type();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.tyoe = ds.Tables[0].Rows[0]["tyoe"].ToString();
                if (ds.Tables[0].Rows[0]["time"].ToString() != "")
                {
                    model.time = int.Parse(ds.Tables[0].Rows[0]["time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["price"].ToString() != "")
                {
                    model.price = decimal.Parse(ds.Tables[0].Rows[0]["price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pudate"].ToString() != "")
                {
                    model.pudate = DateTime.Parse(ds.Tables[0].Rows[0]["pudate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isdel"].ToString() != "")
                {
                    model.isdel = int.Parse(ds.Tables[0].Rows[0]["isdel"].ToString());
                }
                if (ds.Tables[0].Rows[0]["discount"].ToString() != "")
                {
                    model.discount = decimal.Parse(ds.Tables[0].Rows[0]["discount"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.facility_type> DataTableToList(DataTable dt)
        {
            List <System.Model.facility_type> modelList = new List <System.Model.facility_type>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.facility_type model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.facility_type();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.tyoe = dt.Rows[n]["tyoe"].ToString();
                    if (dt.Rows[n]["time"].ToString() != "")
                    {
                        model.time = int.Parse(dt.Rows[n]["time"].ToString());
                    }
                    if (dt.Rows[n]["price"].ToString() != "")
                    {
                        model.price = decimal.Parse(dt.Rows[n]["price"].ToString());
                    }
                    if (dt.Rows[n]["pudate"].ToString() != "")
                    {
                        model.pudate = DateTime.Parse(dt.Rows[n]["pudate"].ToString());
                    }
                    if (dt.Rows[n]["isdel"].ToString() != "")
                    {
                        model.isdel = int.Parse(dt.Rows[n]["isdel"].ToString());
                    }
                    if (dt.Rows[n]["discount"].ToString() != "")
                    {
                        model.discount = decimal.Parse(dt.Rows[n]["discount"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.facility_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update facility_type set ");

            strSql.Append(" tyoe = @tyoe , ");
            strSql.Append(" time = @time , ");
            strSql.Append(" price = @price , ");
            strSql.Append(" pudate = @pudate , ");
            strSql.Append(" isdel = @isdel , ");
            strSql.Append(" discount = @discount  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.Int,        4),
                new SqlParameter("@tyoe",     SqlDbType.NVarChar,  50),
                new SqlParameter("@time",     SqlDbType.Int,        4),
                new SqlParameter("@price",    SqlDbType.Money,      8),
                new SqlParameter("@pudate",   SqlDbType.DateTime),
                new SqlParameter("@isdel",    SqlDbType.Int,        4),
                new SqlParameter("@discount", SqlDbType.Float, 8)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.tyoe;
            parameters[2].Value = model.time;
            parameters[3].Value = model.price;
            parameters[4].Value = model.pudate;
            parameters[5].Value = model.isdel;
            parameters[6].Value = model.discount;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.facility_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into facility_type(");
            strSql.Append("tyoe,time,price,pudate,isdel,discount");
            strSql.Append(") values (");
            strSql.Append("@tyoe,@time,@price,@pudate,@isdel,@discount");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@tyoe",     SqlDbType.NVarChar,  50),
                new SqlParameter("@time",     SqlDbType.Int,        4),
                new SqlParameter("@price",    SqlDbType.Money,      8),
                new SqlParameter("@pudate",   SqlDbType.DateTime),
                new SqlParameter("@isdel",    SqlDbType.Int,        4),
                new SqlParameter("@discount", SqlDbType.Float, 8)
            };

            parameters[0].Value = model.tyoe;
            parameters[1].Value = model.time;
            parameters[2].Value = model.price;
            parameters[3].Value = model.pudate;
            parameters[4].Value = model.isdel;
            parameters[5].Value = model.discount;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.facility_type model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.facility_type model)
 {
     return(dal.Add(model));
 }
Esempio n. 8
0
        /// <summary>
        /// 返回结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    //结果类型
                    string resulttype = Request["resulttype"] != null?Utility.Helper.Checkstr(Request["resulttype"]) : "";

                    //结果
                    string result = Request["result"] != null?Utility.Helper.Checkstr(Request["result"]) : "";

                    //标识
                    string identify = Request["identify"] != null?Utility.Helper.Checkstr(Request["identify"]) : "";

                    //接口标识
                    string requestCode = Request["requetCode"] != null?Utility.Helper.Checkstr(Request["requetCode"]) : "";

                    //requestCode = Request.Form.ToString();
                    //
                    //log.setlog("地址", Request.Url.ToString());
                    //log.setlog("地址", Request.RawUrl);
                    #region 提供服务回调

                    if (!string.IsNullOrEmpty(resulttype) && !string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(identify))
                    {
                        log.setlog("服务回调", "resulttype:" + resulttype + "  result:" + result + "  identify:" + identify + "  requestCode:" + requestCode);



                        //标识
                        string             resultNO = result;
                        List <checkStatus> sd       = publicData.orderlist;
                        log.setlog("静态变量数据量", sd.Count.ToString());

                        try
                        {
                            if (sd.Count > 0)
                            {
                                sd = (from s in sd
                                      where s.identifying == requestCode
                                      select s).ToList();



                                if (sd.Count > 0)
                                {
                                    checkStatus sd_0 = sd[0];
                                    if (sd_0.types == 0)
                                    {
                                        #region 自检结果

                                        string customId = sd_0.customId;
                                        System.Model.facility_port fp = _bll.fpbll.GetModel(sd_0.portid);

                                        System.Model.facility_stipple fs = new System.Model.facility_stipple();
                                        System.Model.facility         fa = new System.Model.facility();

                                        if (resultNO == "2")
                                        //if (resultNO == "0")
                                        //if (true)
                                        {
                                            fa = _bll.fbll.GetModel(sd[0].facilityid);

                                            //查询网点
                                            fs = _bll.fsbll.GetModel(fa.fid);
                                            //查询设备 折扣
                                            System.Model.facility_type ftype = _bll.ftbll.GetModel(fa.types);

                                            //生成订单
                                            string serialNumber = System.DateTime.Now.ToString("yyyyMMddHHmmss") + Utility.Helper.rnds(8);
                                            //折后价
                                            decimal prices = ftype.price * ftype.discount;

                                            System.Model.order_info oi = new System.Model.order_info();

                                            oi.customid     = customId;
                                            oi.serialNumber = serialNumber;
                                            oi.discount     = ftype.discount;

                                            oi.price = prices;

                                            oi.port      = fp.id;
                                            oi.pudate    = System.DateTime.Now;
                                            oi.statuses  = 1;
                                            oi.facility  = Utility.Helper.gerInt(fa.id);
                                            oi.duration  = ftype.time;
                                            oi.stippleid = fs.id;
                                            oi.types     = 1;//1快充
                                            if (_bll.oibll.Add(oi) > 0)
                                            {
                                                //生成支付信息

                                                System.Model.Member_Charge_Withdraw mcw = new System.Model.Member_Charge_Withdraw();

                                                mcw.memberid     = customId;
                                                mcw.moneyes      = prices;
                                                mcw.serialNumber = serialNumber;
                                                mcw.paystatus    = 1;
                                                mcw.statusname   = "未支付";
                                                //mcw.paytype = "";//支付方式 支付宝 微信 钱包
                                                //paystatus 1 未支付 2已支付
                                                //types  1订单 2充值 3......
                                                mcw.types  = 1;
                                                mcw.pudate = System.DateTime.Now;
                                                if (_bll.mcwbll.Add(mcw) > 0)
                                                {
                                                    for (int i = 0; i < publicData.orderlist.Count; i++)
                                                    {
                                                        if (publicData.orderlist[i].identifying == requestCode)
                                                        {
                                                            publicData.orderlist[i].orderid = serialNumber;
                                                            log.setlog("订单产生成功", publicData.orderlist[i].orderid);
                                                        }
                                                    }
                                                    //jsonResult["res"] = (int)MyEnum.ResultEnum.成功;
                                                    //jsonResult["msg"] = "下单成功";
                                                    //jsonResult["code"] = "";
                                                    //
                                                    //jsonResult["stipplename"] = fs.name;
                                                    //jsonResult["servertype"] = "快充";
                                                    //jsonResult["price"] = Math.Round(prices, 2).ToString();
                                                    //jsonResult["serialnumber"] = serialNumber;//订单号
                                                }
                                                else
                                                {
                                                    //jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                                    //jsonResult["msg"] = "错误";
                                                    //jsonResult["code"] = "下单失败";
                                                }
                                            }
                                            else
                                            {
                                                //jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                                //jsonResult["msg"] = "错误";
                                                //jsonResult["code"] = "下单失败";
                                            }
                                        }
                                        else
                                        {
                                            //错误
                                            //添加自检错误记录
                                            //
                                            System.Model.self_test st = new System.Model.self_test();

                                            string name = "";
                                            string typeno;
                                            switch (resultNO)
                                            {
                                            case "0":
                                                name   = "正常";
                                                typeno = "0";
                                                break;

                                            case "2":
                                                name   = "充电桩和充电枪运行正常";
                                                typeno = "2";
                                                break;

                                            case "3":
                                                name   = "充电桩运行异常";
                                                typeno = "3";
                                                break;

                                            case "4":
                                                name   = "充电枪运行异常";
                                                typeno = "4";
                                                break;

                                            case "5":
                                                name   = "外网电压工作异常";
                                                typeno = "5";
                                                break;

                                            case "6":
                                                name   = "电池工作不正常";
                                                typeno = "6";
                                                break;

                                            case "7":
                                                name   = "充电枪与电池接触良";
                                                typeno = "7";
                                                break;

                                            default:
                                                name   = "系统未知错误";
                                                typeno = "xxxx";
                                                break;
                                            }

                                            st.facility  = Utility.Helper.gerInt(fa.id);
                                            st.isdispose = 0;
                                            st.port      = Utility.Helper.gerInt(fp.fid);
                                            st.errortype = "1";
                                            st.stipple   = Utility.Helper.gerInt(fs.id);
                                            st.pudate    = System.DateTime.Now;
                                            _bll.stbll.Add(st);


                                            //jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                            //jsonResult["msg"] = "设备故障";
                                            //jsonResult["code"] = "设备故障";
                                        }



                                        #endregion
                                    }
                                    else if (sd_0.types == 1)
                                    {
                                        #region 充电是否开始

                                        if (!string.IsNullOrEmpty(sd_0.orderid))
                                        {
                                            //修改订单充电状态
                                            //开始充电
                                            string strwhere = " serialNumber='" + sd_0.orderid + "'  ";

                                            List <System.Model.order_info> oilist = _bll.oibll.GetModelList(strwhere);

                                            if (oilist.Count == 1)
                                            {
                                                System.Model.order_info oi = oilist[0];
                                                oi.statuses = 2;//充电中
                                                _bll.oibll.Update(oi);
                                            }
                                            else
                                            {
                                            }
                                        }
                                        #endregion
                                    }
                                    else if (sd_0.types == 2)
                                    {
                                        #region 充电是否结束

                                        if (!string.IsNullOrEmpty(sd_0.orderid))
                                        {
                                            //修改订单充电状态
                                            //结束充电
                                            string strwhere = " serialNumber='" + sd_0.orderid + "'  ";

                                            List <System.Model.order_info> oilist = _bll.oibll.GetModelList(strwhere);
                                            if (oilist.Count == 1)
                                            {
                                                System.Model.order_info oi = oilist[0];
                                                oi.statuses = 3;//已完成充电
                                                _bll.oibll.Update(oi);
                                            }
                                            else
                                            {
                                            }
                                        }

                                        #endregion
                                    }
                                    else if (sd_0.types == 3)
                                    {
                                        #region 系统故障类型

                                        #endregion
                                    }
                                    else if (sd_0.types == 4)
                                    {
                                        #region 充电数据


                                        #endregion
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            log.setlog("错误", ex.Message);
                        }
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.成功;
                        jsonResult["msg"]  = "";
                        jsonResult["code"] = "";
                    }
                    else
                    {
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]  = "";
                        jsonResult["code"] = "参数缺失";
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    jsonResult["result"] = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]    = "服务器繁忙,请稍后再试";
                    jsonResult["code"]   = ex.Message;
                    log.setlog("错误", ex.Message);
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }