Ejemplo n.º 1
0
        public static bool AddOrUpdateCarBitGroup(ParkCarBitGroup model, out bool isAdd)
        {
            isAdd = false;
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IParkGrant      factory  = ParkGrantFactory.GetFactory();
            ParkCarBitGroup oldGroup = factory.GetParkCarBitGroup(model.PKID, model.CarBitName);

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                if (oldGroup == null)
                {
                    model.RecordID = GuidGenerator.GetGuidString();
                    isAdd          = true;
                    return(factory.AddParkCarBitGroup(model, dbOperator));
                }
                else
                {
                    try
                    {
                        dbOperator.BeginTransaction();
                        //factory.UpdateParkGrantPKLot(model.CarBitName,oldGroup.CarBitName, oldGroup.PKID, dbOperator);
                        model.RecordID = oldGroup.RecordID;
                        bool result = factory.UpdateParkCarBitGroup(oldGroup.RecordID, model.CarBitName, model.CarBitNum, dbOperator);
                        if (!result)
                        {
                            throw new MyException("修改车位组信息失败");
                        }
                        dbOperator.CommitTransaction();
                        return(result);
                    }
                    catch {
                        dbOperator.RollbackTransaction();
                        throw;
                    }
                }
            }
        }