Click here to Skip to main content
15,891,943 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionRe: How to write to fileOutputStream mapped to physical file c# Pin
jkirkerx17-Apr-15 13:04
professionaljkirkerx17-Apr-15 13:04 
AnswerRe: How to write to fileOutputStream mapped to physical file c# Pin
Tridip Bhattacharjee18-Apr-15 7:48
professionalTridip Bhattacharjee18-Apr-15 7:48 
AnswerRe: How to write to fileOutputStream mapped to physical file c# Pin
jkirkerx19-Apr-15 12:09
professionaljkirkerx19-Apr-15 12:09 
QuestionMake image appear after div, and next dive appear after image Pin
indian14316-Apr-15 9:29
indian14316-Apr-15 9:29 
AnswerRe: Make image appear after div, and next dive appear after image Pin
jkirkerx16-Apr-15 13:24
professionaljkirkerx16-Apr-15 13:24 
QuestionBulk insert using table value parameter hangs my application Pin
Malikdanish15-Apr-15 21:04
professionalMalikdanish15-Apr-15 21:04 
AnswerRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx16-Apr-15 8:58
professionaljkirkerx16-Apr-15 8:58 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
Malikdanish16-Apr-15 9:04
professionalMalikdanish16-Apr-15 9:04 
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
    If Not Page.IsValid Then Return

    Dim blnIsUpdate As Boolean = False

    Dim hasedBytes As Byte()
    Dim strPassword As String = String.Empty
    Dim md5Hasher As New MD5CryptoServiceProvider()

    If Not litUserId.Text.Trim().Length.Equals(0) Then blnIsUpdate = True

    Dim cnnContact As New SqlConnection(AppSettings("DbSqlPortal"))
    Dim cmdContact As New SqlCommand("spAdminSaveUsers", cnnContact)

    Dim IDs As Integer = Nothing
    Dim trnContact As SqlTransaction = Nothing

    cmdContact.CommandType = CommandType.StoredProcedure

    hasedBytes = md5Hasher.ComputeHash(New UTF8Encoding().GetBytes((txtPassword.Text.Trim() & txtEmail.Text.Trim())))
    ' GetDistrictID()

    'If GetDistrictId() > 0 Then
    '    DisplayMessage(Me.Master.MessageBox, "A User with same District and Same user role  already exists.", "Record Exists", MessageBoxTypes.Warning)
    'Else

    Try
        With cmdContact.Parameters

            If blnIsUpdate Then

                .Add("@UserId", SqlDbType.BigInt).Value = CInt(litUserId.Text.Trim())

            Else

                .Add("@UserId", SqlDbType.BigInt).Value = DBNull.Value

            End If

            .Add("@FullName", SqlDbType.NVarChar).Value = txtFullName.Text.Trim()
            .Add("@Email", SqlDbType.NVarChar).Value = txtEmail.Text.Trim()
            .Add("@Password", SqlDbType.VarChar).Value = base64Encode(txtPassword.Text)

            'txtPassword.Text.Trim()
            'Convert.ToBase64String(hasedBytes)

            .Add("@SecurityQuestion", SqlDbType.VarChar).Value = ddlSecurityQuestions.SelectedItem.Text
            .Add("@SecurityAnswer", SqlDbType.VarChar).Value = txtAnswer.Text.Trim()
            .Add("@UserTypes", SqlDbType.TinyInt).Value = ddlUserTypes.SelectedValue
            .Add("@IsActive", SqlDbType.Bit).Value = chkActive.Checked

            .Add("@DistrictId", SqlDbType.TinyInt).Value = CheckBoxList1.SelectedValue

            .Add("@IsAdmin", SqlDbType.Bit).Value = chkAdmin.Checked

            .Add("@IPAddress", SqlDbType.VarChar).Value = Request.UserHostAddress
            .Add("@Result", SqlDbType.Char, 1).Direction = ParameterDirection.Output
            .Add("@ReturnId", SqlDbType.BigInt).Direction = ParameterDirection.Output

            If ChkIsReportAble.Checked = False Then
                .Add("@IsReportable", SqlDbType.Bit).Value = False
            Else
                .Add("@IsReportable", SqlDbType.Bit).Value = ChkIsReportAble.Checked
            End If
            If ChkIsReportAble.Checked Then
                .Add("@ReporintPerson", SqlDbType.TinyInt).Value = CInt(ddlReporintUser.SelectedValue)

            Else
                .Add("@ReporintPerson", SqlDbType.TinyInt).Value = DBNull.Value
            End If
        End With

        cnnContact.Open()
        trnContact = cnnContact.BeginTransaction()

        cmdContact.Transaction = trnContact
        cmdContact.ExecuteNonQuery()

        If CChar(cmdContact.Parameters("@Result").Value).Equals("E"c) Then
            '   Msg.Text = "The Record has been Successfully Submitted !"
            DisplayMessage(Me.Master.MessageBox, "A User with same Email already exists.", "Record Exists", MessageBoxTypes.Warning)
            'MessageBoxShow(Page, "This Record Exists Try with some other record!")
            litUserId.Text = String.Empty
            Return
        End If

        trnContact.Commit()
        litUserId.Text = (cmdContact.Parameters("@ReturnId").Value)

        If blnIsUpdate Then

            Dim cmdsDistrict As New SqlCommand("spAdminDeleletUserAssociationNews", cnnContact)
            cmdsDistrict.CommandType = CommandType.StoredProcedure
            Try
                With cmdsDistrict.Parameters
                    .Add("@UserId", SqlDbType.TinyInt).Value = litUserId.Text
                    .Add("@Result", SqlDbType.Char, 1).Direction = ParameterDirection.Output

                End With

                trnContact = cnnContact.BeginTransaction()
                cmdsDistrict.Transaction = trnContact

                cmdsDistrict.ExecuteNonQuery()
                trnContact.Commit()

            Catch ex As Exception

            End Try

        End If

        Dim dt As New DataTable()

        dt.Columns.AddRange(New DataColumn(2) {New DataColumn("DistrictId", GetType(Integer)), New DataColumn("DistrictName", GetType(String)), New DataColumn("UserID", GetType(Integer))})

        Dim i As Integer = 0
        Do While (i < CheckBoxList1.Items.Count)
            If CheckBoxList1.Items(i).Selected Then
                Dim id As Integer = Integer.Parse(CheckBoxList1.Items(i).Value)
                Dim name As String = CheckBoxList1.Items(i).Text
                Dim country As String = litUserId.Text
                dt.Rows.Add(id, name, country)
            End If
            i = (i + 1)
        Loop
        If dt.Rows.Count > 0 Then
            ' cnnContact = New SqlConnection(AppSettings("DbSqlPortal"))
            Using cmd As New SqlCommand("Insert_Customers")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Connection = cnnContact
                cmd.Parameters.AddWithValue("@tblCustomers", dt)

                cmd.ExecuteNonQuery()

            End Using

        End If

        Dim dt2 As New DataTable()
        'Dim cnnCdf As SqlConnection = Nothing
        dt2.Columns.AddRange(New DataColumn(3) {New DataColumn("TehsilId", GetType(Integer)), New DataColumn("TehsilName", GetType(String)), New DataColumn("DistrictId", GetType(Integer)), New DataColumn("UserID", GetType(Integer))})

        Dim i2 As Integer = 0
        Do While (i2 < CheckBoxList2.Items.Count)
            If CheckBoxList2.Items(i2).Selected Then
                Dim id As Integer = Integer.Parse(CheckBoxList2.Items(i2).Value)
                hdnThil = id
                Dim name As String = CheckBoxList2.Items(i2).Text
                Dim country As String = litUserId.Text
                Dim tId As Integer = GetDistrictIDoftehsilIds(CheckBoxList2.Items(i2).Value)
                dt2.Rows.Add(id, name, tId, country)
            End If
            i2 = (i2 + 1)
        Loop

        If dt2.Rows.Count > 0 Then

            Using cmd As New SqlCommand("Insert_Customersfourth")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Connection = cnnContact
                cmd.Parameters.AddWithValue("@tblCustomersfourth", dt2)

                cmd.ExecuteNonQuery()

            End Using

        End If

        Dim dt3 As New DataTable()

        dt3.Columns.AddRange(New DataColumn(3) {New DataColumn("UCID", GetType(Integer)), New DataColumn("UCName", GetType(String)), New DataColumn("TehsilId", GetType(Integer)), New DataColumn("UserID", GetType(Integer))})

        Dim i3 As Integer = 0
        Do While (i3 < CheckBoxList3.Items.Count)
            If CheckBoxList3.Items(i3).Selected Then
                Dim id As Integer = Integer.Parse(CheckBoxList3.Items(i3).Value)
                hdnUC = id
                Dim name As String = CheckBoxList3.Items(i3).Text
                Dim country As String = litUserId.Text
                Dim Ucid As Integer = GetTehsilIDIds(CheckBoxList3.Items(i3).Value)
                dt3.Rows.Add(id, name, Ucid, country)
            End If
            i3 = (i3 + 1)
        Loop

        If dt3.Rows.Count > 0 Then

            Using cmd As New SqlCommand("Insert_CustomersThird")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Connection = cnnContact
                cmd.Parameters.AddWithValue("@tblCustomersThird", dt3)

                cmd.ExecuteNonQuery()

            End Using

        End If

        Dim dt4 As New DataTable()

        dt4.Columns.AddRange(New DataColumn(3) {New DataColumn("VillageId", GetType(Integer)), New DataColumn("VillageName", GetType(String)), New DataColumn("UcID", GetType(Integer)), New DataColumn("UserID", GetType(Integer))})

        Dim i4 As Integer = 0
        Do While (i4 < CheckBoxList4.Items.Count)
            If CheckBoxList4.Items(i4).Selected Then
                Dim id As Integer = Integer.Parse(CheckBoxList4.Items(i4).Value)
                hdnVillage = id
                Dim name As String = CheckBoxList4.Items(i4).Text
                Dim country As String = litUserId.Text
                Dim Ucid As Integer = GetUCIDIds(CheckBoxList4.Items(i4).Value)
                dt4.Rows.Add(id, name, Ucid, country)
            End If
            i4 = (i4 + 1)
        Loop
        If dt4.Rows.Count > 0 Then

            Using cmd As New SqlCommand("Insert_CustomersSecond")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Connection = cnnContact
                cmd.Parameters.AddWithValue("@tblCustomersSecond", dt4)

                cmd.ExecuteNonQuery()

            End Using

        End If

        '    Catch ex As Exception

        'End Try

        cnnContact.Close()
        Dim strMessage As String = "A new User has successfully been created and saved."
        If blnIsUpdate Then strMessage = "The selected User has successfully been updated and saved."
        'lblMesssages.InnerText = "Welcome"
        DisplayMessage(Me.Master.MessageBox, strMessage, "User Saved Successfully", MessageBoxTypes.Success)
        SendMAilMessage()

        '  MVSearch.ActiveViewIndex = 0
        SearchUsers()
        'DisplayInitialPage()
    Catch ex As Exception

        If trnContact IsNot Nothing Then trnContact.Rollback()

        DisplayMessage(Me.Master.MessageBox, "An unexpected error occurred while saving the Record. Please retry.", "Record Not Saved", MessageBoxTypes.Error)

    Finally
        DisposeDataObjects(, , cmdContact, cnnContact)

    End Try

