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

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

                service.Insert(Entity);
            }
        }
Exemplo n.º 2
0
        public void SubmitForm(ProfileAmenitiesWatersEntity Entity, string keyValue, string[] mainWayIds)
        {
            using (var db = new RepositoryBase().BeginTrans())
            {
                if (!string.IsNullOrEmpty(keyValue))//修改
                {
                    //删除之前无用数据
                    string sql = "SELECT * FROM ProfileAmenitiesMainWay_Waters WHERE WatersId='" + keyValue + "'";
                    db.FindList <ProfileAmenitiesMainWay_WatersEntity>(sql).ForEach(d =>
                    {
                        db.Delete <ProfileAmenitiesMainWay_WatersEntity>(d);
                    });

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

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