Lankahotelsonline.com - new hotel reservation done with nopcommerce

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 14 años
http://www.lankahotelsonline.com is developed by me using nopcommerce and with simple modification it was ready for hotel reservation. ready to share once completed.

Thanks for nopcomerce team for great product. Thank you guys..

regards,

chinthaka
Hace 14 años
Great site and nice to see that you have accomplished to develop the functions needed to reserve rooms from one date to another. How do you handle the pricing when completing the order? [email protected].
Hace 14 años
i will do some changes to the existing application. for the moment i am trying to make lankahotelsonline.com popular. what i did here is play trick to make simply work. Much better solution which i work on will post later on. this is just a try.

changes productvarientingrid.ascx
=======================

  <div class="addinfo">
                    <table>
                        <tr>
                            <td align="right">
                                <asp:Label ID="Label1" runat="server" Text="Check In :"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="txtStartDate" />
                                <ajaxToolkit:CalendarExtender ID="cStartDateButtonExtender" runat="server" TargetControlID="txtStartDate"
                                    PopupButtonID="iStartDate" />
                                <asp:RequiredFieldValidator ID="vldNamereq" SetFocusOnError="true" ControlToValidate="txtStartDate"
                                    ErrorMessage="*" runat="server">
                                </asp:RequiredFieldValidator>
                                <asp:CompareValidator ID="CompareValidator3" runat="server" ControlToValidate="txtStartDate"
                                    ErrorMessage="Check out date cannot be early date then " Operator="GreaterThan"
                                    Type="Date"></asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="Label2" runat="server" Text="Check Out :"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="txtEndDate" EnableViewState="true" OnTextChanged="MakeUpdatable" />
                                <ajaxToolkit:CalendarExtender ID="cEndDateButtonExtender" runat="server" TargetControlID="txtEndDate"
                                    PopupButtonID="iEndDate" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEndDate"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtStartDate"
                                    ControlToValidate="txtEndDate" ErrorMessage="Check out date cannot be early date then Start date."
                                    Operator="GreaterThan" Type="Date"></asp:CompareValidator>
                                <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="txtStartDate"
                                    ControlToValidate="txtEndDate" ErrorMessage="Check out date cannot be early date then "
                                    Operator="GreaterThan" Type="Date"></asp:CompareValidator>
                            </td>
                        </tr>
                    </table>
                    <nopCommerce:NumericTextBox runat="server" ID="txtQuantity" Value="0" Enabled="false"
                        RequiredErrorMessage="Enter quantity" RangeErrorMessage="The value must be from 1 to 999999"
                        MinimumValue="1" MaximumValue="999999" Width="50"></nopCommerce:NumericTextBox>
                    <asp:Button ID="btnAddToCart" runat="server" Text="Add to cart" CommandName="AddToCart"
                        CommandArgument='<%#Eval("ProductVariantID")%>' SkinID="ProductVariantAddToCartButton">
                    </asp:Button>
                    <asp:Button ID="btnAddToWishlist" runat="server" Text="Add to wishlist"   CommandName="AddToWishlist"
                        CommandArgument='<%#Eval("ProductVariantID")%>' SkinID="ProductVariantAddToWishlistButton">
                    </asp:Button>
                </div>
=======================

productvarientingrid.cs
========================================
//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.Common;
using NopSolutions.NopCommerce.Common.Audit;
using NopSolutions.NopCommerce.Common.Configuration.Settings;
using NopSolutions.NopCommerce.Common.Localization;
using NopSolutions.NopCommerce.Common.Media;
using NopSolutions.NopCommerce.Common.Orders;
using NopSolutions.NopCommerce.Common.Products;
using NopSolutions.NopCommerce.Common.Utils;

