/// <summary> /// 增加一条数据 /// </summary> public long Add(lgk.Model.tb_agent1 model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_agent1("); strSql.Append("AgentCode,Flag,UserID,AgentType,AppliTime,JoinMoney,OpenTime,PicLink,AgentInProvince,AgentInCity,AgentAddress,Agent001,Agent002,Agent003,Agent004,Agent005,Agent006)"); strSql.Append(" values ("); strSql.Append("@AgentCode,@Flag,@UserID,@AgentType,@AppliTime,@JoinMoney,@OpenTime,@PicLink,@AgentInProvince,@AgentInCity,@AgentAddress,@Agent001,@Agent002,@Agent003,@Agent004,@Agent005,@Agent006)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@AgentCode", SqlDbType.VarChar, 50), new SqlParameter("@Flag", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.BigInt, 8), new SqlParameter("@AgentType", SqlDbType.Int, 4), new SqlParameter("@AppliTime", SqlDbType.DateTime), new SqlParameter("@JoinMoney", SqlDbType.Decimal, 9), new SqlParameter("@OpenTime", SqlDbType.DateTime), new SqlParameter("@PicLink", SqlDbType.VarChar, 50), new SqlParameter("@AgentInProvince", SqlDbType.VarChar, 50), new SqlParameter("@AgentInCity", SqlDbType.VarChar, 50), new SqlParameter("@AgentAddress", SqlDbType.VarChar, 50), new SqlParameter("@Agent001", SqlDbType.Int, 4), new SqlParameter("@Agent002", SqlDbType.Int, 4), new SqlParameter("@Agent003", SqlDbType.VarChar, 50), new SqlParameter("@Agent004", SqlDbType.VarChar, 50), new SqlParameter("@Agent005", SqlDbType.Decimal, 9), new SqlParameter("@Agent006", SqlDbType.Decimal, 9) }; parameters[0].Value = model.AgentCode; parameters[1].Value = model.Flag; parameters[2].Value = model.UserID; parameters[3].Value = model.AgentType; parameters[4].Value = model.AppliTime; parameters[5].Value = model.JoinMoney; parameters[6].Value = model.OpenTime; parameters[7].Value = model.PicLink; parameters[8].Value = model.AgentInProvince; parameters[9].Value = model.AgentInCity; parameters[10].Value = model.AgentAddress; parameters[11].Value = model.Agent001; parameters[12].Value = model.Agent002; parameters[13].Value = model.Agent003; parameters[14].Value = model.Agent004; parameters[15].Value = model.Agent005; parameters[16].Value = model.Agent006; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
/// <summary> /// 审核分页申请记录 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { long iID = long.Parse(e.CommandArgument.ToString()); lgk.Model.tb_agent1 agentInfo = agent1BLL.GetModel(iID); if (agentInfo == null) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('已删除,无法再进行此操作!');window.location.href='Agent.aspx';", true); } else { if (agentInfo.Flag != 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('该运营中心已激活,不能再进行此操作!');window.location.href='Agent.aspx';", true); } else { if (e.CommandName == "Remove") { if (agent1BLL.Delete(iID)) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除成功!');window.location.href='Agent.aspx';", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除失败!');window.location.href='Agent.aspx';", true); } } if (e.CommandName == "Open") { agentInfo.Flag = 1; agentInfo.OpenTime = DateTime.Now; var model = userBLL.GetModel(agentInfo.UserID); model.User001 = 1; if (agent1BLL.Update(agentInfo) && userBLL.Update(model)) { string strUserCode = userBLL.GetUserCode(agentInfo.UserID); //userBLL.UpdateAgent1(agentInfo.UserID); //UpdateAgent(iID, agentInfo.UserID, strUserCode); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('激活成功!');window.location.href='Agent.aspx';", true); } } } } BindData(); }
protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e) { int ID = int.Parse(e.CommandArgument.ToString()); lgk.Model.tb_agent1 agent = agent1BLL.GetModel(ID); var model = userBLL.GetModel(agent.UserID); if (e.CommandName == "close") { spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 model.User001 = 2; userBLL.Update(model); agent.Flag = 2; agent1BLL.Update(agent); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('冻结成功!');", true); } if (e.CommandName == "open") { spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 model.User001 = 1; userBLL.Update(model); agent.Flag = 1; agent1BLL.Update(agent); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('解冻成功!');", true); } if (e.CommandName == "close_hx") { spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 agent.Agent001 = 1; agent1BLL.Update(agent); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置空单成功!');", true); } if (e.CommandName == "open_hx") { spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 agent.Agent001 = 0; agent1BLL.Update(agent); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('取消空单成功!');", true); } if (e.CommandName == "list") { Response.Redirect("UserList.aspx?id=" + ID); } bind2(); }
protected void btnSubmit_Click(object sender, EventArgs e) { int iAgent1Opend = getParamInt("Yunying");//是否可申请报单中心(0否,1是) if (iAgent1Opend == 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('" + GetLanguage("Feature") + "');", true);//该功能未开放 return; } if (Loginagent1 != null) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('" + GetLanguage("pleaseWait") + "');", true);//您的申请已提交,请耐心等待 return; } //if (userBLL.GetCount("RecommendID=" + LoginUser.UserID + " AND IsOpend = 2") < getParamInt("Agent11")) //{ // ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('" + GetLanguage("InsufficientNumber") + "');", true);//推荐人数不足 // return; //} if (agentBLL.GetAgentsID(LoginUser.UserCode) == 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('成为报单中心才能申请运营中心');", true);//推荐人数不足 return; } if (agent1BLL.GetAgentsID(LoginUser.UserCode) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('正在审核或者已经是运营中心');", true);//推荐人数不足 return; } if (this.Address.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('地址不能为空');", true);//推荐人数不足 return; } if (this.Phone.Value == "" || this.Phone.Value.Length != 11) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入正确的手机号码');", true);//推荐人数不足 return; } lgk.Model.tb_agent1 model = new lgk.Model.tb_agent1(); model.UserID = getLoginID(); model.AgentCode = LoginUser.UserCode; model.Flag = 0; model.AgentType = LoginUser.LevelID; model.Agent003 = LoginUser.TrueName; model.AppliTime = DateTime.Now; model.JoinMoney = getParamAmount("Level" + LoginUser.LevelID); model.Agent004 = ""; model.Agent001 = 0; model.Agent002 = 0; model.AgentAddress = this.Address.Value; model.PicLink = this.Phone.Value; if (agent1BLL.Add(model) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('" + GetLanguage("Successful") + "');window.location.href='Agent1.aspx';", true);//申请XX成功 } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('" + GetLanguage("OperationFailed") + "');", true);//申请失败 } }
/// <summary> /// 获得服务中心 /// </summary> /// <param name="where">条件</param> /// <returns></returns> public lgk.Model.tb_agent1 GetModel(string where) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,AgentCode,Flag,UserID,AgentType,AppliTime,JoinMoney,OpenTime,PicLink,AgentInProvince,AgentInCity,AgentAddress,Agent001,Agent002,Agent003,Agent004,Agent005,Agent006 from tb_agent1 "); strSql.Append(" where " + where); lgk.Model.tb_agent1 model = new lgk.Model.tb_agent1(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["AgentCode"] != null && ds.Tables[0].Rows[0]["AgentCode"].ToString() != "") { model.AgentCode = ds.Tables[0].Rows[0]["AgentCode"].ToString(); } if (ds.Tables[0].Rows[0]["Flag"] != null && ds.Tables[0].Rows[0]["Flag"].ToString() != "") { model.Flag = int.Parse(ds.Tables[0].Rows[0]["Flag"].ToString()); } if (ds.Tables[0].Rows[0]["UserID"] != null && ds.Tables[0].Rows[0]["UserID"].ToString() != "") { model.UserID = long.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); } if (ds.Tables[0].Rows[0]["AgentType"] != null && ds.Tables[0].Rows[0]["AgentType"].ToString() != "") { model.AgentType = int.Parse(ds.Tables[0].Rows[0]["AgentType"].ToString()); } if (ds.Tables[0].Rows[0]["AppliTime"] != null && ds.Tables[0].Rows[0]["AppliTime"].ToString() != "") { model.AppliTime = DateTime.Parse(ds.Tables[0].Rows[0]["AppliTime"].ToString()); } if (ds.Tables[0].Rows[0]["JoinMoney"] != null && ds.Tables[0].Rows[0]["JoinMoney"].ToString() != "") { model.JoinMoney = decimal.Parse(ds.Tables[0].Rows[0]["JoinMoney"].ToString()); } if (ds.Tables[0].Rows[0]["OpenTime"] != null && ds.Tables[0].Rows[0]["OpenTime"].ToString() != "") { model.OpenTime = DateTime.Parse(ds.Tables[0].Rows[0]["OpenTime"].ToString()); } if (ds.Tables[0].Rows[0]["PicLink"] != null && ds.Tables[0].Rows[0]["PicLink"].ToString() != "") { model.PicLink = ds.Tables[0].Rows[0]["PicLink"].ToString(); } if (ds.Tables[0].Rows[0]["AgentInProvince"] != null && ds.Tables[0].Rows[0]["AgentInProvince"].ToString() != "") { model.AgentInProvince = ds.Tables[0].Rows[0]["AgentInProvince"].ToString(); } if (ds.Tables[0].Rows[0]["AgentInCity"] != null && ds.Tables[0].Rows[0]["AgentInCity"].ToString() != "") { model.AgentInCity = ds.Tables[0].Rows[0]["AgentInCity"].ToString(); } if (ds.Tables[0].Rows[0]["AgentAddress"] != null && ds.Tables[0].Rows[0]["AgentAddress"].ToString() != "") { model.AgentAddress = ds.Tables[0].Rows[0]["AgentAddress"].ToString(); } if (ds.Tables[0].Rows[0]["Agent001"] != null && ds.Tables[0].Rows[0]["Agent001"].ToString() != "") { model.Agent001 = int.Parse(ds.Tables[0].Rows[0]["Agent001"].ToString()); } if (ds.Tables[0].Rows[0]["Agent002"] != null && ds.Tables[0].Rows[0]["Agent002"].ToString() != "") { model.Agent002 = int.Parse(ds.Tables[0].Rows[0]["Agent002"].ToString()); } if (ds.Tables[0].Rows[0]["Agent003"] != null && ds.Tables[0].Rows[0]["Agent003"].ToString() != "") { model.Agent003 = ds.Tables[0].Rows[0]["Agent003"].ToString(); } if (ds.Tables[0].Rows[0]["Agent004"] != null && ds.Tables[0].Rows[0]["Agent004"].ToString() != "") { model.Agent004 = ds.Tables[0].Rows[0]["Agent004"].ToString(); } if (ds.Tables[0].Rows[0]["Agent005"] != null && ds.Tables[0].Rows[0]["Agent005"].ToString() != "") { model.Agent005 = decimal.Parse(ds.Tables[0].Rows[0]["Agent005"].ToString()); } if (ds.Tables[0].Rows[0]["Agent006"] != null && ds.Tables[0].Rows[0]["Agent006"].ToString() != "") { model.Agent006 = decimal.Parse(ds.Tables[0].Rows[0]["Agent006"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(lgk.Model.tb_agent1 model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_agent1 set "); strSql.Append("AgentCode=@AgentCode,"); strSql.Append("Flag=@Flag,"); strSql.Append("UserID=@UserID,"); strSql.Append("AgentType=@AgentType,"); strSql.Append("AppliTime=@AppliTime,"); strSql.Append("JoinMoney=@JoinMoney,"); strSql.Append("OpenTime=@OpenTime,"); strSql.Append("PicLink=@PicLink,"); strSql.Append("AgentInProvince=@AgentInProvince,"); strSql.Append("AgentInCity=@AgentInCity,"); strSql.Append("AgentAddress=@AgentAddress,"); strSql.Append("Agent001=@Agent001,"); strSql.Append("Agent002=@Agent002,"); strSql.Append("Agent003=@Agent003,"); strSql.Append("Agent004=@Agent004,"); strSql.Append("Agent005=@Agent005,"); strSql.Append("Agent006=@Agent006"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@AgentCode", SqlDbType.VarChar, 50), new SqlParameter("@Flag", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.BigInt, 8), new SqlParameter("@AgentType", SqlDbType.Int, 4), new SqlParameter("@AppliTime", SqlDbType.DateTime), new SqlParameter("@JoinMoney", SqlDbType.Decimal, 9), new SqlParameter("@OpenTime", SqlDbType.DateTime), new SqlParameter("@PicLink", SqlDbType.VarChar, 50), new SqlParameter("@AgentInProvince", SqlDbType.VarChar, 50), new SqlParameter("@AgentInCity", SqlDbType.VarChar, 50), new SqlParameter("@AgentAddress", SqlDbType.VarChar, 50), new SqlParameter("@Agent001", SqlDbType.Int, 4), new SqlParameter("@Agent002", SqlDbType.Int, 4), new SqlParameter("@Agent003", SqlDbType.VarChar, 50), new SqlParameter("@Agent004", SqlDbType.VarChar, 50), new SqlParameter("@Agent005", SqlDbType.Decimal, 9), new SqlParameter("@Agent006", SqlDbType.Decimal, 9), new SqlParameter("@ID", SqlDbType.BigInt, 8) }; parameters[0].Value = model.AgentCode; parameters[1].Value = model.Flag; parameters[2].Value = model.UserID; parameters[3].Value = model.AgentType; parameters[4].Value = model.AppliTime; parameters[5].Value = model.JoinMoney; parameters[6].Value = model.OpenTime; parameters[7].Value = model.PicLink; parameters[8].Value = model.AgentInProvince; parameters[9].Value = model.AgentInCity; parameters[10].Value = model.AgentAddress; parameters[11].Value = model.Agent001; parameters[12].Value = model.Agent002; parameters[13].Value = model.Agent003; parameters[14].Value = model.Agent004; parameters[15].Value = model.Agent005; parameters[16].Value = model.Agent006; parameters[17].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }