Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FoWoSoft.Platform.Organize   borganize = new FoWoSoft.Platform.Organize();
            FoWoSoft.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"];

                FoWoSoft.Data.Model.Organize org1 = new FoWoSoft.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();
                }

                FoWoSoft.Platform.Log.Add("添加了组织机构", org1.Serialize(), FoWoSoft.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\"");
        }
Beispiel #2
0
        //重建组织时用
        public void AddOrganize(DataSet ds)
        {
            FoWoSoft.Platform.Guid_id guidIdService = new FoWoSoft.Platform.Guid_id();
            var dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var dr = dt.Rows[i];
                #region 部门编号转换成GUID
                string id = dr["BMBH"].ToString();

                var  guidId = guidIdService.Get(id);
                Guid org1ID;
                if (guidId == null)
                {
                    org1ID = GetGuid(id);

                    //插入对应表guid--id
                    FoWoSoft.Data.Model.Guid_id guidIdModel = new FoWoSoft.Data.Model.Guid_id()
                    {
                        GuidId = org1ID,
                        useId  = id
                    };
                    guidIdService.Add(guidIdModel);
                }
                else
                {
                    org1ID = guidId.GuidId;
                }
                dr["BMBH"] = org1ID;
                #endregion
                var orgrion = borganize.Get(org1ID);
                if (orgrion != null)
                {
                    continue;
                }
                #region 转上级编号为GUID
                id     = dr["SJBM"].ToString();
                guidId = guidIdService.Get(id);
                if (guidId == null)
                {
                    org1ID = GetGuid(id);
                    //插入对应表guid--id
                    FoWoSoft.Data.Model.Guid_id guidIdModel = new FoWoSoft.Data.Model.Guid_id()
                    {
                        GuidId = org1ID,
                        useId  = id
                    };
                    guidIdService.Add(guidIdModel);
                }
                else
                {
                    org1ID = guidId.GuidId;
                }
                dr["SJBM"] = org1ID;
                #endregion

                #region 插入组织结构
                FoWoSoft.Data.Model.Organize org = new FoWoSoft.Data.Model.Organize();

                org.ID       = Guid.Parse(dr["BMBH"].ToString());
                org.Name     = dr["BMMC"].ToString();
                org.Note     = null;
                org.Number   = ""; // org.Number + "," + org1ID.ToString().ToLower();
                org.ParentID = Guid.Parse(dr["SJBM"].ToString());
                org.Sort     = 0;  // borganize.GetMaxSort(org.ID);
                org.Status   = 0;
                org.Type     = 0;  // type.ToInt();
                org.Depth    = 0;  // org.Depth + 1;

                //using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                //  {

                borganize.Add(org);
                //更新父级[ChildsLength]字段
                //borganize.UpdateChildsLength(org.ID);
                // scope.Complete();
                // }
                #endregion
            }
        }