protected void btnAdd_Click(object sender, EventArgs e) { SYCRM.Model.Position MF = new SYCRM.Model.Position(); SYCRM.BLL.Position BF = new SYCRM.BLL.Position(); { MF.Name = tbName.Text; MF.status = 1; BF.Add(MF); tbName.Text = ""; Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加成功!", "<script>alert('添加成功!');window.location.href=window.location.href</script>"); } }
protected void btnEdit_Click(object sender, EventArgs e) { SYCRM.Model.Position MF = new SYCRM.Model.Position(); SYCRM.BLL.Position BF = new SYCRM.BLL.Position(); { MF = BF.GetModel(new Guid(hfPid.Value.Trim())); MF.Name = tbEName.Text; BF.Update(MF); tbEName.Text = ""; hfPid.Value = ""; Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改成功!", "<script>alert('修改成功!');window.location.href=window.location.href</script>"); } }
List<SYCRM.Model.Agent> handleAList(List<SYCRM.Model.Agent> listMA) { foreach (SYCRM.Model.Agent a in listMA) { SYCRM.Model.Area MArea = new SYCRM.Model.Area(); SYCRM.BLL.Area BArea = new SYCRM.BLL.Area(); MArea = BArea.GetModel(a.AreaId); if (MArea != null) { a.AreaName = MArea.Name; } else { a.AreaName = "区域已删除"; } SYCRM.Model.Position MPosition = new SYCRM.Model.Position(); SYCRM.BLL.Position BPosition = new SYCRM.BLL.Position(); MPosition = BPosition.GetModel(a.Position); if (MPosition != null) { a.PostName = MPosition.Name; } else { a.PostName = "职位已删除"; } } return listMA; }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public SYCRM.Model.Position GetModel(Guid Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 * from Position "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.UniqueIdentifier)}; parameters[0].Value = Id; SYCRM.Model.Position model=new SYCRM.Model.Position(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["Id"].ToString()!="") { model.Id=new Guid(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name=ds.Tables[0].Rows[0]["Name"].ToString(); if(ds.Tables[0].Rows[0]["status"].ToString()!="") { model.status=int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } if (ds.Tables[0].Rows[0]["Code"].ToString() != "") { model.Code = int.Parse(ds.Tables[0].Rows[0]["Code"].ToString()); } return model; } else { return null; } }