/// <summary> /// 获取实体 /// </summary> public Model.tourgroup_guid GetGroupGuidModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from dt_group_guid "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.tourgroup_guid model = new Model.tourgroup_guid(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region DATA if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["guid_id"] != null && ds.Tables[0].Rows[0]["guid_id"].ToString() != "") { model.guid_id = int.Parse(ds.Tables[0].Rows[0]["guid_id"].ToString()); } if (ds.Tables[0].Rows[0]["group_id"] != null && ds.Tables[0].Rows[0]["group_id"].ToString() != "") { model.group_id = int.Parse(ds.Tables[0].Rows[0]["group_id"].ToString()); } if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } if (ds.Tables[0].Rows[0]["apply_time"] != null && ds.Tables[0].Rows[0]["apply_time"].ToString() != "") { model.apply_time = DateTime.Parse(ds.Tables[0].Rows[0]["apply_time"].ToString()); } if (ds.Tables[0].Rows[0]["remark1"] != null && ds.Tables[0].Rows[0]["remark1"].ToString() != "") { model.remark1 = ds.Tables[0].Rows[0]["remark1"].ToString(); } if (ds.Tables[0].Rows[0]["remark2"] != null && ds.Tables[0].Rows[0]["remark2"].ToString() != "") { model.remark2 = int.Parse(ds.Tables[0].Rows[0]["remark2"].ToString()); } #endregion return model; } else { return null; } }
public void SignUp(int userId, int travelId, string version, string equType, string equName) { string json = string.Empty; try { if (bll_groupguid.Exists(userId, travelId)) { json = "{\"status\":\"false\",\"data\":\"不可重复报名!\"}"; } else { lock (this.SynBaoMing) { Model.tourgroup model_group = bll_tourgroup.GetTourGroupModel(travelId); if (model_group.total_count > model_group.book_count) { //将报团数+1 //bll_tourgroup.UpdateField(travelId, "book_count=" + (model_group.book_count + 1)); //向关系表中加入一条报名记录 //groupGuideManager.SignUp(userId, travelId); Model.tourgroup_guid model_groupguid = new Model.tourgroup_guid(); model_groupguid.group_id = travelId; model_groupguid.guid_id = userId; model_groupguid.status = 0; model_groupguid.apply_time = DateTime.Now; int count = bll_groupguid.Add(model_groupguid); if (count > 0) { json = json = "{\"status\":\"true\"}"; } else { json = "{\"status\":\"false\",\"data\":\"报团失败!\"}"; } } else { //是否需要更新状态 json = "{\"status\":\"false\",\"data\":\"该旅行团报名名额已满\"}"; } } } } catch (Exception ex) { json = "{\"status\":\"false\",\"data\":\"" + ex.Message + "\"}"; } WriteWebServiceLog(version, equType, equName, "SignUp", ""); Context.Response.Write(json); Context.Response.End(); }