Exemple #1
0
        /// <summary>
        /// 提交,修改
        /// </summary>
        /// <param name="tandasEntity"></param>
        /// <param name="keyValue"></param>
        public void SubmitForm(ProfileAmenitiesMainWay_GovernEntity Entity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                Entity.Modify(keyValue);

                service.Update(Entity);
            }
            else
            {
                Entity.Create();

                service.Insert(Entity);
            }
        }
Exemple #2
0
        public void SubmitForm(ProfileAmenitiesGovernEntity Entity, string keyValue, string[] mainWayIds)
        {
            using (var db = new RepositoryBase().BeginTrans())
            {
                if (!string.IsNullOrEmpty(keyValue))//修改
                {
                    //删除之前无用数据
                    db.Update(Entity);

                    //删除关系表
                    string sql = "SELECT * FROM ProfileAmenitiesMainWay_Govern WHERE GovernId='" + keyValue + "'";
                    db.FindList <ProfileAmenitiesMainWay_GovernEntity>(sql).ForEach(d =>
                    {
                        db.Delete <ProfileAmenitiesMainWay_GovernEntity>(d);
                    });

                    ProfileAmenitiesMainWay_GovernEntity centreModle;
                    for (int i = 0; i < mainWayIds.Length; i++)
                    {
                        centreModle = new ProfileAmenitiesMainWay_GovernEntity();
                        centreModle.Create();
                        centreModle.MainWayId       = mainWayIds[i];
                        centreModle.F_CreatorUserId = Entity.F_Id;
                        centreModle.GovernId        = Entity.F_Id;
                        db.Insert(centreModle);
                    }
                }
                else
                {
                    db.Insert(Entity);

                    ProfileAmenitiesMainWay_GovernEntity centreModle;
                    for (int i = 0; i < mainWayIds.Length; i++)
                    {
                        centreModle = new ProfileAmenitiesMainWay_GovernEntity();
                        centreModle.Create();
                        centreModle.MainWayId = mainWayIds[i];
                        centreModle.GovernId  = Entity.F_Id;
                        db.Insert(centreModle);
                    }
                }
                db.Commit();
            }
        }