Exemplo n.º 1
0
		private void detach_UserBillingAddresses(UserBillingAddress entity)
		{
			this.SendPropertyChanging();
			entity.Country = null;
		}
Exemplo n.º 2
0
        protected void Button_Click(object sender, EventArgs e)
        {
            var button = sender as Button;

            if (button == null)
                return;

            var commandName = button.CommandName;

            if (string.IsNullOrEmpty(commandName))
                return;

            int? id;
            switch (commandName.ToLower())
            {
                case "ship":
                    {
                        id = TextHelper.ToInteger(button.CommandArgument);

                        if (id == null)
                            return;

                        //Set Selected Address Id
                        SelectedAddressId = (int)id;

                        //Go to next index
                        wiz_cart.MoveTo(wiz_cart.WizardSteps[1]);

                        //Bind Cart
                        GvCart_DataBind();
                    }
                    break;

                case "nextship":
                    {
                        var userBillingAddress = new UserBillingAddress
                        {
                            FullName = txt_fullname.Text,
                            AddressLine1 = txt_address1.Text,
                            AddressLine2 = txt_address2.Text,
                            City = txt_city.Text,
                            State = txt_state.Text,
                            CountryId = TextHelper.ToInteger(ddl_country.SelectedValue),
                            PostalCode = txt_postalcode.Text,
                            PhoneNumber = txt_phone.Text,
                            UserId = LoggedInUserId,
                            IsActive = true//Get from session
                        };

                        int returnId;

                        if (!_userBillingAddress.Insert(userBillingAddress, out returnId))
                            return;

                        SelectedAddressId = returnId; //Set selectedAddressId so that system won't re-add the data again

                        //Bind Cart
                        GvCart_DataBind();

                        //Clear all fields
                        txt_fullname.Text = string.Empty;
                        txt_address1.Text = string.Empty;
                        txt_address2.Text = string.Empty;
                        txt_city.Text = string.Empty;
                        txt_state.Text = string.Empty;
                        txt_phone.Text = string.Empty;
                        ddl_country.SelectedIndex = 0;

                        //Move to next step
                        MoveToNextStep(1);
                    }
                    break;

                case "nextpayment":
                    {
                        MoveToNextStep(2);
                    }
                    break;
                case "makepayment":
                    {
                        //Check if shopping cart is empty
                        if (ShoppingCart == null || ShoppingCart.Count == 0)
                            return;

                        //Check if address is selected
                        if (SelectedAddressId == 0)
                            return;

                        //Use transaction to make sure all queries run without error
                        using (var ts = new TransactionScope())
                        {
                            var order = new Order
                            {
                                CardNumber = txt_cardNumber.Text,
                                SecurityNumber = TextHelper.ToInteger(txt_securityNumber.Text),
                                NameOnCard = txt_nameOnCard.Text,
                                ExpirationMonth = TextHelper.ToInteger(ddl_month.SelectedValue),
                                ExpirationYear = TextHelper.ToInteger(ddl_year.SelectedValue),
                                UserBillingAddressId = SelectedAddressId,
                                UserId = LoggedInUserId, //get from session
                                OrderItems = GetOrderItems()
                            };

                            int orderNumber;
                            if (_orderClass.Insert(order, out orderNumber))
                            {
                                Session["Order"] = orderNumber;

                                ts.Complete();
                            }
                        }

                        ShoppingCart = null;

                        MoveToNextStep(3);
                    }
                    break;

                case "remove":
                    id = TextHelper.ToInteger(button.CommandArgument);

                    if (id == null)
                        return;

                    if (_userBillingAddress.Delete((int)id))
                    {
                        DlAddress_DataBind();
                    }
                    break;
            }
        }
Exemplo n.º 3
0
		private void attach_UserBillingAddresses(UserBillingAddress entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}
Exemplo n.º 4
0
 partial void DeleteUserBillingAddress(UserBillingAddress instance);
