예제 #1
0
        public ActionResult Body(FormCollection collection)
        {
            MyCreek.Data.Model.Organize org       = null;
            MyCreek.Platform.Organize   borganize = new MyCreek.Platform.Organize();
            string id = Request.QueryString["id"];

            if (id.IsGuid())
            {
                org = borganize.Get(id.ToGuid());
            }

            //保存
            if (!Request.Form["Save"].IsNullOrEmpty() && org != null)
            {
                string name         = Request.Form["Name"];
                string type         = Request.Form["Type"];
                string status       = Request.Form["Status"];
                string chargeLeader = Request.Form["ChargeLeader"];
                string leader       = Request.Form["Leader"];
                string note         = Request.Form["note"];
                string oldXML       = org.Serialize();
                org.Name         = name.Trim();
                org.Type         = type.ToInt(1);
                org.Status       = status.ToInt(0);
                org.ChargeLeader = chargeLeader;
                org.Leader       = leader;
                org.Note         = note.IsNullOrEmpty() ? null : note.Trim();

                borganize.Update(org);
                MyCreek.Platform.Log.Add("修改了组织机构", "", MyCreek.Platform.Log.Types.组织机构, oldXML, org.Serialize());
                string rid = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                ViewBag.Script = "alert('保存成功!');parent.frames[0].reLoad('" + rid + "');";
            }

            //移动
            if (!Request.Form["Move1"].IsNullOrEmpty() && org != null)
            {
                string toOrgID = Request.Form["deptmove"];
                Guid   toID;
                if (toOrgID.IsGuid(out toID) && borganize.Move(org.ID, toID))
                {
                    MyCreek.Platform.Log.Add("移动了组织机构", "将机构:" + org.ID + "移动到了:" + toID, MyCreek.Platform.Log.Types.组织机构);
                    string refreshID = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                    ViewBag.Script = "alert('移动成功!');parent.frames[0].reLoad('" + refreshID + "');parent.frames[0].reLoad('" + toOrgID + "')";
                }
                else
                {
                    ViewBag.Script = "alert('移动失败!');";
                }
            }

            //删除
            if (!Request.Form["Delete"].IsNullOrEmpty())
            {
                int i = borganize.DeleteAndAllChilds(org.ID);
                MyCreek.Platform.Log.Add("删除了组织机构及其所有下级共" + i.ToString() + "项", org.Serialize(), MyCreek.Platform.Log.Types.组织机构);
                string refreshID = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                ViewBag.Script = "alert('共删除了" + i.ToString() + "项!');parent.frames[0].reLoad('" + refreshID + "');";
            }

            if (org == null)
            {
                org = new MyCreek.Data.Model.Organize();
            }
            ViewBag.TypeRadios   = borganize.GetTypeRadio("Type", org.Type.ToString(), "validate=\"radio\"");
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", org.Status.ToString(), "validate=\"radio\"");

            return(View(org));
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MyCreek.Data.Model.Organize org       = null;
            MyCreek.Platform.Organize   borganize = new MyCreek.Platform.Organize();
            string id = Request.QueryString["id"];

            if (id.IsGuid())
            {
                org = borganize.Get(id.ToGuid());
            }

            if (IsPostBack)
            {
                //保存
                if (!Request.Form["Save"].IsNullOrEmpty() && org != null)
                {
                    string name         = Request.Form["Name"];
                    string type         = Request.Form["Type"];
                    string status       = Request.Form["Status"];
                    string chargeLeader = Request.Form["ChargeLeader"];
                    string leader       = Request.Form["Leader"];
                    string note         = Request.Form["note"];
                    string oldXML       = org.Serialize();
                    org.Name         = name.Trim();
                    org.Type         = type.ToInt(1);
                    org.Status       = status.ToInt(0);
                    org.ChargeLeader = chargeLeader;
                    org.Leader       = leader;
                    org.Note         = note.IsNullOrEmpty() ? null : note.Trim();

                    borganize.Update(org);
                    MyCreek.Platform.Log.Add("修改了组织机构", "", MyCreek.Platform.Log.Types.组织机构, oldXML, org.Serialize());
                    string rid = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');parent.frames[0].reLoad('" + rid + "');", true);
                }

                //移动
                if (!Request.Form["Move1"].IsNullOrEmpty() && org != null)
                {
                    string toOrgID = Request.Form["deptmove"];
                    Guid   toID;
                    if (toOrgID.IsGuid(out toID) && borganize.Move(org.ID, toID))
                    {
                        MyCreek.Platform.Log.Add("移动了组织机构", "将机构:" + org.ID + "移动到了:" + toID, MyCreek.Platform.Log.Types.组织机构);
                        string refreshID = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('移动成功!');parent.frames[0].reLoad('" + refreshID + "');parent.frames[0].reLoad('" + toOrgID + "')", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('移动失败!');", true);
                    }
                }

                //删除
                if (!Request.Form["Delete"].IsNullOrEmpty())
                {
                    int i = borganize.DeleteAndAllChilds(org.ID);
                    MyCreek.Platform.Log.Add("删除了组织机构及其所有下级共" + i.ToString() + "项", org.Serialize(), MyCreek.Platform.Log.Types.组织机构);
                    string refreshID = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('共删除了" + i.ToString() + "项!');parent.frames[0].reLoad('" + refreshID + "');", true);
                }
            }



            if (org != null)
            {
                this.Name.Value         = org.Name;
                this.TypeRadios.Text    = borganize.GetTypeRadio("Type", org.Type.ToString(), "validate=\"radio\"");
                this.StatusRadios.Text  = borganize.GetStatusRadio("Status", org.Status.ToString(), "validate=\"radio\"");
                this.ChargeLeader.Value = org.ChargeLeader;
                this.Leader.Value       = org.Leader;
                this.Note.Value         = org.Note;
            }
            else
            {
                this.TypeRadios.Text   = borganize.GetTypeRadio("Type", "", "validate=\"radio\"");
                this.StatusRadios.Text = borganize.GetStatusRadio("Status", "", "validate=\"radio\"");
            }
        }