namespace NopSolutions.NopCommerce.Web.Modules
{
    public partial class ProductVariantsInGridControl : BaseNopUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
              
                
                BindData();
            }
         }

        protected void MakeUpdatable(object sender, EventArgs e)
        {
            foreach (RepeaterItem ri in rptVariants.Items)
            {
                TextBox tbstart = (TextBox)ri.FindControl("txtStartDate");
                TextBox tbsEnd = (TextBox)ri.FindControl("txtEndDate");
                NumericTextBox tbQuantity = (NumericTextBox)ri.FindControl("txtQuantity");
                SimpleTextBox txtTextOption = (SimpleTextBox)ri.FindControl("txtTextOption") ;
                tbstart.Enabled = true;
                tbsEnd.Enabled = true;
                if (tbstart.Text != "" && tbsEnd.Text != "")
                {
                    DateTime dts = Convert.ToDateTime(tbstart.Text.ToString());
                    DateTime dte = Convert.ToDateTime(tbsEnd.Text.ToString());
                    double datediff = dte.ToOADate() - dts.ToOADate();
                    tbQuantity.Value = (int)datediff;
  
Hace 14 años
It is unfair that  sri lanka not included as location to select by nopcommerce
Hace 14 años
[code]
//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.Common;
using NopSolutions.NopCommerce.Common.Audit;
using NopSolutions.NopCommerce.Common.Configuration.Settings;
using NopSolutions.NopCommerce.Common.Localization;
using NopSolutions.NopCommerce.Common.Media;
using NopSolutions.NopCommerce.Common.Orders;
using NopSolutions.NopCommerce.Common.Products;
using NopSolutions.NopCommerce.Common.Utils;

namespace NopSolutions.NopCommerce.Web.Modules
{
    public partial class ProductVariantsInGridControl : BaseNopUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
              
                
                BindData();
            }
         }

        protected void MakeUpdatable(object sender, EventArgs e)
        {
            foreach (RepeaterItem ri in rptVariants.Items)
            {
                TextBox tbstart = (TextBox)ri.FindControl("txtStartDate");
                TextBox tbsEnd = (TextBox)ri.FindControl("txtEndDate");
                NumericTextBox tbQuantity = (NumericTextBox)ri.FindControl("txtQuantity");
                SimpleTextBox txtTextOption = (SimpleTextBox)ri.FindControl("txtTextOption") ;
                tbstart.Enabled = true;
                tbsEnd.Enabled = true;
                if (tbstart.Text != "" && tbsEnd.Text != "")
                {
                    DateTime dts = Convert.ToDateTime(tbstart.Text.ToString());
                    DateTime dte = Convert.ToDateTime(tbsEnd.Text.ToString());
                    double datediff = dte.ToOADate() - dts.ToOADate();
                    tbQuantity.Value = (int)datediff;
                    txtTextOption.Text = "Check in :" + dts.ToShortDateString() + " Check Out :" + dte.ToShortDateString() + " " + datediff.ToString() + " Days";
                  
                }
            }
        }
        protected void BindData()
        {
            
            Product product = ProductManager.GetProductByID(ProductID);
            if (product != null)
            {
                ProductVariantCollection productVariants = product.ProductVariants;
                if (productVariants.Count > 0)
                {
                    rptVariants.DataSource = productVariants;
                    rptVariants.DataBind();
                }
                else
                { this.Visible = false; }


            }
            else
            {
                this.Visible = false;
            }

            foreach (RepeaterItem ri in rptVariants.Items)
            {
                TextBox tbstart = (TextBox)ri.FindControl("txtStartDate");
                TextBox tbsEnd = (TextBox)ri.FindControl("txtEndDate");
                tbstart.Text = DateTime.Now.AddDays(5).ToShortDateString();
                tbsEnd.Text = DateTime.Now.AddDays(6).ToShortDateString();
                NumericTextBox tbQuantity = (NumericTextBox)ri.FindControl("txtQuantity");
                SimpleTextBox txtTextOption = (SimpleTextBox)ri.FindControl("txtTextOption");
              
                //CompareValidator compvalend = (CompareValidator)ri.FindControl("CompareValidator2");
                //compvalend.ValueToCompare = DateTime.Now.AddDays(6).ToShortDateString();
                //compvalend.ErrorMessage = "All hotels were reserved untill " + DateTime.Now.AddDays(6).ToShortDateString();

                CompareValidator compvalstart = (CompareValidator)ri.FindControl("CompareValidator3");
                compvalstart.ValueToCompare = DateTime.Now.AddDays(5).ToShortDateString();
                compvalstart.ErrorMessage = "All hotels were reserved untill " + DateTime.Now.AddDays(5).ToShortDateString();

                if (tbstart.Text != "" && tbsEnd.Text != "")
                {
                    DateTime dts = Convert.ToDateTime(tbstart.Text.ToString());
                    DateTime dte = Convert.ToDateTime(tbsEnd.Text.ToString());
                    double datediff = dte.ToOADate() - dts.ToOADate();
                    tbQuantity.Value = (int)datediff;
                    txtTextOption.Text = "Check in :" + dts.ToShortDateString() + " Check Out :" + dte.ToShortDateString() + " " + datediff.ToString() + " Days";
                    txtTextOption.Visible = false;

                }

            }
            
        }

        protected void rptVariants_OnItemCommand(Object source, RepeaterCommandEventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
            if (e.CommandName == "AddToCart" || e.CommandName == "AddToWishlist")
            {
                NumericTextBox txtQuantity = e.Item.FindControl("txtQuantity") as NumericTextBox;
                Label productVariantID = e.Item.FindControl("ProductVariantID") as Label;
                SimpleTextBox txtTextOption = e.Item.FindControl("txtTextOption") as SimpleTextBox;
                ProductAttributesControl ctrlProductAttributes = e.Item.FindControl("ctrlProductAttributes") as ProductAttributesControl;
                Label lblError = e.Item.FindControl("lblError") as Label;

                try
                {
                    if (e.CommandName == "AddToCart")
                    {
                        string addToCartWarning = string.Empty;
                        ShoppingCartManager.AddToCart(ShoppingCartTypeEnum.ShoppingCart,
                            Convert.ToInt32(productVariantID.Text),
                            ctrlProductAttributes.SelectedAttributeIDs,
                            txtTextOption.Text, txtQuantity.Value, ref addToCartWarning);
                        if (string.IsNullOrEmpty(addToCartWarning))
            
Hace 14 años
Hi
do you think you can help? tahnks in advance

=====================

Hi

First of all thanks for your hard work and sharing this great software. I don't know where to post
my question so I'll try here hoping I'll get an answer.

I've download version 1.11 from don't remember where (maybe codeproject), installed on my local
everything worked perfect, installed on another computer with a dynamic dns, worked perfectly.

Now I finally installed on a real web hosting but I'm having issues with sending emails. If the user
is not authenticated the "recover password message" is delivered without a problem. If I register
I don't get the welcome message. After authenticated can't send email to a friend about any product.

I can send email from the global settings page without a problem. Bottom line is:

1) email works from recover password page (user not authenticated)
2) email works from the global settings page (user admin authenticated)
3) email does not work on any other circunstance

I'm a .net programmer with 25+ plus years experience (c#, asp.net 7+)

please help
thanks
Hace 14 años
Hi Ivan,

set global setting  as below

Store Admin Email:  email   
Store Admin Email Display Name:  name of store  
Host:  ip or hostname   
Port:   25  or as given
User: [email protected]   user email address  
Password: password for u r mail account   
Enable SSL:    
Use default credentials:  keep unchecked


make default credentials unchecked

best luck,

chinthaka
Hace 14 años
Hi Thanks for your reply

I end up changing the code and everything is working fine now. I'm moving on to
enable paypal, do you have experience with that? Can you help? Thanks in advance and good luck with your project,
looks very nice.
Hace 14 años
Hi All

I've changed my code for the email to work. Below is the code snippet
module: Libraries -> Nop.Common -> Messages -> MessageManager.cs
my version is 1.11
this method should be near line 693

        public static void SendEmail(string Subject, string Body, MailAddress From, MailAddress To, List<string> bcc, List<string> cc)
        {
            MailMessage message = new MailMessage();
            message.From = From;
            message.To.Add(To);
            if (null != bcc)
                foreach (string address in bcc)
                {
                    if (!String.IsNullOrEmpty(address))
                        message.Bcc.Add(address);
                }
            if (null != cc)
                foreach (string address in cc)
                {
                    if (!String.IsNullOrEmpty(address))
                        message.CC.Add(address);
                }
            message.Subject = Subject;
            message.Body = Body;
            message.IsBodyHtml = true;

            // new code start here

            if (Debugger.IsAttached == true)
            {
                SmtpClient smtpClient = new SmtpClient();
                smtpClient.UseDefaultCredentials = AdminEmailUseDefaultCredentials;
                smtpClient.Host = AdminEmailHost;
                smtpClient.Port = AdminEmailPort;
                smtpClient.EnableSsl = AdminEmailEnableSsl;
                if (AdminEmailUseDefaultCredentials)
                    smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
                else
                    smtpClient.Credentials = new NetworkCredential(AdminEmailUser, AdminEmailPassword);
                smtpClient.Send(message);
            }
            else
            {


// the lines below are the most important, lines above are for developers setting up email from local iis or else

                SmtpClient smtpClient = new SmtpClient();
                smtpClient.Credentials = new System.Net.NetworkCredential("your email here", "your password here");
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.Port = 25;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Host = "localhost";
                smtpClient.Send(message);
            }

            //smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; // developer machine iis
            // new code end here


        }


hope this helps
Hace 14 años
Hi Chintaka,

Could you possibly advise which file the code snippet was from (you posted on Wednesday, August 19, 2009 7:45 PM)?

I am very interested in your changes as i am looking at using nopCommerce to handle reservations for vacation homes. Thanks for sharing your modifications.

Thanks again.

Regards,
Andrew
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.