Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MyCreek.Platform.Organize   borganize = new MyCreek.Platform.Organize();
            MyCreek.Data.Model.Organize org       = null;
            string id     = Request.QueryString["id"];
            string name   = string.Empty;
            string type   = string.Empty;
            string status = string.Empty;
            string note   = string.Empty;

            Guid orgID;

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

            if (IsPostBack && org != null)
            {
                name   = Request.Form["Name"];
                type   = Request.Form["Type"];
                status = Request.Form["Status"];
                note   = Request.Form["note"];

                MyCreek.Data.Model.Organize org1 = new MyCreek.Data.Model.Organize();
                Guid org1ID = Guid.NewGuid();
                org1.ID       = org1ID;
                org1.Name     = name.Trim();
                org1.Note     = note.IsNullOrEmpty() ? null : note.Trim();
                org1.Number   = org.Number + "," + org1ID.ToString().ToLower();
                org1.ParentID = org.ID;
                org1.Sort     = borganize.GetMaxSort(org.ID);
                org1.Status   = status.IsInt() ? status.ToInt() : 0;
                org1.Type     = type.ToInt();
                org1.Depth    = org.Depth + 1;

                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    borganize.Add(org1);
                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(org.ID);
                    scope.Complete();
                }

                MyCreek.Platform.Log.Add("添加了组织机构", org1.Serialize(), MyCreek.Platform.Log.Types.组织机构);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;", true);
            }

            this.TypeRadios.Text   = borganize.GetTypeRadio("Type", type, "validate=\"radio\"");
            this.StatusRadios.Text = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
        }
Exemplo n.º 2
0
        public ActionResult BodyAdd(FormCollection collection)
        {
            MyCreek.Platform.Organize   borganize = new MyCreek.Platform.Organize();
            MyCreek.Data.Model.Organize org       = null;
            string id     = Request.QueryString["id"];
            string name   = string.Empty;
            string type   = string.Empty;
            string status = string.Empty;
            string note   = string.Empty;

            Guid orgID;

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

            if (collection != null && org != null)
            {
                name   = Request.Form["Name"];
                type   = Request.Form["Type"];
                status = Request.Form["Status"];
                note   = Request.Form["note"];

                MyCreek.Data.Model.Organize org1 = new MyCreek.Data.Model.Organize();
                Guid org1ID = Guid.NewGuid();
                org1.ID       = org1ID;
                org1.Name     = name.Trim();
                org1.Note     = note.IsNullOrEmpty() ? null : note.Trim();
                org1.Number   = org.Number + "," + org1ID.ToString().ToLower();
                org1.ParentID = org.ID;
                org1.Sort     = borganize.GetMaxSort(org.ID);
                org1.Status   = status.IsInt() ? status.ToInt() : 0;
                org1.Type     = type.ToInt();
                org1.Depth    = org.Depth + 1;

                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    borganize.Add(org1);
                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(org.ID);
                    scope.Complete();
                }

                MyCreek.Platform.Log.Add("添加了组织机构", org1.Serialize(), MyCreek.Platform.Log.Types.组织机构);
                ViewBag.Script = "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;";
            }
            ViewBag.TypeRadios   = borganize.GetTypeRadio("Type", type, "validate=\"radio\"");
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
            return(View());
        }