End Sub

GeneralRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx16-Apr-15 10:41
professionaljkirkerx16-Apr-15 10:41 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
Malikdanish16-Apr-15 20:45
professionalMalikdanish16-Apr-15 20:45 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx17-Apr-15 8:02
professionaljkirkerx17-Apr-15 8:02 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
Malikdanish17-Apr-15 18:29
professionalMalikdanish17-Apr-15 18:29 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx19-Apr-15 9:18
professionaljkirkerx19-Apr-15 9:18 
Questionissue wih gridview Pin
Praveen Kandari15-Apr-15 0:20
Praveen Kandari15-Apr-15 0:20 
SuggestionRe: issue wih gridview Pin
ZurdoDev15-Apr-15 3:31
professionalZurdoDev15-Apr-15 3:31 
AnswerRe: issue wih gridview Pin
User 418025410-Jul-15 11:18
User 418025410-Jul-15 11:18 
GeneralRe: issue wih gridview Pin
Praveen Kandari15-Jul-15 19:17
Praveen Kandari15-Jul-15 19:17 
GeneralRe: issue wih gridview Pin
User 418025416-Jul-15 2:21
User 418025416-Jul-15 2:21 
QuestionHow to fix “Googlebot can't access your site” issue? Pin
Tridip Bhattacharjee14-Apr-15 21:16
professionalTridip Bhattacharjee14-Apr-15 21:16 
AnswerRe: How to fix “Googlebot can't access your site” issue? Pin
Richard Deeming15-Apr-15 1:38
mveRichard Deeming15-Apr-15 1:38 
AnswerRe: How to fix “Googlebot can't access your site” issue? Pin
ZurdoDev15-Apr-15 3:32
professionalZurdoDev15-Apr-15 3:32 
QuestionReading Excel File Pin
anokeha_prani14-Apr-15 20:34
anokeha_prani14-Apr-15 20:34 
SuggestionRe: Reading Excel File Pin
Richard MacCutchan14-Apr-15 21:13
mveRichard MacCutchan14-Apr-15 21:13 
GeneralRe: Reading Excel File Pin
anokeha_prani16-Apr-15 0:35
anokeha_prani16-Apr-15 0:35 
GeneralRe: Reading Excel File Pin
Richard MacCutchan16-Apr-15 1:00
mveRichard MacCutchan16-Apr-15 1:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.