public void Save(CustomerPriceAgreement PriceAgreement)
        {
            PriceAgreement.AccountCode = account.AccountCode;
            PriceAgreement.BranchCode = branch.BranchCode;
            PriceAgreement.BrandCode = brand.BrandCode;

            //TEMPORARY DATE AND USER SAVING
            PriceAgreement.DateCreated = DateTime.Now;
            PriceAgreement.CreatedBy = "SYSTEM";
            PriceAgreement.ModifiedBy = "SYSTEM";
            PriceAgreement.DateModified = DateTime.Now;
            //TEMPORARY DATE AND USER SAVING

            using (DbManager db = new DbManager())
            {
                try
                {
                    if (PriceAgreement.RecordNo != 0)
                    {
                        Accessor.Query.Update(db, PriceAgreement);
                    }
                    else
                    {
                        Accessor.Query.Insert(db, PriceAgreement);
                    }
                }
                catch (Exception except)
                {
                    throw new System.ArgumentException(except.Message);
                }
            }
        }
 public void Delete(Forwarder FORWARDER)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, FORWARDER);
     }
 }
示例#3
0
		public IDbDataParameter[] GetParameters(DbManager db, object obj)
		{
			var parameters = new IDbDataParameter[_parameters.Count];

			for (var i = 0; i < _parameters.Count; i++)
			{
				var info = _parameters[i];

				//parameters[i] = db.Parameter(info.ParameterName, info.MemberMapper.GetValue(obj));

				var mmi = info.MemberMapper.MapMemberInfo;
				var val = info.MemberMapper.GetValue(obj);

				if (val == null && mmi.Nullable/* && mmi.NullValue == null*/)
				{
					//replace value with DbNull
					val = DBNull.Value;
				}

				if (mmi.IsDbTypeSet)
				{
					parameters[i] = mmi.IsDbSizeSet 
						? db.Parameter(info.ParameterName, val, info.MemberMapper.DbType, mmi.DbSize) 
						: db.Parameter(info.ParameterName, val, info.MemberMapper.DbType);
				}
				else
				{
					parameters[i] = db.Parameter(info.ParameterName, val);
				}
			}

			return parameters;
		}
示例#4
0
 protected override void TearDown()
 {
     using (var dbManager = new DbManager("PerformanceTest"))
         dbManager
             .SetCommand("TRUNCATE TABLE Simplests")
             .ExecuteNonQuery();
 }
 public void Save(PricePoint Object)
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Insert(dbm, Object);
     }
 }
 public void DeleteRequest(PulloutHeader PH)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, PH);
     }
 }
 public void DeleteByMemoID(int MemoID)
 {
     using (DbManager dbm = new DbManager())
     {
         dbm.SetCommand(string.Format("DELETE FROM GENMEMODTL WHERE GENMEMOID = {0}", MemoID)).ExecuteNonQuery();
     }
 }
 public void Delete(Message Message)
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Delete(dbm, Message);
     }
 }
 public List<Message> Messages()
 {
     using (DbManager dbm = new DbManager())
     {
         return Accessor.Query.SelectAll<Message>(dbm);
     }
 }
 public void Delete(Memo memo)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, memo);
     }
 }
示例#11
0
		public void Test()
		{
			using (DbManager db = new DbManager())
			{
				List<Person> list = db
					.SetCommand(@"
						SELECT
							ps.*,
							d.Taxonomy,
							p.Diagnosis,
							CASE
								WHEN d.PersonID IS NOT NULL THEN 'D'
								WHEN p.PersonID IS NOT NULL THEN 'P'
							END as PersonType
						FROM
							Person ps
								LEFT JOIN Doctor  d ON d.PersonID = ps.PersonID
								LEFT JOIN Patient p ON p.PersonID = ps.PersonID
						ORDER BY
							ps.PersonID")
					.ExecuteList<Person>();

				Assert.AreEqual(list[0].GetType(), /*[a]*/typeof(Doctor)/*[/a]*/);
				Assert.AreEqual(list[1].GetType(), /*[a]*/typeof(Patient)/*[/a]*/);

				if (list.Count > 2)
					Assert.AreEqual(list[2].GetType(), typeof(Person));
			}
		}
示例#12
0
		// Insert, Update, and Delete a person.
		//
		public Person GetPersonByID(DbManager db, int id)
		{
			return db
				./*[a]*/SetCommand/*[/a]*/("SELECT * FROM Person WHERE PersonID = @id",
					db./*[a]*/Parameter/*[/a]*/("@id", id))
				.ExecuteObject<Person>();
		}
示例#13
0
		public void OutputParameterTest()
		{
			using (DbManager db = new DbManager())
			{
				/*
				 * CREATE Procedure Scalar_OutputParameter
				 *     @outputInt    int         = 0  output,
				 *     @outputString varchar(50) = '' output
				 * AS
				 * BEGIN
				 *     SET @outputInt = 12345
				 *     SET @outputString = '54321'
				 * END
				 */

				db
					.SetSpCommand("Scalar_OutputParameter",
						db./*[a]*/OutputParameter/*[/a]*/("@outputInt",    1),
						db./*[a]*/OutputParameter/*[/a]*/("@outputString", "1"))
					.ExecuteNonQuery();

				Assert.AreEqual(12345,   (int)   db./*[a]*/Parameter("@outputInt").   Value/*[/a]*/);
				Assert.AreEqual("54321", (string)db./*[a]*/Parameter("@outputString").Value/*[/a]*/);
			}
		}
 public void Delete(DeliveryReceipt DeliveryReceipt)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, DeliveryReceipt);
     }
 }
 public void ConfirmCustomerReturnSlip(CustomerReturnSlipConfirmation crs)
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Insert(dbm, crs);
     }
 }
 public void Delete(SalesInvoice SalesInvoice)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, SalesInvoice);
     }
 }
