Exemplo n.º 1
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>");
                }
            }
        }
Exemplo n.º 2
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>");
            }
        }