protected void DLWantedAnswerInfo_ItemCommand(object source, DataListCommandEventArgs e) { Button BTNSelectAsAnswer = (Button)e.Item.FindControl("BTNSelectAsAnswer"); Label LBLAnswerID = (Label)e.Item.FindControl("LBLAnswerID"); WantedInfoBusiness SetTargetAsAnswer = new WantedInfoBusiness(); int iReturnedValue = 0; if (e.CommandName == "BTNSelectAsAnswer") { //当客户登录时,若没有选定的答案,则点击后可设置最佳答案 iReturnedValue = SetTargetAsAnswer.SetAsAnswer(long.Parse(LBLAnswerID.Text)); if (iReturnedValue > 0) { long lWantedID = long.Parse(Request.QueryString["WantedID"].ToString()); CounsellorInfoBusiness CounsellorInfo = new CounsellorInfoBusiness(); ClientInfoBusiness ClientInfo = new ClientInfoBusiness(); long lCounsellorID = CounsellorInfo.GetCounsellorIDByAnswerID(long.Parse(LBLAnswerID.Text)); long lClientID = ClientInfo.GetClientIDByWantedID(lWantedID); WantedInfoBusiness WantedQuestionDetailsInfoSearch = new WantedInfoBusiness(); WantedQuestionDetailsInfoEntity WantedQuestionInfo = new WantedQuestionDetailsInfoEntity(); WantedQuestionInfo = WantedQuestionDetailsInfoSearch.WantedQuestionDetailsInfoByID(lWantedID); long lBountyMoney = WantedQuestionInfo.lwantedBounty; LBLWantedField.Text = lBountyMoney.ToString(); ClientInfo.ClientWantedBountyMoney(lBountyMoney, lClientID); CounsellorInfo.CounsellorWalletMoneyUpdate(lCounsellorID, lBountyMoney); Response.Write("<script>alert('成功设置为答案!')</script>"); } else { Response.Write("<script>alert('设置为答案失败!')</script>"); } } /** * 任何身份都可以点赞,包括游客 */ else if (e.CommandName == "BTNRespondLikedCount") { //点了点赞后,让点赞数+1 iReturnedValue = SetTargetAsAnswer.RespondLiked(long.Parse(LBLAnswerID.Text)); if (iReturnedValue > 0) { Response.Write("<script>alert('您赞了此答案!')</script>"); } else { Response.Write("<script>alert('点赞失败!!')</script>"); } } else if (e.CommandName == "BTNRespondDislikedCount") { //点了点踩后,让点踩数+1 iReturnedValue = SetTargetAsAnswer.RespondDisliked(long.Parse(LBLAnswerID.Text)); if (iReturnedValue > 0) { Response.Write("<script>alert('您踩了此答案!')</script>"); } else { Response.Write("<script>alert('点踩失败!')</script>"); } } }