Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strId = editid.Text.Trim();

            try
            {
                Guid id = new Guid(strId);
                SYCRM.Model.Area MF = new SYCRM.Model.Area();
                SYCRM.BLL.Area BF = new SYCRM.BLL.Area();
                MF = BF.GetModel(id);

                MF.Name = tbShowName.Text.Trim();
                MF.Des = tb_ShowDes.Text.Trim();
                string strOldWBS = MF.WBS;
                MF.WBS = DDLLayer.SelectedValue + "." + MF.Id.ToString();
                MF.status = 1;
                BF.Update(MF);

                List<SYCRM.Model.Area> listMA = BF.GetModelList("WBS like '%" + strOldWBS + ".%'");

                foreach (SYCRM.Model.Area a in listMA)
                {
                    a.WBS = MF.WBS + "." + a.Id.ToString();
                    BF.Update(a);
                }

                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改成功!", "<script>alert('修改成功!');window.location.href='Area.aspx'</script>");
            }
            catch
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改失败!", "<script>alert('修改失败!');window.location.href='Area.aspx'</script>");
            }
        }
Beispiel #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            SYCRM.Model.Area MF = new SYCRM.Model.Area();
            SYCRM.BLL.Area BF = new SYCRM.BLL.Area();

            //if (DateTime.TryParse(tbFDate.Text.Trim(), out temp))
            {
                MF.Name = tbShowName.Text.Trim();
                MF.Des = tb_ShowDes.Text.Trim();
                //MF.WBS = DDLLayer.SelectedValue
                MF.status = 1;
                BF.Add(MF);
                if (MF.Id == null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加失败!", "<script>alert('添加失败!');window.location.href='Area.aspx'</script>");
                    return;
                }
                else
                {
                    MF.WBS = DDLLayer.SelectedValue + "." + MF.Id;
                    BF.Update(MF);
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加成功!", "<script>alert('添加成功!');window.location.href='Area.aspx'</script>");
                }
            }
        }
Beispiel #3
0
        protected void btnDel_Click(object sender, EventArgs e)
        {
            string strId = editid.Text.Trim();

            try
            {
                Guid id = new Guid(strId);
                SYCRM.BLL.Area BF = new SYCRM.BLL.Area();
                SYCRM.Model.Area MF = new SYCRM.Model.Area();
                MF = BF.GetModel(id);

                List<SYCRM.Model.Area> listMA = BF.GetModelList("WBS like '%" + MF.WBS + "%'");

                foreach (SYCRM.Model.Area a in listMA)
                {
                    BF.Delete(a.Id);
                }
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "删除成功!", "<script>alert('删除成功!');window.location.href='Area.aspx'</script>");
            }
            catch
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "删除失败!", "<script>alert('删除失败!');window.location.href='Area.aspx'</script>");
            }
        }
Beispiel #4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public SYCRM.Model.Area GetModel(Guid Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 * from Area ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.UniqueIdentifier)};
            parameters[0].Value = Id;

            SYCRM.Model.Area model=new SYCRM.Model.Area();
            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]["Type"].ToString()!="")
                {
                    model.Type=new Guid(ds.Tables[0].Rows[0]["Type"].ToString());
                }
                model.WBS=ds.Tables[0].Rows[0]["WBS"].ToString();
                model.Des=ds.Tables[0].Rows[0]["Des"].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;
            }
        }
        List<SYCRM.Model.Customer> handleAList(List<SYCRM.Model.Customer> listMA)
        {
            foreach (SYCRM.Model.Customer a in listMA)
            {
                SYCRM.Model.Area MArea = new SYCRM.Model.Area();
                SYCRM.BLL.Area BArea = new SYCRM.BLL.Area();

                MArea = BArea.GetModel(a.Area);

                if (MArea != null)
                {
                    a.AreaName = MArea.Name;
                }
                else
                {
                    a.AreaName = "区域已删除";
                }
            }
            return listMA;
        }
Beispiel #6
0
        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;
        }
Beispiel #7
0
        void bind(SYCRM.Model.Agent user)
        {
            hdId.Value = user.Id.ToString();

            SYCRM.Model.Area ma = new SYCRM.Model.Area();
            SYCRM.BLL.Area ba = new SYCRM.BLL.Area();

            if (user.AreaId != null)
            {
                ma = ba.GetModel(user.AreaId);
                if (ma == null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');'</script>");
                }
                else
                {
                    ddlUserType.SelectedValue = user.UserType.Value.ToString();
                    DDLLayer.SelectedValue = ma.WBS.ToString();
                    ddlSex.SelectedValue = user.Sex.Value.ToString();
                    ddlPost.SelectedValue = user.Position.ToString();

                    tbAddress.Text = user.Address;
                    tb_ShowDes.Text = user.Des;
                    tbMail.Text = user.Email;
                    tbIDCard.Text = user.IDCard;
                    tbPhone.Text = user.Phone;

                    tbLoginName.Text = user.UserName;
                    tbName.Text = user.Name;
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');'</script>");
            }
        }