Exemplo n.º 5
0
 partial void UpdateUserBillingAddress(UserBillingAddress instance);
Exemplo n.º 6
0
 partial void InsertUserBillingAddress(UserBillingAddress instance);
Exemplo n.º 7
0
        protected void Button_Click(object sender, EventArgs e)
        {
            var button = sender as Button;

            if (button == null)
                return;

            var commandName = button.CommandName;

            if (string.IsNullOrEmpty(commandName))
                return;

            switch (commandName.ToLower())
            {
                case "update":
                    {
                        //Update data
                        var roomBilling = new RoomBilling
                        {
                            RoomId = Id,
                            UserId = TextHelper.ToInteger(ddl_patients.SelectedValue),
                            RoomBillingEquipments = GetRoomBillingEquipments(),
                        };

                        var isRoomVacant = _objRoomBilling.IsRoomVacant(Id);

                        if (!isRoomVacant)
                            roomBilling.RoomBillingId = _objRoomBilling.GetIdByRoomId(Id);

                        if (isRoomVacant ? _objRoomBilling.Insert(roomBilling) : UpdateRoom(roomBilling))
                        {
                            //Redirect
                            Redirect("~/Admin/Room/");
                        }
                    }
                    break;

                case "checkout":
                    {
                        var userId = TextHelper.ToInteger(ddl_patients.SelectedValue);

                        //Load user billing address
                        LoadUserAddresses(userId);

                        //Disable additional equipments
                        SetAdditionalEquipmentTextbox(false);

                        //Disable Checkout button
                        btn_checkout.Enabled = false;

                        //Disable Update Button
                        btn_update.Enabled = false;

                        //Disable dropdownlist
                        ddl_patients.Enabled = false;

                        pnl_address.Visible = true;

                        up_address.Update();
                    }
                    break;

                case "newbill":
                    {
                        using (var transactionScope = new TransactionScope())
                        {
                            var userId = TextHelper.ToInteger(ddl_patients.SelectedValue);

                            if (userId == null || userId <= 0)
                                return;

                            var userBillingAddress = new UserBillingAddress
                            {
                                FullName = txt_fullname.Text,
                                AddressLine1 = txt_address1.Text,
                                AddressLine2 = txt_address2.Text,
                                City = txt_city.Text,
                                State = txt_state.Text,
                                CountryId = TextHelper.ToInteger(ddl_country.SelectedValue),
                                PostalCode = txt_postalcode.Text,
                                PhoneNumber = txt_phone.Text,
                                UserId = (int)userId
                            };

                            int addressId;

                            if (!_objUserBillingAddress.Insert(userBillingAddress, out addressId))
                                return;

                            //Get room billing Id
                            var roomBillingId = _objRoomBilling.GetIdByRoomId(Id);

                            //return if room billing id does not exist
                            if (roomBillingId <= 0)
                                return;

                            int checkOutId;

                            if (!_objRoomBilling.CheckOutRoom(Id, addressId, out checkOutId))
                                return;

                            transactionScope.Complete();

                            Response.Redirect(string.Format("ViewBill.aspx?id={0}", checkOutId));
                        }

                    }
                    break;

                case "existingbill":
                    {
                        var addressId = TextHelper.ToInteger(button.CommandArgument);

                        if (addressId == null)
                            return;

                        int checkOutId;

                        if (!_objRoomBilling.CheckOutRoom(Id, (int)addressId, out checkOutId))
                            return;

                        Response.Redirect(string.Format("ViewBill.aspx?id={0}", checkOutId));
                    }
                    break;

                case "cancel":

                        //Disable additional equipments
                        SetAdditionalEquipmentTextbox(true);

                        //Disable Checkout button
                        btn_checkout.Enabled = true;

                        //Disable Update Button
                        btn_update.Enabled = true;

                        //Disable dropdownlist
                        ddl_patients.Enabled = true;

                        pnl_address.Visible = false;

                        up_address.Update();
                    break;
            }
        }