Ejemplo n.º 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent;

            SYCRM.Model.Agent user = new SYCRM.Model.Agent();

            List<SYCRM.Model.Agent> listuser = new List<SYCRM.Model.Agent>();

            SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent();

            string strLayer = DDLLayer.SelectedValue;

            string[] layerarray = strLayer.Split('.');
            if (layerarray.Count() == 0)
            {
                labErr.Visible = true;
                labErr.Text = "账户数据错误!请联系系统管理员!";
                return;
            }
            user.AreaId = new Guid(layerarray[layerarray.Count() - 1]);

            user.Address = tbAddress.Text.Trim();

            user.Des = tb_ShowDes.Text.Trim();
            user.Email = tbMail.Text.Trim();
            user.IDCard = tbIDCard.Text.Trim();
            user.Phone = tbPhone.Text.Trim();

            user.UserType = int.Parse(ddlUserType.SelectedValue);

            if(manauser.AreaId==user.AreaId&&user.UserType.Value==1)
            {
                 labErr.Visible = true;
                labErr.Text = "账户数据错误!请联系系统管理员!";
                return;
            }

            user.Position = new Guid(ddlPost.SelectedValue);

            user.Sex = int.Parse(ddlSex.SelectedValue);

            user.status = 1;

            user.Password = tbPassword.Text;

            user.UserName = tbLoginName.Text.Trim();

            listuser = ba.GetModelList(" UserName ='******'");

            if (listuser.Count > 0)
            {
                labErr.Visible = true;
                labErr.Text = "已存在登录名,请修改!";
                return;
            }

            user.Name = tbName.Text.Trim();

            ba.Add(user);

            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加成功!", "<script>alert('添加成功!');window.location.href=window.location.href</script>");
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["User"] != null)
                {
                    SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent;
                    hdarea.Value = manauser.AreaId.ToString();
                    bindddl(manauser);
                }
                else
                {
                    Response.Redirect("~/login.aspx");
                }

                //if (Request.QueryString["id"] != null)
                {
                    SYCRM.Model.Agent manauser  =Session["User"] as SYCRM.Model.Agent;
                    string strId = manauser.Id.ToString();
                    if (strId != "")
                    {
                        bool wrong = false;
                        Guid id = new Guid();
                        try
                        {
                            id = new Guid(strId);
                        }
                        catch
                        {
                            wrong = true;
                        }
                        if (wrong)
                        {
                            Response.Redirect("agent.aspx");
                        }
                        else
                        {

                            SYCRM.Model.Agent user = new SYCRM.Model.Agent();

                            SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent();

                            user = ba.GetModel(id);

                            if (user != null)
                            {
                                bind(user);
                            }
                            else
                            {
                                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');</script>");
                            }

                        }
                    }
                    else
                    {
                        Response.Redirect("mine.aspx");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public SYCRM.Model.Agent GetModel(Guid Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 * from Agent ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.UniqueIdentifier)};
            parameters[0].Value = Id;

            SYCRM.Model.Agent model=new SYCRM.Model.Agent();
            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.UserName=ds.Tables[0].Rows[0]["UserName"].ToString();
                model.Password=ds.Tables[0].Rows[0]["Password"].ToString();
                model.Name=ds.Tables[0].Rows[0]["Name"].ToString();
                if(ds.Tables[0].Rows[0]["Position"].ToString()!="")
                {
                    model.Position=new Guid(ds.Tables[0].Rows[0]["Position"].ToString());
                }
                model.Phone=ds.Tables[0].Rows[0]["Phone"].ToString();
                model.Mobile=ds.Tables[0].Rows[0]["Mobile"].ToString();
                model.Email=ds.Tables[0].Rows[0]["Email"].ToString();
                model.Address=ds.Tables[0].Rows[0]["Address"].ToString();
                model.IDCard=ds.Tables[0].Rows[0]["IDCard"].ToString();
                model.Remark=ds.Tables[0].Rows[0]["Remark"].ToString();
                if(ds.Tables[0].Rows[0]["UserType"].ToString()!="")
                {
                    model.UserType=int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
                }
                model.Des=ds.Tables[0].Rows[0]["Des"].ToString();
                if(ds.Tables[0].Rows[0]["Sex"].ToString()!="")
                {
                    model.Sex=int.Parse(ds.Tables[0].Rows[0]["Sex"].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]["AreaId"].ToString()!="")
                {
                    model.AreaId=new Guid(ds.Tables[0].Rows[0]["AreaId"].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;
            }
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool wrong = false;

            Guid id = new Guid();
            try
            {
                id = new Guid(hdId.Value);
            }
            catch
            {
                wrong = true;
            }
            if (wrong)
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');</script>");
                return;
            }

            SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent;

            SYCRM.Model.Agent user = new SYCRM.Model.Agent();

            List<SYCRM.Model.Agent> listuser = new List<SYCRM.Model.Agent>();

            SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent();

            user = ba.GetModel(id);

            if (user == null)
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');</script>");
                return;
            }

            string strLayer = DDLLayer.SelectedValue;

            string[] layerarray = strLayer.Split('.');
            if (layerarray.Count() == 0)
            {
                labErr.Visible = true;
                labErr.Text = "账户数据错误!请联系系统管理员!";
                return;
            }
            user.AreaId = new Guid(layerarray[layerarray.Count() - 1]);

            user.Address = tbAddress.Text.Trim();

            user.Des = tb_ShowDes.Text.Trim();
            user.Email = tbMail.Text.Trim();
            user.IDCard = tbIDCard.Text.Trim();
            user.Phone = tbPhone.Text.Trim();

            user.UserType = int.Parse(ddlUserType.SelectedValue);

            user.Position = new Guid(ddlPost.SelectedValue);

            user.Sex = int.Parse(ddlSex.SelectedValue);

            user.status = 1;

            if (tbPassword.Text != "")
            {
                user.Password = tbPassword.Text;
            }
            user.Name = tbName.Text.Trim();

            ba.Update(user);

            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改成功!", "<script>alert('修改成功!');</script>");
        }