Пример #1
0
        public int Delete(ChildOrderableBunk value)
        {
            string sql = "DELETE FROM [T_ChildOrderableBunk] WHERE [ID]=@ID";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("ID", value.Id);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Пример #2
0
        public static void AddChildrenOrderableBunk(ChildOrderableBunkView childOrderableBunkView, string account)
        {
            var childOrderableBunk = ChildOrderableBunk.GetChildOrderableBunk(childOrderableBunkView);

            if (QueryChildOrderableBunk(childOrderableBunk.AirlineCode, childOrderableBunk.BunkCode) != null)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException(string.Format("航空公司[{0}]的舱位[{1}]已存在", childOrderableBunk.AirlineCode.Value, childOrderableBunk.BunkCode.Value));
            }
            ChildOrderableBunkCollection.Instance.Add(childOrderableBunk.Id, childOrderableBunk);
            saveAddLog("儿童可预订舱位", childOrderableBunk.ToString(), childOrderableBunk.Id.ToString(), account);
        }
Пример #3
0
        public int Update(ChildOrderableBunk value)
        {
            string sql = "UPDATE [dbo].[T_ChildOrderableBunk] SET [Airline]=@AIRLINE,[Bunk]=@BUNK,[Discount]=@DISCOUNT WHERE [Id]=@ID";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("ID", value.Id);
                dbOperator.AddParameter("AIRLINE", value.AirlineCode.Value);
                dbOperator.AddParameter("BUNK", value.BunkCode.Value);
                dbOperator.AddParameter("DISCOUNT", value.Discount);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Пример #4
0
        public int Insert(ChildOrderableBunk value)
        {
            string sql = "INSERT INTO [T_ChildOrderableBunk]([ID],[AIRLINE],[BUNK],[Discount]) VALUES(@ID,@AIRLINE,@BUNK,@DISCOUNT)";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("ID", value.Id);
                dbOperator.AddParameter("AIRLINE", value.AirlineCode.Value);
                dbOperator.AddParameter("BUNK", value.BunkCode.Value);
                dbOperator.AddParameter("DISCOUNT", value.Discount);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Пример #5
0
        public IEnumerable <KeyValuePair <Guid, ChildOrderableBunk> > Query()
        {
            string sql    = "SELECT [Id],[Airline],[Bunk],[Discount] FROM [dbo].[T_ChildOrderableBunk]";
            var    result = new List <KeyValuePair <Guid, ChildOrderableBunk> >();

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                using (var reader = dbOperator.ExecuteReader(sql)) {
                    while (reader.Read())
                    {
                        ChildOrderableBunk item = new ChildOrderableBunk(reader.GetGuid(0));
                        item.AirlineCode = reader.GetString(1);
                        item.BunkCode    = reader.GetString(2);
                        item.Discount    = reader.GetDecimal(3);
                        result.Add(new KeyValuePair <Guid, ChildOrderableBunk>(item.Id, item));
                    }
                }
            }
            return(result);
        }
Пример #6
0
        public static void UpdateChildrenOrderableBunk(Guid id, ChildOrderableBunkView childOrderableBunkView, string account)
        {
            var childOrderableBunk         = ChildOrderableBunk.GetChildOrderableBunk(id, childOrderableBunkView);
            var originalChildOrderableBunk = QueryChildOrderableBunk(id);

            if (null == originalChildOrderableBunk)
            {
                throw new ChinaPay.Core.CustomException("原儿童可预订舱位不存在");
            }
            var sameBunk = QueryChildOrderableBunk(childOrderableBunk.AirlineCode, childOrderableBunk.BunkCode);

            if (sameBunk != null && sameBunk.Id != id)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException(string.Format("航空公司[{0}]的舱位[{1}]已存在", childOrderableBunk.AirlineCode.Value, childOrderableBunk.BunkCode.Value));
            }
            var originalContent = originalChildOrderableBunk.ToString();

            ChildOrderableBunkCollection.Instance.Update(childOrderableBunk.Id, childOrderableBunk);
            saveUpdateLog("儿童可预订舱位", originalContent, childOrderableBunk.ToString(), childOrderableBunk.Id.ToString(), account);
        }