Beispiel #1
0
		private void AddAddress(int AddressType, string firstName, string lastName, string email)
		{
			BPAddresses bpAddresses = new BPAddresses();
			BEAddresses.tbl_AddressesRow address;
			DSAddresses = new BEAddresses();
	
			// Add a Address
			address = DSAddresses.tbl_Addresses.Newtbl_AddressesRow();
	
			//all content to be updated/inserted between here
			address.CustomerID = CustomerID;
			address.AddressType = AddressType;
	
			address.AddressLine1 = "";
			address.AddressLine2 = "";
			if (AddressType == 1)
			{
				address.AddressFirstName = "";
				address.AddressLastName = "";
				address.AddressEmail = "";
			}
			else
			{
				address.AddressFirstName = firstName;
				address.AddressLastName = lastName;
				address.AddressEmail = email;
			}
			address.AddressPhone = "";
			address.AddressCity = "";
			address.AddressProvinceID = 1;
			address.AddressCountryID = 38;
			address.AddressPostalCode = "";
	
			address.DateModified = DateTime.Now;
			address.ModifiedByAdminID = Convert.ToInt32(CustomerID);
			//all content to be updated/inserted between here			
			//Add new Address
			address.DateCreated = DateTime.Now;
			DSAddresses.tbl_Addresses.Addtbl_AddressesRow(address);
	
			bpAddresses.Update(DSAddresses);
		}
		private void GetShippingAddressInfo()
		{
			BPAddresses bp = new BPAddresses();
			BEAddresses ds = bp.SelectByCustomerIDAndByAddressType(CustomerID, 1);

			if (ds.tbl_Addresses.Count > 0)
			{
				BEAddresses.tbl_AddressesRow address = ds.tbl_Addresses[0];

				ShippingAddressID = address.AddressID;
				txtShippingFirstName.Text = address.AddressFirstName;
				txtShippingLastName.Text = address.AddressLastName;
				txtShippingLine1.Text = address.AddressLine1;
				if (!address.IsAddressLine2Null())
				{
					txtShippingLine2.Text = address.AddressLine2;
				}
				if (!address.IsAddressEmailNull())
				{
					txtShippingEmail.Text = address.AddressEmail;
				}
				txtShippingPhone.Text = address.AddressPhone;
				txtShippingCity.Text = address.AddressCity;

				if (ddlShippingProvinceID.Items.FindByValue(address.AddressProvinceID.ToString()) != null)
				{
					ddlShippingProvinceID.SelectedValue = address.AddressProvinceID.ToString();
				}
				if (ddlShippingCountryID.Items.FindByValue(address.AddressCountryID.ToString()) != null)
				{
					ddlShippingCountryID.SelectedValue = address.AddressCountryID.ToString();
				}
				txtShippingPostalCode.Text = address.AddressPostalCode;
			}
		}
		private void UpdateAddress(int AddressID, int AddressType)
		{
			string AddressFirstName, AddressLastName, AddressLine1, AddressLine2, AddressEmail, AddressPhone, AddressCity, AddressPostalCode;
			int AddressProvinceID, AddressCountryID;

			if(AddressType == 0)
			{
				AddressFirstName = txtBillingFirstName.Text ;
				AddressLastName = txtBillingLastName.Text;
				AddressLine1 = txtBillingLine1.Text;
				AddressLine2 = txtBillingLine2.Text;
				AddressEmail = txtBillingEmail.Text;
				AddressPhone = txtBillingPhone.Text;
				AddressCity = txtBillingCity.Text;
				AddressProvinceID = Convert.ToInt32(ddlBillingProvinceID.SelectedValue);
				AddressCountryID = Convert.ToInt32(ddlBillingCountryID.SelectedValue);
				AddressPostalCode = txtBillingPostalCode.Text;
			}
			else
			{
				AddressFirstName = txtShippingFirstName.Text ;
				AddressLastName = txtShippingLastName.Text;
				AddressLine1 = txtShippingLine1.Text;
				AddressLine2 = txtShippingLine2.Text;
				AddressEmail = txtShippingEmail.Text;
				AddressPhone = txtShippingPhone.Text;
				AddressCity = txtShippingCity.Text;
				AddressProvinceID = Convert.ToInt32(ddlShippingProvinceID.SelectedValue);
				AddressCountryID = Convert.ToInt32(ddlShippingCountryID.SelectedValue);
				AddressPostalCode = txtShippingPostalCode.Text;
			}

			BPAddresses bp = new BPAddresses();
			BEAddresses.tbl_AddressesRow address;
			DSAddresses = new BEAddresses();
	
			if (AddressID == 0)
			{
				// Add a Address
				address = DSAddresses.tbl_Addresses.Newtbl_AddressesRow();
			}
			else
			{
				// Edit a Address
				DSAddresses = bp.SelectAddressesByID(AddressID);
				address = DSAddresses.tbl_Addresses.FindByAddressID(AddressID);				
			}
			//all content to be updated/inserted between here
			address.AddressFirstName = AddressFirstName;
			address.AddressLastName = AddressLastName;
			address.AddressLine1 = AddressLine1;
			address.AddressLine2 = AddressLine2;
			address.AddressEmail = AddressEmail;
			address.AddressPhone = AddressPhone;
			address.AddressCity = AddressCity;
			address.AddressProvinceID = AddressProvinceID;
			address.AddressCountryID = AddressCountryID;
			address.AddressPostalCode = AddressPostalCode;

			address.DateModified = DateTime.Now;
			address.ModifiedByAdminID = Convert.ToInt32(CarrielUser.CarrielIdentity.MemberID);
			//all content to be updated/inserted between here			
			if (AddressID == 0)
			{
				//Add new Address
				address.DateCreated = DateTime.Now;
				address.AddressType = AddressType;
				address.CustomerID = CustomerID;

				DSAddresses.tbl_Addresses.Addtbl_AddressesRow(address);
			}
	
			bp.Update(DSAddresses);
		}
		private void GetShippingAddressInfo()
		{
			BPAddresses bp = new BPAddresses();
			BEAddresses ds = bp.SelectByCustomerIDAndByAddressType(CustomerID, 1);

			if (ds.tbl_Addresses.Count > 0)
			{
				BEAddresses.tbl_AddressesRow address = ds.tbl_Addresses[0];

				ShippingAddressID = address.AddressID;
				lblShippingFirstName.Text = address.AddressFirstName;
				lblShippingLastName.Text = address.AddressLastName;
				lblShippingLine1.Text = address.AddressLine1;
				if (!address.IsAddressLine2Null())
				{
					lblShippingLine2.Text = address.AddressLine2;
				}
				if (!address.IsAddressEmailNull())
				{
					lblShippingEmail.Text = address.AddressEmail;
					ShippingEmail = address.AddressEmail;
				}
				lblShippingPhone.Text = address.AddressPhone;
				lblShippingCity.Text = address.AddressCity;
				lblShippingProvinceName.Text = address.ProvinceName;
				lblShippingCountryName.Text = address.CountryName;
				lblShippingPostalCode.Text = address.AddressPostalCode;
			}
		}