Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net.Mail
Imports System.Web.Mail
Imports System.Data.SqlTypes

Partial Class product_notfound_inquiry
    Inherits System.Web.UI.Page
    Shared Category(10) As String
    Shared i1 As Integer
    Dim value As String
    Dim objProduct As New clsProductInquiry '------Updated By Prachi - 19/08/2009------

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            '------Updated By Prachi - 19/08/2009 - to bind dropdown with table------
            FillContactPersonTitle()
            FillQtyRequiredUnit()
            '------end update------

            'Response.Write(Session("ProductCode"))
            txtCompanyName.Focus()
            i1 = 0
            If Not Session("catid") = Nothing Then
                'Dim catid As String
                'catid = ReturnValue("Select Product_CategoryID from Product_Master where Product_Kid= '" & RemoveLiterals(Session("ProductCode").ToString()) & "'and Product_IsDeleted='0'")
                ' get categoryid according productid
                FillCategoryName(Session("catid").ToString.Trim)
                'getlbl()
            End If

            If Not Session("brandid") = Nothing Then
                lblCat.Text = ReturnValue("Select Brand_Name From Brand_Master where Brand_Kid ='" & RemoveLiterals(Session("brandid").ToString.Trim) & "' and Brand_Isdeleted = '0'")
            End If

            ' ''btnSubmit.Style.Add("background-image", Page.ResolveUrl("~/Images/submit.gif"))
            ' ''btnCancel.Style.Add("background-image", Page.ResolveUrl("~/Images/cancel.gif"))
            ' ''btnClose.Style.Add("background-image", Page.ResolveUrl("~/Images/close1.gif"))
            btnCancel.Attributes.Add("onclick", "javascript:window.close();")
            'Fill_Combo("SELECT distinct Unit_Kid, Unit_Name, Unit_Flag FROM Unit_Master WHERE Unit_Flag = N'Qty' and unit_IsDeleted='0' order by unit_name", ddlQtyType)
            Image1.Attributes.Add("onmouseOver", "javascript:over(this)")
            btnClose.Attributes.Add("onclick", "javascript:window.close();")

            '------updated by Prachi - 26/08/2009 - to allow key like backspace, delete------
            'txtCountryCode.Attributes.Add("onkeypress", "return numericonly(event,this);")
            'txtCityCode.Attributes.Add("onkeypress", "return numericonly(event,this);")
            'txtPhoneNo.Attributes.Add("onkeypress", "return numericonly(event,this);")
            'txtCountryCodeM.Attributes.Add("onkeypress", "return numericonly(event,this);")
            'txtMobileNo.Attributes.Add("onkeypress", "return numericonly(event,this);")
            'txtQtyRequired.Attributes.Add("onkeypress", "return decimalonly(event,this);")
            txtCountryCode.Attributes.Add("blockNonNumbers", "return blockNonNumbers(this,event,false,false);")
            txtCityCode.Attributes.Add("onkeypress", "return blockNonNumbers(this,event,false,false);")
            txtPhoneNo.Attributes.Add("onkeypress", "return blockNonNumbers(this,event,false,false);")
            txtCountryCodeM.Attributes.Add("onkeypress", "return blockNonNumbers(this,event,false,false);")
            txtMobileNo.Attributes.Add("onkeypress", "return blockNonNumbers(this,event,false,false);")
            txtQtyRequired.Attributes.Add("onkeypress", "return blockNonNumbers(this,event,true,false);")
            '------end update------

            'txtCityCode.Attributes.Add("onkeydown", "return testmobile(document.getElementById('txtCountryCode'));")
            'txtMobileNo.Attributes.Add("onkeydown", "return testmobile(document.getElementById('txtCountryCodeM'));")
            'txtPhoneNo.Attributes.Add("onkeydown", "return testphone(document.getElementById('txtCountryCode'),document.getElementById('txtCityCode'));")
            txtCountryCode.Text = "91"
            txtCountryCodeM.Text = "91"
            tbl1.Visible = False
            value = Request.QueryString("flag")

            If Session("BuyId") <> Nothing And value = "Buyer" Then
                fillbuyerinfo()
            End If
            'Image1.Attributes.Add("onmouseOut", "javascript:out(this)")
        End If
        lblMsg.Visible = False
    End Sub

    Protected Sub fillbuyerinfo()
        Dim dt As DataTable
        Dim str As String
        str = "select BuyerRegister_Name,BuyerRegister_EmailId,BuyerRegister_CompanyName,BuyerRegister_TelephoneNo,BuyerRegister_MobileNo from BuyerRegister where BuyerRegister_Kid='" & Session("BuyId") & "'"
        dt = ReturnDataTable(str)
        txtCompanyName.Text = dt.Rows(0).Item("BuyerRegister_CompanyName")
        txtContactPersonName.Text = dt.Rows(0).Item("BuyerRegister_Name")
        txtEmailID.Text = dt.Rows(0).Item("BuyerRegister_EmailId")
        txtQtyRequired.Text = "1"
        Dim tele As String
        tele = dt.Rows(0).Item("BuyerRegister_TelephoneNo")
        Dim teleno = Split(tele, "-")
        txtCityCode.Text = teleno(1)
        txtPhoneNo.Text = teleno(2)
        Dim mob As String
        mob = dt.Rows(0).Item("BuyerRegister_MobileNo")
        Dim mobno = Split(mob, "-")
        txtMobileNo.Text = mobno(1)
    End Sub

    'Public Sub getlbl()
    '    lblProductName.Text = ReturnValue("Select Product_Name From Product_Master where Product_Kid = '" & RemoveLiterals(Session("ProductCode").ToString.Trim) & "' and Product_IsDeleted ='0'")
    '    lblProductCode.Text = ReturnValue("Select Product_Code From Product_Master where Product_Kid = '" & RemoveLiterals(Session("ProductCode").ToString.Trim) & "' and Product_IsDeleted ='0'")
    '    lblModelNo.Text = ReturnValue("Select Product_ModelNo From Product_Master where Product_Kid = '" & RemoveLiterals(Session("ProductCode").ToString.Trim) & "' and Product_IsDeleted ='0'")
    'End Sub

    Public Sub FillCategoryName(ByVal Catid As String)
        ' Fill category herarchy in label
        Dim dt As DataTable
        dt = ReturnDataTable("Select * From Category_Master Where Category_Kid ='" & Catid & "' and Category_Isdeleted = '0'")
        Dim ParentId As String
        ParentId = dt.Rows(0).Item(3).ToString()
        If ParentId = "Root Category" Then
            Dim j As Integer
            Category(i1) = dt.Rows(0).Item(2).ToString() & "  >  "
            For j = 0 To i1
                lblCat.Text += Category(i1)
                i1 = i1 - 1
            Next
            Exit Sub
        Else
            Category(i1) = dt.Rows(0).Item(2).ToString() & "  >  "
            i1 = i1 + 1
            FillCategoryName(dt.Rows(0).Item(3).ToString())
        End If
        dt.Clear()
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Try
            'If CheckValid() = True Then
            ' lblError.Visible = False

            If txtQtyRequired.Text <> "" Then
                If ddlQtyType.SelectedIndex = 0 Then
                    showmessage("Please Select Unit.", lblMsg)
                    ScriptManager1.SetFocus(ddlQtyType)
                    Exit Sub
                End If
            End If

            If txtRequiredDate.Text <> "" Then
                Try
                    Dim dt As DateTime
                    dt = Format$(Convert.ToDateTime(txtRequiredDate.Text.ToString), "")

                    If dt <= DateTime.Now Then
                        showmessage("Please Select Proper Future Date.", lblMsg)
                        ScriptManager1.SetFocus(txtRequiredDate.Text)
                        Exit Sub
                    End If
                Catch ex As Exception
                    showmessage("Please Enter Correct Date.", lblMsg)
                    ScriptManager1.SetFocus(txtRequiredDate.Text)
                    Exit Sub
                End Try
            End If

            If txtPhoneNo.Text = "" And txtMobileNo.Text = "" Then
                showmessage("Plese Give Atleast One Contact Details. Like Phone No or Mobile No", lblMsg)
                Exit Sub
            End If

            If txtEmailID.Text = "" Then
                showmessage("Please Enter EmailID", lblMsg)
                Exit Sub
            End If

            If chkcall.Checked = True Then
                If txtPhoneNo.Text = "" And txtMobileNo.Text = "" Then
                    showmessage("Plese Give Atleast One Contact No. For Contact.", lblMsg)
                    Exit Sub
                End If
            End If

            Dim con As New SqlConnection
            con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
            Dim cmd As New SqlCommand
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "Product_NotFound_Inquiry_Proc" ' storeprocedure
            cmd.Connection = con
            cmd.Parameters.Add(New SqlParameter("@PNFI_Kid", SqlDbType.NVarChar, 10)).Value = NewPrimaryKey(Me)
            cmd.Parameters.Add(New SqlParameter("@PNFI_Code", SqlDbType.NVarChar, 25)).Value = GenerateCode()

            If Not Session("catid") = Nothing Then
                cmd.Parameters.Add(New SqlParameter("@PNFI_CategoryID", SqlDbType.NVarChar, 10)).Value = Session("catid")
            Else
                cmd.Parameters.Add(New SqlParameter("@PNFI_BrandID", SqlDbType.NVarChar, 10)).Value = Session("brandid").ToString.Replace("'", "")
            End If

            cmd.Parameters.Add(New SqlParameter("@PNFI_CompanyName", SqlDbType.NVarChar, 200)).Value = txtCompanyName.Text
            cmd.Parameters.Add(New SqlParameter("@PNFI_ContactPersonName", SqlDbType.NVarChar, 200)).Value = Trim(txtContactPersonName.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_PhoneCountryCode", SqlDbType.NVarChar, 10)).Value = Trim(txtCountryCode.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_PhoneCityCode", SqlDbType.NVarChar, 10)).Value = Trim(txtCityCode.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_PhoneNo", SqlDbType.NVarChar, 20)).Value = Trim(txtPhoneNo.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_MobileCountryCode", SqlDbType.NVarChar, 10)).Value = Trim(txtCountryCodeM.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_MobileNo", SqlDbType.NVarChar, 20)).Value = Trim(txtMobileNo.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_EmailId", SqlDbType.NVarChar, 50)).Value = Trim(txtEmailID.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_ProductName", SqlDbType.NVarChar, 200)).Value = Trim(txtProductName.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_QtyRequired", SqlDbType.NVarChar, 10)).Value = Trim(txtQtyRequired.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_QtyRequiredUnit", SqlDbType.NVarChar, 10)).Value = Trim(ddlQtyType.SelectedItem.Value.ToString)
            cmd.Parameters.Add(New SqlParameter("@PNFI_RequiredByDate", SqlDbType.NVarChar, 50)).Value = Trim(txtRequiredDate.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_RequiredPlace", SqlDbType.NVarChar, 200)).Value = Trim(txtRequiredPlace.Text)
            cmd.Parameters.Add(New SqlParameter("@PNFI_SpecificRequirement", SqlDbType.NVarChar, 200)).Value = Trim(txtSpecificRequirement.Text)
            If chkcall.Checked = True Then
                cmd.Parameters.Add(New SqlParameter("@PNFI_FlagCall", SqlDbType.NVarChar, 1)).Value = "Y"
            Else
                cmd.Parameters.Add(New SqlParameter("@PNFI_FlagCall", SqlDbType.NVarChar, 1)).Value = "N"
            End If
            cmd.Parameters.Add(New SqlParameter("@PNFI_SendOtherSupplier", SqlDbType.Bit)).Value = 1
            cmd.Parameters.Add(New SqlParameter("@PNFI_Status", SqlDbType.NVarChar, 50)).Value = "Pending"
            cmd.Parameters.Add(New SqlParameter("@PNFI_InquiryDate", SqlDbType.DateTime)).Value = Date.Now
            cmd.Parameters.Add(New SqlParameter("@PNFI_FinancialYearId", SqlDbType.NVarChar, 10)).Value = ""
            cmd.Parameters.Add(New SqlParameter("@PNFI_CompanyId", SqlDbType.NVarChar, 10)).Value = ""
            cmd.Parameters.Add(New SqlParameter("@PNFI_UserId", SqlDbType.NVarChar, 10)).Value = ""
            cmd.Parameters.Add(New SqlParameter("@FormName", SqlDbType.NVarChar, 50)).Value = "Product Not Found Inquiry"
            cmd.Parameters.Add(New SqlParameter("@Mode", SqlDbType.NVarChar, 10)).Value = "Insert" ' mode

            If con.State = ConnectionState.Open Then ' check connection state
                con.Close()
            End If
            con.Open()
            cmd.ExecuteNonQuery()
            con.Close() ' close connection
            con.Dispose()
            sendmail()
            customeremail()
            'tbl.Visible = False
            'tbl1.Visible = True

            '------Updated By Prachi - 19/08/2009 - to insert in v-office prospect bank------
            Dim strProspectCode As String
            strProspectCode = GenerateProspectCode()
            objProduct.Mode = "Insert_ProductInquiry"
            objProduct.CmdType = "Insert"
            objProduct.ProspectCode = strProspectCode
            objProduct.CompanyName = txtCompanyName.Text.Trim
            objProduct.Title = ddlTitle.SelectedValue.ToString
            objProduct.ContactPersonFirstName = txtContactPersonName.Text.Trim
            objProduct.ContactPersonMiddleName = txtMiddleName.Text.Trim
            objProduct.ContactPersonLastName = txtLastName.Text.Trim
            objProduct.TelephoneNo = txtCountryCode.Text.Trim + txtCityCode.Text.Trim + txtPhoneNo.Text.Trim
            objProduct.MobileNo = txtCountryCodeM.Text.Trim + txtMobileNo.Text.Trim
            objProduct.EmailAddress = txtEmailID.Text.Trim
            objProduct.ProductName = txtProductName.Text.Trim
            objProduct.QtyRequired = txtQtyRequired.Text.Trim.ToString
            objProduct.QtyRequiredUnit = ddlQtyType.SelectedValue
            If txtRequiredDate.Text = "" Then
                objProduct.RequiredByDate = System.Data.SqlTypes.SqlDateTime.Null
            Else
                objProduct.RequiredByDate = CType(txtRequiredDate.Text.Trim, System.Data.SqlTypes.SqlDateTime)
            End If
            objProduct.RequiredPlace = txtRequiredPlace.Text.Trim
            objProduct.SpecificRequirement = txtSpecificRequirement.Text.Trim
            Dim Category_ID As String = ""
            Category_ID = ReturnValue("WITH ParentCategory(Category_Kid,Category_Name,Category_ParentId) AS (SELECT Category_Master1.Category_Kid, Category_Master1.Category_Name, Category_Master1.Category_ParentId FROM dbo.Category_Master AS Category_Master1 WHERE Category_Master1.Category_Kid = '" & RemoveLiterals(Session("catid")) & "' UNION ALL SELECT		Category_Master2.Category_Kid, Category_Master2.Category_Name, Category_Master2.Category_ParentId FROM Category_Master AS Category_Master2 , ParentCategory AS ParentCategory WHERE Category_Master2.Category_Kid = ParentCategory.Category_ParentId ) SELECT Category_Kid FROM ParentCategory WHERE Category_Parentid = 'Root Category'")
            objProduct.CategoryID = IIf(Category_ID = "", Nothing, Category_ID)
            objProduct.BrandID = IIf(Session("brandid") Is Nothing, Nothing, Convert.ToString(Session("brandid")))
            objProduct.ProductCode = Nothing
            objProduct.ProductModelNo = Nothing
            objProduct.OtherSupplier = 1
            objProduct.MarketPrice = Nothing

            clsProductInquiry.Insert_ProductInquiry(objProduct)
            '------end update------
        Catch ex As Exception
            showmessage(ex.Message, lblMsg)                                'Display the Error Message
        End Try
    End Sub

    '------Updated By Prachi - 19/08/2009 - to assign enum variables for dropdown------
    Private Sub FillContactPersonTitle()
        For Each i As clsProductInquiry.ContactPersonTitle In [Enum].GetValues(GetType(clsProductInquiry.ContactPersonTitle))
            ddlTitle.Items.Add(New ListItem(i.ToString(), Convert.ToInt32(i)))
        Next
    End Sub '------end update------

    '------Updated By Prachi - 20/08/2009 - to generate prospect code------
    Private Function GenerateProspectCode() As String
        Try
            Dim maxId As String
            objProduct.Mode = "Select_MaxProspectCode"
            objProduct.CmdType = "Select"
            maxId = clsProductInquiry.Select_MaxProspectCode(objProduct)

            Dim arrCode(5) As Integer
            Dim code As String
            Dim prefix As String
            Dim charc As Char
            prefix = maxId.Substring(0, 5)
            code = maxId.Substring(5)

            Dim i As Integer
            If code = "99999" Then
                If prefix.Contains("Z") Then
                    i = prefix.IndexOf("Z")
                    charc = prefix.Chars(i - 1)
                    charc = Convert.ToChar(Asc(charc) + 1)
                    prefix = prefix.Substring(0, i - 1) + charc + prefix.Substring(i)
                    code = "00001"
                Else
                    charc = prefix.Chars(prefix.Length - 1)
                    charc = Convert.ToChar(Asc(charc) + 1)
                    prefix = prefix.Substring(0, prefix.Length - 1) + charc
                    code = "00001"
                End If
            Else
                code = Format(code + 1, "00000")
            End If
            prefix = prefix + code
            Return prefix
        Catch ex As Exception

        End Try
    End Function '------end update------

    '------Updated By Prachi - 20/08/2009 - to fill QtyRequiredUnit combo------
    Private Sub FillQtyRequiredUnit()
        Try
            Dim dt As New DataTable
            objProduct.Mode = "Select_QtyRequiredUnit"
            objProduct.CmdType = "Select"
            dt = clsProductInquiry.Select_QtyRequiredUnit(objProduct)

            ddlQtyType.DataSource = dt
            ddlQtyType.DataTextField = "Unit"
            ddlQtyType.DataValueField = "Unit_Kid"
            ddlQtyType.DataBind()
            ddlQtyType.Items.Insert(0, New ListItem("Select", "0"))
        Catch ex As Exception

        End Try
    End Sub '------end update------

    Public Sub sendmail()
        Try
            'Dim msg As New MailMessage
            'If txtEmailID.Text = "" Then
            '    msg.From = "contact@atcomaart.com"
            'Else
            '    msg.From = "contact@atcomaart.com <contact@atcomaart.com>"
            'End If

            'msg.To = "jjjitiya@gmail.com"
            Dim lt As New Label
            lt.Text = "<h1> Inquiry From " & txtEmailID.Text & " </h1> </br>"

            If Not Session("catid") = Nothing Then
                lt.Text = "Product Category :    "
            Else
                lt.Text = "Product Brand :    "
            End If

            lt.Text += lblCat.Text
            lt.Text += "<br/>Product Name :    "
            lt.Text += "<b>" & txtProductName.Text & "</b>"
            'lt.Text += "<br/>Product ModelNo. :    "
            'lt.Text += "<b>" & lblModelNo.Text & "</b>"
            lt.Text += "<br/>Company Name :    "
            lt.Text += "<b>" & txtCompanyName.Text & "</b>"
            lt.Text += "<br/>Company Contact Person Name :    "
            lt.Text += "<b>" & txtContactPersonName.Text & "</b>"

            If txtCityCode.Text = "" And txtPhoneNo.Text = "" Then
            Else
                lt.Text += "<br/>Phone No :    "
                lt.Text += "<b>" & txtCountryCode.Text & "-" & txtCityCode.Text & "-" & txtPhoneNo.Text & "</b>"
            End If

            If txtMobileNo.Text <> "" Then
                lt.Text += "<br/>Mobile No :    "
                lt.Text += "<b>" & txtCountryCodeM.Text & "-" & txtMobileNo.Text & "</b>"
            End If

            If txtEmailID.Text = "" Then
                lt.Text += "<br/>Email ID :    "
                lt.Text += "<b>" & txtEmailID.Text & "</b>"
            End If

            If txtQtyRequired.Text <> "" Then
                lt.Text += "<br/>Quantity Required :    "
                lt.Text += "<b>" & txtQtyRequired.Text & "   " & ddlQtyType.SelectedItem.Text & "</b>"
            End If

            If txtRequiredDate.Text <> "" Then
                lt.Text += "<br/>Required By Date :    "
                lt.Text += "<b>" & txtRequiredDate.Text & "</b>"
            End If

            If txtRequiredPlace.Text <> "" Then
                lt.Text += "<br/>Place At Which Required :    "
                lt.Text += "<b>" & txtRequiredPlace.Text & "</b>"
            End If

            If txtSpecificRequirement.Text <> "" Then
                lt.Text += "<br/>Specific Requirement :    "
                lt.Text += "<b>" & txtSpecificRequirement.Text & "</b>"
            End If

            If chkcall.Checked = True Then
                lt.Text += "<br/>Call Me :    "
                lt.Text += "<b> Please Call Me. </b>"
            Else
                lt.Text += "<br/>Call Me :    "
                lt.Text += "<b> NO </b>"
            End If

            'msg.BodyFormat = MailFormat.Html
            'msg.Body = lt.Text
            'msg.Subject = "Product Not Found Inquiry."
            'SmtpMail.SmtpServer = ""
            '' Dim i As System.Web.Mail
            'SmtpMail.Send(msg)
            ' ''Dim MyMailMessage As New MailMessage()
            '' ''From requires an instance of the MailAddress type
            ' ''MyMailMessage.From = New MailAddress("contact@atcomaart.com", txtEmailID.Text)
            '' ''To is a collection of MailAddress types
            ' ''MyMailMessage.To.Add("contact@atcomaart.com")
            '' ''MyMailMessage.CC.Add(New MailAddress("pankajmishra2006@gmail.com", "CC Name"))
            '' ''MyMailMessage.Bcc.Add(New MailAddress("pankaj.mishra@edeskservices.com", "eDesk Services Ltd."))
            ' ''MyMailMessage.Subject = "Product Not Found Inquiry."
            ' ''MyMailMessage.Body = lt.Text
            ' ''MyMailMessage.IsBodyHtml = True
            ' ''MyMailMessage.Priority = MailPriority.High
            ' ''Dim smtpclient As New SmtpClient("smtp.rediffmailpro.com")
            ' ''smtpclient.Credentials = New Net.NetworkCredential("contact@atcomaart.com", "contact@55017_atco")
            ' ''smtpclient.Send(MyMailMessage)
            MailSender.SendEmail("contact@atcomaart.com", "Product Not Found Inquiry.", lt.Text, MailFormat.Html, "")
            tbl.Visible = False
            tbl1.Visible = True
        Catch ex As Exception
            showmessage(ex.Message, lblMsg)
        End Try
    End Sub

    Public Sub customeremail()
        Try
            Dim StrMail As String = ""
            'Dim objmessage As New MailMessage()
            StrMail = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">"
            StrMail = StrMail & "<html>" & "<head>" & "<meta http-equiv=""Content-Type"""
            StrMail = StrMail & "<content=""text/html""; charset=""iso-8859-1"">"
            StrMail = StrMail & "<title>Contact Us</title>" & "</head><body><P align=left>"
            StrMail = StrMail & "<table width='739' border='0' cellspacing='0' cellpadding='0' align='left' style='BORDER-RIGHT: #8c8e81 thin solid; BORDER-TOP: #8c8e81 thin solid; FONT-SIZE: 9pt;  BORDER-LEFT: #8c8e81 thin solid; BORDER-BOTTOM: #8c8e81 thin solid; FONT-FAMILY: Verdana' >"
            StrMail = StrMail & "<tr>" & "<td>" & "Dear Client,"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<br> We highly appreciate your time and efforts to visit our website and inquire with us on your product and supplies needs. We understand that you are looking forward to finding out the products and brands under one roof."
            StrMail = StrMail & "<br><br> For this product we are still registering supplier.<br/> We will get back to you soon.Thanks for inquiry & visiting our website"
            StrMail = StrMail & "<br> THANK YOU."
            ''StrMail = StrMail & "<br> We highly appreciate your time and efforts to visit our website and enquire with us on your product and supplies needs. We understand that you are looking forward to finding out the products, brands and services of best quality, price and service under one roof. "
            ''StrMail = StrMail & "<br><br><br> ATCOMAART! Brings you tremendous value and wealth addition to your business by being your representative as PURCHASE/MATERIALS Department by which your purchase cycle is shortened, lag time is reduced, inventories are controlled, products at your doorstep, and administrative costs are reduced significantly.  Our alternative channels of marketing gives you perfect range of products with complete details, comparisons, and choice."
            ''StrMail = StrMail & "<br><br><br> Currently you can register with us BUYER and complete the details of your company and requirements on our website. We are coming soon with our industrial retail warehouse all over the country to give a wider range of choice of products and be much closer to you. "
            ''StrMail = StrMail & "<br><br><br> For any questions and concerns get back to us."
            ''StrMail = StrMail & "<br><br><br> Looking forward to long term relationship with you!. <br><br>"
            'StrMail = StrMail & "<B>" & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "New Supplier Registration on Atcomaart Web Site:-" & "</B>"
            ''StrMail = StrMail & "<B>" & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Details of the Your Inquiry are as follows:" & "</B>"
            ''StrMail = StrMail & "<br>" & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Product Name " & "&nbsp;&nbsp;&nbsp;" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtProductName.Text & ""
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Company Name " & "&nbsp;&nbsp;&nbsp;" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtCompanyName.Text.Trim & ""
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Telephone No.-" & "&nbsp;&nbsp;&nbsp;" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtCountryCode.Text & "-" & txtCityCode.Text & "-" & txtPhoneNo.Text & "</B>"
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Mobile No.-" & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtCountryCodeM.Text & "-" & txtMobileNo.Text & "</B>"
            ''StrMail = StrMail & "<br>"
            ''If chkcall.Checked = True Then
            ''    StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call Me :    "
            ''    StrMail = StrMail & "<b> Please Call Me. </b>"
            ''Else
            ''    StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call Me :    "
            ''    StrMail = StrMail & "<b> NO </b>"
            ''End If
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Quantity Required " & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtQtyRequired.Text & "   " & ddlQtyType.SelectedItem.Text & "</B>"
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Required By Date " & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtRequiredDate.Text & "</B>"
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Place At Which Required " & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtRequiredPlace.Text & "</B>"
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "EmailId-" & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtEmailID.Text & "</B>"
            ''StrMail = StrMail & "<br>"
            ''StrMail = StrMail & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & "Specific Requirement " & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" & ":" & "&nbsp;&nbsp;&nbsp;&nbsp; " & txtSpecificRequirement.Text & "</B>"
            StrMail = StrMail & "<br><br>"
            StrMail = StrMail & "<br> ATCOMAART Team"
            StrMail = StrMail & "<br> <a href='http://www.atcomaart.com/'>www.atcomaart.com</a>"
            StrMail = StrMail & "<br> <a href='mailto:contact@atcomaart.com'>contact@atcomaart.com</a> <br><br>"
            '  StrMail = StrMail & "<br> <a href='mailto:ceo@atcomaart.com'> ceo@atcomaart.com</a><br><br>"
            StrMail = StrMail & "</td></tr></table></p></body></html>"
            'Dim MyMailMessage As New MailMessage()
            ''From requires an instance of the MailAddress type
            'MyMailMessage.From = New MailAddress("contact@atcomaart.com", "Atcomaart Ltd.")
            ''To is a collection of MailAddress types
            'MyMailMessage.To.Add(txtEmailID.Text)
            ''MyMailMessage.CC.Add(New MailAddress("pankajmishra2006@gmail.com", "CC Name"))
            ''MyMailMessage.Bcc.Add(New MailAddress("pankaj.mishra@edeskservices.com", "eDesk Services Ltd."))
            'MyMailMessage.Subject = "Inquiry for " & txtProductName.Text & " from www.atcomaart.com website ."
            'MyMailMessage.Body = StrMail
            'MyMailMessage.IsBodyHtml = True
            'MyMailMessage.Priority = MailPriority.High
            'Dim smtpclient As New SmtpClient("smtp.rediffmailpro.com")
            'smtpclient.Credentials = New Net.NetworkCredential("contact@atcomaart.com", "vikram")
            'smtpclient.Send(MyMailMessage)
            MailSender.SendEmail(txtEmailID.Text, "Inquiry for " & txtProductName.Text & " from www.atcomaart.com website .", StrMail, MailFormat.Html, "")
        Catch ex As Exception
        End Try
    End Sub

    Private Function GenerateCode() As String
        ' generate kid and code
        Try
            Dim i As String
            Dim qry As String
            Dim code As String
            'txtBranchNetworkKid.Text = Trim(NewPrimaryKey(Me))
            i = "1"
            i = Format(Val(i), "000")
            While True
                code = "PNFI" & "/" & Year(Date.Today) & "/" & Format(Month(Date.Today), "00") & "/" & Day(Date.Today) & "/" & i
                qry = "Select count(*) from Product_NotFound_Inquiry where PNFI_Code='" & code & "'"
                If IsAlreadyPresent(qry) Then
                    i = (Val(i) + 1).ToString
                    i = Format(Val(i), "000")
                Else
                    Return code
                    Exit Function
                End If
            End While
        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "StrKeyVal")     'Display the Error Message
        End Try
    End Function
End Class