示例#17
0
        public FullSqlQuery(DbManager dbManager, bool ignoreLazyLoad = false, MappingOrder mappingOrder = MappingOrder.ByColumnIndex)
            : base(dbManager)
        {
            dbManager.MappingSchema = new FullMappingSchema(dbManager, ignoreLazyLoad: ignoreLazyLoad, mappingOrder: mappingOrder, parentMappingSchema: dbManager.MappingSchema);

            _ignoreLazyLoad = ignoreLazyLoad;
        }
		public void SetCommandWorksCorrectlyWithSprocParameterPrefixSet()
		{
			var oldPrefix = MySqlDataProvider.SprocParameterPrefix;
			MySqlDataProvider.SprocParameterPrefix = "_";

			try
			{
				using (var db = new DbManager(ProviderName.MySql))
				{
					var person = db.SetCommand(
							"SELECT * FROM Person WHERE PersonID = ?PersonID",
							db.Parameter("?PersonID", 1))
						.ExecuteObject<Person>();

					Assert.IsNotNull(person);
					Assert.AreEqual(1, person.ID);

					var person2 = db.SetCommand(
							"SELECT * FROM Person WHERE FirstName = ?firstName AND LastName = ?lastName",
							db.CreateParameters(person))
						.ExecuteObject<Person>();

					Assert.IsNotNull(person2);
					Assert.AreEqual(person, person2);
				}
			}
			finally
			{
				MySqlDataProvider.SprocParameterPrefix = oldPrefix;
			}
		}
 public void Delete( GeneralMemoConcessionDetail GMConcessionDetail )
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Delete(dbm,GMConcessionDetail);
     }
 }
 public void Delete(Size size)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, size);
     }
 }
 public void Save(GeneralMemoConcessionDetail Object)
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Insert(dbm, Object);
     }
 }
 public void Delete(Category category)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, category);
     }
 }
 public void DeleteByMemoNo(string MemoNo)
 {
     using (DbManager dbm = new DbManager())
     {
         dbm.SetCommand(string.Format("DELETE FROM PRICEPOINT WHERE MEMONO = '{0}'", MemoNo)).ExecuteNonQuery();
     }
 }
 public void Delete(WholesalerContractClass WholesalerContract)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, WholesalerContract);
     }
 }
 public List<Customer> Customers()
 {
     using (DbManager db = new DbManager())
     {
         return Accessor.Query.SelectAll<Customer>(db);
     }
 }
 public void Delete(Garment garment)
 {
     using (DbManager db = new DbManager())
        {
        Accessor.Query.Delete(db, garment);
        }
 }
 public void DeleteCustomerForwarder(ForwarderCustomer ForwarderCustomer)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, ForwarderCustomer);
     }
 }
示例#28
0
		public void Test1()
		{
			List<Parent> parents = new List<Parent>();
			MapResultSet[] sets = new MapResultSet[2];

			sets[0] = new MapResultSet(typeof(Parent), parents);
			sets[1] = new MapResultSet(typeof(Child));

			sets[0].AddRelation(sets[1], "ParentID", "ParentID", "Children");
			sets[1].AddRelation(sets[0], "ParentID", "ParentID", "Parent");

			using (DbManager db = new DbManager())
			{
				db
					.SetCommand(_parentChildquery)
					.ExecuteResultSet(sets);
			}

			foreach (Parent p in parents)
			{
				Assert.That(p.IsDirty == false);

				foreach (Child c in p.Children)
					Assert.That(c.IsDirty == false);
			}
		}
 public void Delete(Customer customer)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, customer);
     }
 }
 public void Delete(CustomerPriceAgreement PriceAgreement)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, PriceAgreement);
     }
 }