/// <summary> /// 新增、修改信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { if (this.CheckForm() == false) { CloseDivImplementation(); return; } GameEO _eo = new GameEO(); _eo.GmName = txtGameName.Text; _eo.GmGameId = txtGaameId.Text; _eo.GmDel = "0"; _eo.GmDescription = txtDescription.Text; _eo.GmState = rblState.Text; _eo.UrId = GetUserID(); _eo.GmAdddTime = DateTime.Now; if (Request.QueryString["State"] == "A") { Add(_eo); } if (Request.QueryString["State"] == "U") { Edit(_eo); } CloseDivImplementation(); }
/// <summary> /// 加载平台信息 /// </summary> private void LoadGame() { GameMO _mo = new GameMO(); GameEO _eo = _mo.Get(" Gm_gameId = @Gm_gameId ", Request.QueryString["Gm_gameId"].ToString()).Last(); if (!string.IsNullOrEmpty(_eo.GmId)) { this.txtGameName.Text = _eo.GmName; this.txtGaameId.Text = _eo.GmGameId; this.txtDescription.Text = _eo.GmDescription; this.rblState.SelectedValue = _eo.GmState; foreach (DataRow dr in _message.GetCannelListByGameId(Request.QueryString["Gm_gameId"].ToString()).Rows) { for (int i = 0; i < cblChannel.Items.Count; i++) // 循环选中渠道的值 { if (cblChannel.Items[i].Value == dr["Cn_id"].ToString()) { cblChannel.Items[i].Selected = true; } } } } }
/// <summary> /// 更新数据 /// </summary> /// <param name = "item">要更新的实体对象</param> /// <param name="tm">事务管理对象</param> /// <return>受影响的行数</return> public virtual int PutById(GameEO item, TransactionManager tm = null) { const string sql = @"UPDATE game SET Gm_name=@Gm_name, Gm_gameId=@Gm_gameId, Cn_channelId=@Cn_channelId, Gm_description=@Gm_description, Ur_id=@Ur_id, Gm_adddTime=@Gm_adddTime, Gm_state=@Gm_state, Gm_del=@Gm_del, Gm_text1=@Gm_text1, Gm_text2=@Gm_text2 WHERE Gm_id=@Gm_id"; return(Database.CreateSqlDao(sql) .AddInParameter("@Gm_name", item.GmName != null ? (object)item.GmName : DBNull.Value, DbType.String, 50) .AddInParameter("@Gm_gameId", item.GmGameId != null ? (object)item.GmGameId : DBNull.Value, DbType.String, 10) .AddInParameter("@Cn_channelId", item.CnChannelId != null ? (object)item.CnChannelId : DBNull.Value, DbType.String, 50) .AddInParameter("@Gm_description", item.GmDescription != null ? (object)item.GmDescription : DBNull.Value, DbType.String, -1) .AddInParameter("@Ur_id", item.UrId != null ? (object)item.UrId : DBNull.Value, DbType.String, 50) .AddInParameter("@Gm_adddTime", item.GmAdddTime.HasValue ? (object)item.GmAdddTime.Value : DBNull.Value, DbType.Date, 3) .AddInParameter("@Gm_state", item.GmState != null ? (object)item.GmState : DBNull.Value, DbType.AnsiStringFixedLength, 1) .AddInParameter("@Gm_del", item.GmDel != null ? (object)item.GmDel : DBNull.Value, DbType.AnsiStringFixedLength, 1) .AddInParameter("@Gm_text1", item.GmText1 != null ? (object)item.GmText1 : DBNull.Value, DbType.String, 200) .AddInParameter("@Gm_text2", item.GmText2 != null ? (object)item.GmText2 : DBNull.Value, DbType.String, 200) .AddInParameter("@Gm_id", item.GmId, DbType.String, 50) .ExecNonQuery(tm)); }
/// <summary> /// 修改 /// </summary> private void Edit(GameEO _eo) { string messagetrue = ""; string messagefalse = ""; //修改平台信息 //判断平台名称是否存在 if (this.CheckGameID() == false) { this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.Gam_eID + this.txtGaameId.Text.Trim() + Resources.Resource.Already_exist; CloseDivImplementation(); return; } if (Request.QueryString["Gm_gameId"].ToString() != txtGaameId.Text) { foreach (GameEO eos in _mo.GetByGmGameId(Request.QueryString["Gm_gameId"].ToString())) { string id = eos.GmId; _mo.PutGmGameIdByPK(id, txtGaameId.Text); } } for (int i = 0; i < cblChannel.Items.Count; i++) // 循环选中渠道的值 { if (cblChannel.Items[i].Selected) { _eo.CnChannelId = cblChannel.Items[i].Value; bool result = true; foreach (GameEO eoss in _mo.Get(" Gm_gameId=@Gm_gameId and Cn_channelId=@Cn_channelId ", _eo.GmGameId, _eo.CnChannelId)) { _eo.GmId = eoss.GmId; if (_mo.PutById(_eo) > 0) { messagetrue += cblChannel.Items[i].Value + ";"; //插入操作日志 } else { messagefalse += cblChannel.Items[i].Value + ";"; } result = false; } if (result) // 如果不存在 { _eo.GmId = GetBigGuid(); if (_mo.Add(_eo) > 0) { messagetrue += cblChannel.Items[i].Value + ";"; } else { messagefalse += cblChannel.Items[i].Value + ";"; } } } else // 没有选中 { _eo.CnChannelId = cblChannel.Items[i].Value; foreach (GameEO eoss in _mo.Get(" Gm_gameId=@Gm_gameId and Cn_channelId=@Cn_channelId ", _eo.GmGameId, _eo.CnChannelId)) { _mo.PutGmDelByPK(eoss.GmId, "1"); } } } InsertLog(Resources.Resource.Modify_game_info, string.Format("GmGameId:{0},创建{1}成功,创建{2}失败", _eo.GmGameId, messagetrue, messagefalse), 5010, GetPlatformIdByValue(1)); CloseDivImplementation(); if (messagefalse == "") { Jswork.Alert(Resources.Resource.Modify_game_information_successfully, "GameList.aspx"); } else { Jswork.Alert(Resources.Resource.Modify_game_creation + messagetrue + Resources.Resource.Success_create + messagefalse + Resources.Resource.fail, "GameList.aspx"); } }
/// <summary> /// 添加 /// </summary> /// <param name="_eo"></param> private void Add(GameEO _eo) { string messagetrue = ""; string messagefalse = ""; //创建平台信息 //判断平台名称是否存在 if (this.CheckGameID() == false) { this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.Gam_eID + this.txtGaameId.Text.Trim() + Resources.Resource.Already_exist; CloseDivImplementation(); return; } for (int i = 0; i < cblChannel.Items.Count; i++) // 循环选中渠道的值 { if (cblChannel.Items[i].Selected) { _eo.CnChannelId = cblChannel.Items[i].Value; _eo.GmId = GetBigGuid(); bool result = true; foreach (GameEO eoss in _mo.Get(" Gm_gameId=@Gm_gameId and Cn_channelId=@Cn_channelId ", _eo.GmGameId, _eo.CnChannelId)) { _eo.GmId = eoss.GmId; if (_mo.PutById(_eo) > 0) { messagetrue += cblChannel.Items[i].Value + ";"; //插入操作日志 } else { messagefalse += cblChannel.Items[i].Value + ";"; } result = false; } if (result) // 如果不存在 { if (_mo.Add(_eo) > 0) { messagetrue += cblChannel.Items[i].Value + ";"; } else { messagefalse += cblChannel.Items[i].Value + ";"; } } } } InsertLog(Resources.Resource.Create_game_information, string.Format("GmGameId:{0},创建{1}成功,创建{2}失败", _eo.GmGameId, messagetrue, messagefalse), 5009, GetPlatformIdByValue(1)); CloseDivImplementation(); if (messagefalse == "") { Jswork.Alert(Resources.Resource.Create_game_information_success, "GameList.aspx"); } else { Jswork.Alert(Resources.Resource.Create_a_game_channel + messagetrue + Resources.Resource.Success_create + messagefalse + Resources.Resource.fail, "GameList.aspx"); } }