Member 12558408 Ответов: 1

Как мне изменить этот VB6 на C#


Private Sub cmdOk_Click()
Dim rs  As New ADODB.Recordset
Set rs = Nothing
Set fs = CreateObject("Scripting.FileSystemObject")

'If txtHRP.Text = "" Then
'    MsgBox "Please Select Hotel Reservaion Policy", vbInformation
'    txtHRP.SetFocus
'    Exit Sub
'ElseIf txtHCP.Text = "" Then
'    MsgBox "Please Select Hotel Cancellation Policy", vbInformation
'    txtHCP.SetFocus
'    Exit Sub
If TxtServerName.Text = "" Then
    MsgBox "Please Select Server Name", vbInformation
    TxtServerName.SetFocus
    Exit Sub
ElseIf TxtDBName.Text = "" Then
    MsgBox "Please Select DataBase Name", vbInformation
    TxtDBName.SetFocus
    Exit Sub
ElseIf TxtUserId.Text = "" Then
    MsgBox "Please Select User Id", vbInformation
    TxtUserId.SetFocus
    Exit Sub
ElseIf TxtPassword.Text = "" Then
    MsgBox "Please Select Password", vbInformation
    TxtPassword.SetFocus
    Exit Sub
    
ElseIf txtCompId.Text = "" Then
    MsgBox "Please Select Company ID", vbInformation
    txtCompId.SetFocus
    Exit Sub
ElseIf txtoutletId.Text = "" Then
    MsgBox "Please Select Outlet ID", vbInformation
    txtoutletId.SetFocus
    Exit Sub
ElseIf txtServicePath.Text = "" Then
    MsgBox "Please Select Service Path", vbInformation
    txtServicePath.SetFocus
    Exit Sub
End If


    Dim fso 'As Scripting.FileSystemObject
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(App.path & "\Cabs_WebApp.ini") Then
        fso.DeleteFile (App.path & "\Cabs_WebApp.ini")
    End If
    
    Open App.path & "\Cabs_WebApp.ini" For Output As #1
        Write #1, txtServicePath.Text
        Write #1, txtoutletId.Text
        Write #1, txtCompId.Text
    Close #1
    
My_Connection.Execute "Delete from HMS_Booking_eng_Confi"
'rs.Open "Select * from HMS_Booking_eng_Confi where Cacel_Police='" & Trim(txtHCP.Text) & "' ", My_Connection, adOpenKeyset, adLockOptimistic
rs.Open "Select * from HMS_Booking_eng_Confi ", My_Connection, adOpenKeyset, adLockOptimistic
'If rs.EOF Then
    rs.AddNew
    rs!Cacel_Police = txtHCP.Text
'End If
    rs!Reserv_Police = txtHRP.Text
    rs!Deposit_Police = txtHDP.Text
    rs!Hotel_No = txtHNSP.Text
    rs!Cutof_Hour = txtHour.Text
    rs!Stay_Period = txtPeriod.Text
    rs!Stay_Period_max = Text1.Text
    If (Trim(cboRemark.Text)) = "Yes" Then
        rs!Remark = "Y"
    Else
        rs!Remark = "N"
    End If
    If (Trim(cboService.Text)) = "Yes" Then
        rs!Add_On_Service = "Y"
    Else
        rs!Add_On_Service = "N"
    End If
    rs!Server_Name = Trim(TxtServerName.Text)
    rs!User_Name = Trim(TxtUserId.Text)
    rs!Password1 = Trim(TxtPassword.Text)
    rs!DB_Name = Trim(TxtDBName.Text)
    rs!Comp_Id = Trim(txtCompId.Text)
    rs!Outlet_Id = Trim(txtoutletId.Text)
    rs!service_path = Trim(txtServicePath.Text)
    'rs!Max_Resv_Date = Format(mskArrDate.Text, "yyyy/mm/dd")
    rs!Min_Resv_Date = Format(mskminDate.Text, "yyyy/mm/dd")
    rs!Max_Resv_Days = Trim(Text2.Text)
    rs!UnitCode = Trim(txtUnitCode.Text)
    
    rs.update
    MsgBox "Data Save Successfully", vbInformation
    Unload Me
    'Clear
End Sub

Private Sub CmdPrint_Click()
    CrystalReport1.Connect = RepConn
    Call Cabs_Print_DTP(CrystalReport1)
    CrystalReport1.ReportFileName = App.path & "\Report\Hms_Booking_Engine_Report.rpt"
    CrystalReport1.Formulas(35) = "Title='Booking Engine Configurator'"
    
    Dim rsPrint As New ADODB.Recordset
    rsPrint.Open "select * from Cabs_Print_Setup where comp_code='" & GetObj.GetCompany_Code & "'", My_Connection, adOpenForwardOnly, adLockReadOnly
    If Not rsPrint.EOF Then
        CrystalReport1.Formulas(30) = "a1='" & rsPrint!comp_name & "'"
        CrystalReport1.Formulas(31) = "a2='" & rsPrint!C_ADD & "'"
        CrystalReport1.Formulas(32) = "a3='" & rsPrint!C_Add1 & "'"
        CrystalReport1.Formulas(33) = "a4='" & rsPrint!C_Add2 & "'"
        CrystalReport1.Formulas(34) = "a5='" & rsPrint!C_City & "'"
    End If
    rsPrint.Close
    Set rsPrint = Nothing
    CrystalReport1.WindowState = crptMaximized
    CrystalReport1.WindowShowPrintBtn = True
    CrystalReport1.WindowShowPrintSetupBtn = True
    CrystalReport1.WindowShowRefreshBtn = True
    CrystalReport1.Action = 1
    CrystalReport1.Reset
    Screen.MousePointer = vbNormal
End Sub

Private Sub Command1_Click()
If Trim(TxtServerName.Text) = "" Or Trim(TxtDBName.Text) = "" Or Trim(TxtUserId.Text) = "" Or Trim(TxtPassword.Text) = "" Then
    MsgBox "Cloud Server Detail Can Not Be Left Blank", vbExclamation, "Error"
    Exit Sub
End If
'On Error GoTo err1
Screen.MousePointer = vbHourglass
    Dim rscloud As New ADODB.Recordset
    Dim rslocal As New ADODB.Recordset
    Dim Cloud_Conn As New ADODB.Connection
    Dim Prov As String
    Prov = "SQLOLEDB.1;Persist Security Info=False;User ID=" & TxtUserId.Text & ";Password=" & TxtPassword.Text & ";Initial Catalog=" & Trim(TxtDBName) & ";data source=" & Trim(TxtServerName)
    Cloud_Conn.Provider = Prov
    Cloud_Conn.Open
    Cloud_Conn.Execute "delete from CORHFO_RateCard_Trn"
    Cloud_Conn.Execute "delete from CORHFO_RateCard_Mst"
    
    Cloud_Conn.Execute "delete from CORHFO_ROOM_MST"
    Cloud_Conn.Execute "delete from CORHFO_ROOMTYPE_MST"
    
    Cloud_Conn.Execute "delete from CORHFO_Booking_eng_mst"
    Cloud_Conn.Execute "delete from CORHFO_Booking_eng_Confi"
    
    Cloud_Conn.Execute "delete from eCabsg_MessengerLoyality"
    Cloud_Conn.Execute "delete from eCabsg_MessengerOthers"
    Cloud_Conn.Execute "delete from eCabsg_MessengerQue"
    Cloud_Conn.Execute "delete from eCabsg_MessengerSetup"
    Cloud_Conn.Execute "delete from eCabsg_MessengerTemplate"
    Cloud_Conn.Execute "delete from eCabsg_MessengerTransaction"
    Cloud_Conn.Execute "delete from eCabsg_MessengerTransfer"
    Cloud_Conn.Execute "delete from eCabsg_Messenger_SMSSetting"
    
    
    rscloud.Open "select * from CORHFO_RateCard_Trn", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from HMS_RateCard_Trn", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!RateCardCode = rslocal.Fields("RateCardCode").Value
        rscloud!RMType = rslocal.Fields("RMType").Value
        rscloud!flag = rslocal.Fields("flag").Value
        rscloud!Discount = rslocal.Fields("Discount").Value
        rscloud!DbRent = rslocal.Fields("DbRent").Value
        rscloud!SGRent = rslocal.Fields("SGRent").Value
        rscloud!ExRent = rslocal.Fields("ExRent").Value
        rscloud!mNRENT = rslocal.Fields("MNRent").Value
        rscloud!ifrent = rslocal.Fields("IFRent").Value
        rscloud!ChargeType = rslocal.Fields("ChargeType").Value
        rscloud!ChargeTypeMeal = rslocal.Fields("ChargeTypeMeal").Value
        rscloud!APFIT = rslocal.Fields("APFIT").Value
        rscloud!APGIT = rslocal.Fields("APGIT").Value
        rscloud!MAPFIT = rslocal.Fields("MAPFIT").Value
        rscloud!MAPGIT = rslocal.Fields("MAPGIT").Value
        rscloud!CPFIT = rslocal.Fields("CPFIT").Value
        rscloud!CPGIT = rslocal.Fields("CPGIT").Value
        rscloud!EPFIT = rslocal.Fields("EPFIT").Value
        rscloud!EPGIT = rslocal.Fields("EPGIT").Value
        rscloud!Disc_Mon = rslocal.Fields("Disc_Mon").Value
        rscloud!Disc_Tue = rslocal.Fields("Disc_Tue").Value
        rscloud!Disc_Wed = rslocal.Fields("Disc_Wed").Value
        rscloud!Disc_Thu = rslocal.Fields("Disc_Thu").Value
        rscloud!Disc_Fri = rslocal.Fields("Disc_Fri").Value
        rscloud!Disc_Sat = rslocal.Fields("Disc_Sat").Value
        rscloud!Disc_Sun = rslocal.Fields("Disc_Sun").Value
        rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    '''''
    rscloud.Open "select * from CORHFO_RateCard_Mst ", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Hms_RateCard_Mst ", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!RateCardCode = rslocal.Fields("RateCardCode").Value
        rscloud!RateCardDesc = rslocal.Fields("RateCardDesc").Value
        rscloud!fromdate = rslocal.Fields("fromdate").Value
        rscloud!ToDate = rslocal.Fields("ToDate").Value
        rscloud!Remark = rslocal.Fields("Remark").Value
        rscloud!RATECARDSts = rslocal.Fields("RateCardSts").Value
        rscloud!Booking_Eng = rslocal.Fields("Booking_Eng").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    '''''''''''''''
    rscloud.Open "select * from CORHFO_ROOM_MST", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from HMS_ROOM_MST", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        
        rscloud!Room_Numb = rslocal.Fields("ROOM_NUMB").Value
        rscloud!Rm_Floor = rslocal.Fields("RM_FLOOR").Value
        rscloud!RM_TYPE = rslocal.Fields("RM_TYPE").Value
        rscloud!Rm_Desc = rslocal.Fields("RM_DESC").Value
        rscloud!RM_SINGLE = rslocal.Fields("RM_SINGLE").Value
        rscloud!RM_SG_RENT = rslocal.Fields("RM_SG_RENT").Value
        rscloud!RM_DB_RENT = rslocal.Fields("RM_DB_RENT").Value
        rscloud!RM_EX_RENT = rslocal.Fields("RM_EX_RENT").Value
        rscloud!RM_MN_RENT = rslocal.Fields("RM_MN_RENT").Value
        rscloud!Rm_Min_Per = rslocal.Fields("RM_MIN_PER").Value
        rscloud!Rm_Ebx_Ext = rslocal.Fields("RM_EBX_EXT").Value
        rscloud!RM_LTAXYN = rslocal.Fields("RM_LTAXYN").Value
        rscloud!Rm_Remark = rslocal.Fields("RM_REMARK").Value
        rscloud!Rm_Bd_Type = rslocal.Fields("RM_BD_TYPE").Value
        rscloud!Wef_Date = rslocal.Fields("Wef_Date").Value
        rscloud!Rm_Feature = rslocal.Fields("RM_FEATURE").Value
        rscloud!NoofGuest = rslocal.Fields("NoofGuest").Value
        rscloud!RM_STATUS = rslocal.Fields("RM_STATUS").Value
        rscloud!RM_IF_RENT = rslocal.Fields("RM_IF_RENT").Value
        rscloud!ROOM_NOTES = rslocal.Fields("ROOM_NOTES").Value
        rscloud!ROOM_PICTURE = rslocal.Fields("ROOM_PICTURE").Value
        rscloud!Status = rslocal.Fields("Status").Value
        rscloud!DoorLock = rslocal.Fields("DoorLock").Value
        rscloud!roomMSG = rslocal.Fields("RoomMSG").Value
    
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    '''''''''''
    rscloud.Open "select * from CORHFO_ROOMTYPE_MST", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from HMS_ROOMTYPE_MST", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
    
        rscloud!RmTypeCode = rslocal.Fields("RmTypeCode").Value
        rscloud!RMType = rslocal.Fields("RMType").Value
        rscloud!SingleDouble = rslocal.Fields("SingleDouble").Value
        rscloud!Maxpax = rslocal.Fields("Maxpax").Value
        rscloud!Tariff = rslocal.Fields("Tariff").Value
        rscloud!totnor = rslocal.Fields("ToTNOR").Value
        rscloud!oblimit = rslocal.Fields("OBLimit").Value
        rscloud!ShortName = rslocal.Fields("ShortName").Value
        rscloud!ExtraBedRent = rslocal.Fields("ExtraBedRent").Value
        rscloud!MinorBedRent = rslocal.Fields("MinorBedRent").Value
        rscloud!InfantBedRent = rslocal.Fields("InfantBedRent").Value
        rscloud!SingleTariff = rslocal.Fields("SingleTariff").Value
        rscloud!ROOM_PICTURE = rslocal.Fields("ROOM_PICTURE").Value
        rscloud!LanguageInput = rslocal.Fields("LanguageInput").Value
        rscloud!ROOM_NOTES = rslocal.Fields("ROOM_NOTES").Value
    
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    '''''''''''
    rscloud.Open "select * from CORHFO_Booking_eng_mst", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from HMS_Booking_eng_mst", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!Bking_ID = rslocal.Fields("Bking_ID").Value
        rscloud!Bking_Desc = rslocal.Fields("Bking_Desc").Value
        rscloud!Bking_PICTURE = rslocal.Fields("Bking_PICTURE").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    '''''''''''
    rscloud.Open "select * from CORHFO_Booking_eng_Confi", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from HMS_Booking_eng_Confi", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!Cacel_Police = rslocal.Fields("Cacel_Police").Value
        rscloud!Deposit_Police = rslocal.Fields("Deposit_Police").Value
        rscloud!Hotel_No = rslocal.Fields("Hotel_No").Value
        rscloud!Cutof_Hour = rslocal.Fields("Cutof_Hour").Value
        rscloud!Stay_Period = rslocal.Fields("Stay_Period").Value
        rscloud!Remark = rslocal.Fields("Remark").Value
        rscloud!Add_On_Service = rslocal.Fields("Add_On_Service").Value
        rscloud!Reserv_Police = rslocal.Fields("Reserv_Police").Value
        rscloud!Stay_Period_max = rslocal.Fields("Stay_Period_max").Value
        rscloud!Server_Name = rslocal.Fields("Server_Name").Value
        rscloud!User_Name = rslocal.Fields("User_Name").Value
        rscloud!Password1 = rslocal.Fields("Password1").Value
        rscloud!DB_Name = rslocal.Fields("DB_Name").Value
        'rscloud!Max_Resv_Date = rslocal.Fields("Max_Resv_Date").Value
        rscloud!Min_Resv_Date = rslocal.Fields("Min_Resv_Date").Value
        rscloud!UnitCode = rslocal.Fields("UnitCode").Value
        rscloud!Max_Resv_Days = rslocal.Fields("Max_Resv_Days").Value
        
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
'    rsCloud.Open "select * from CORHFO_Booking_eng_Total_Room", Cloud_Conn, adOpenKeyset, adLockOptimistic
'    rsCloud.AddNew
'        rsCloud!unit = Trim(txtCompId.Text)
'        rsCloud!Date = Format(Run_Date, "yyyy/mm/dd")
'        rsCloud!RoomType = ""
'        rsCloud!totalRoom_HMS = ""
'        rsCloud!arribal_hms = ""
'        rsCloud!departures_hms = ""
'        rsCloud!occupied_hms = ""
'        rsCloud!vacant_hms = ""
'        rsCloud!reserv_booking_eng = ""
'        rsCloud!Mod_Code = ""
'        rsCloud!HotelCode = ""
'        rsCloud!Account_ID = ""
'    rsCloud.update
'    rsCloud.Close
    ''''''''''''''
    
'''     Dim rstot As New ADODB.Recordset
'''    rstot.Open "select * from HMS_ROOMTYPE_MST", My_Connection, adOpenKeyset, adLockOptimistic
'''    Do While Not rstot.EOF
'''        Dim rs As New ADODB.Recordset
'''        LblTotRm = "": LbltotOcc = "": LblTotVac = "": LblTotBlk = "": LblExpArr = "": LblExpDep = ""
'''        LblTotRm = Val(FunRetAnyFldVal("Select count(*) from Hms_Room_Mst where rm_type='" & rstot.Fields("RmTypeCode") & "'"))
'''        LbltotOcc = Val(FunRetAnyFldVal("Select count(*) from Hms_Room_Mst Where NoOFGuest>0 and rm_type='" & rstot.Fields("RmTypeCode") & "'"))
'''        LblTotBlk = Val(FunRetAnyFldVal(Change_Query("Select count(*) from Hms_Room_block Where FromDate<=#" & Format(Run_Date, "yyyy/mm/dd") & "# And ToDate>=#" & Format(Run_Date, "yyyy/mm/dd") & "# ")))
'''        LblTotVac = Val(LblTotRm) - Val(LbltotOcc) - Val(LblTotBlk)
'''        LblExpArr = Val(FunRetAnyFldVal(Change_Query("Select sum(HRH.nor) from hms_Res_Hotel HRH,Hms_Res_Mst HRM where HRH.ResNO=HRM.ResNO and  HRH.fromdate =#" & Format(Run_Date, "yyyy/mm/dd") & "#  And HRH.StsFlag<>'I' And HRM.ResStatus<>'C' and HRM.ResStatus<>'D' and HRH.RoomType='" & rstot.Fields("RmTypeCode") & "'")))
'''        If rs.State = 1 Then rs.Close: Set rs = Nothing
'''        rs.Open Change_Query("Select GuestId,VisitNo from Hms_Inguest_Mst Where ExpDate=#" & Format(Run_Date, "yyyy/mm/dd") & "# and Status ='I'"), My_Connection, adOpenKeyset, adLockOptimistic
'''        If Not rs.EOF Then
'''            Do While Not rs.EOF
'''                If Trim(FunRetAnyFldVal("Select depdate from Hms_Inguest_Room Where GuestId='" & rs.Fields(0) & "' and VisitNo=" & rs.Fields(1))) = 0 Then
'''                    LblExpDep = Val(LblExpDep) + Val(FunRetAnyFldVal("Select Count(*) from Hms_Inguest_Room Where DepDate Is Null and GuestId='" & rs.Fields(0) & "' and VisitNo=" & rs.Fields(1)))
'''                End If
'''                rs.MoveNext
'''            Loop
'''            LblExpDep = Val(LblExpDep.Caption)
'''        End If
'''        Cloud_Conn.Execute "insert into CORHFO_Booking_eng_Total_Room (unit,Date,RoomType,totalRoom_HMS,arribal_hms,departures_hms,occupied_hms,vacant_hms) values('BVM','" & Format(Run_Date, "yyyy/mm/dd") & "','" & rstot.Fields("RmTypeCode") & "','" & LblTotRm & "', '" & LblExpArr & "','" & LblExpDep & "','" & LbltotOcc & "' ,'" & LblTotVac & "'  )  "
'''
'''    rstot.MoveNext
'''    Loop
    
    
    rscloud.Open "select * from eCabsg_MessengerLoyality", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerLoyality", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!Venderid = rslocal.Fields("VenderId").Value
        rscloud!USERID = rslocal.Fields("userId").Value
        rscloud!Passwords = rslocal.Fields("Passwords").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
    rscloud.Open "select * from eCabsg_MessengerOthers", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerOthers", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!ModuleReportId = rslocal.Fields("ModuleReportId").Value
        rscloud!EmailEmpId = rslocal.Fields("EmailEmpId").Value
        rscloud!SMSEmpId = rslocal.Fields("SMSEmpId").Value
        rscloud!BCCID = rslocal.Fields("BCCID").Value
        rscloud!ModuleId = rslocal.Fields("ModuleId").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
    rscloud.Open "select * from eCabsg_MessengerQue", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerQue", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!MTRN_id = rslocal.Fields("MTRN_id").Value
        rscloud!frm_emailsms = rslocal.Fields("frm_emailsms").Value
        rscloud!to_emailsms = rslocal.Fields("to_emailsms").Value
        rscloud!MTRN_subject = rslocal.Fields("MTRN_subject").Value
        rscloud!MTRN_message = rslocal.Fields("MTRN_message").Value
        rscloud!Ip_add = rslocal.Fields("Ip_add").Value
        rscloud!MTRN_Date = rslocal.Fields("MTRN_Date").Value
        rscloud!MTRN_Time = rslocal.Fields("MTRN_Time").Value
        rscloud!smsemailtype = rslocal.Fields("smsemailtype").Value
        rscloud!MTRN_Type = rslocal.Fields("MTRN_Type").Value
        rscloud!Attachment = rslocal.Fields("Attachment").Value
        rscloud!On_Offline = rslocal.Fields("On_Offline").Value
        rscloud!USERID = rslocal.Fields("UserId").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
    
    rscloud.Open "select * from eCabsg_MessengerSetup", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerSetup", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!SenderID = rslocal.Fields("SenderID").Value
        rscloud!SMTP = rslocal.Fields("SMTP").Value
        rscloud!Port = rslocal.Fields("PORT").Value
        rscloud!SenderPass = rslocal.Fields("SenderPass").Value
        rscloud!Status = rslocal.Fields("Status").Value
        rscloud!smsemailtype = rslocal.Fields("SMSemailtype").Value
        rscloud!Venderid = rslocal.Fields("Venderid").Value
        rscloud!USERID = rslocal.Fields("userid").Value
        rscloud!Flash = rslocal.Fields("Flash").Value
        rscloud!IsDefault = rslocal.Fields("IsDefault").Value
        rscloud!GatewayID = rslocal.Fields("GatewayID").Value
        rscloud!Modulename = rslocal.Fields("Modulename").Value 'IIf(IsNull(rsLocal.Fields("Modulename").Value), "", rsLocal.Fields("Module").Value)
        rscloud!Secure = rslocal.Fields("Secure").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
    rscloud.Open "select * from eCabsg_MessengerTemplate", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerTemplate", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!MT_ID = rslocal.Fields("MT_ID").Value
        rscloud!MT_Type = rslocal.Fields("MT_Type").Value
        rscloud!MT_subject = rslocal.Fields("MT_subject").Value
        rscloud!MT_Message = rslocal.Fields("MT_Message").Value
        rscloud!smsemailtype = rslocal.Fields("smsemailtype").Value
        rscloud!Status = rslocal.Fields("Status").Value
        rscloud!Header = rslocal.Fields("Header").Value
        rscloud!Footer = rslocal.Fields("Footer").Value
        rscloud!Document = rslocal.Fields("Document").Value
        rscloud!FontType = rslocal.Fields("FontType").Value
        rscloud!Fontcolor = rslocal.Fields("Fontcolor").Value
        rscloud!FontSize = rslocal.Fields("FontSize").Value
        rscloud!Editable = rslocal.Fields("Editable").Value
        rscloud!Modulename = rslocal.Fields("Modulename").Value
        rscloud!inline = rslocal.Fields("inline").Value
        
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
    rscloud.Open "select * from eCabsg_MessengerTransaction", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerTransaction", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!MTRN_id = rslocal.Fields("MTRN_id").Value
        rscloud!frm_emailsms = rslocal.Fields("frm_emailsms").Value
        rscloud!to_emailsms = rslocal.Fields("to_emailsms").Value
        rscloud!MTRN_subject = rslocal.Fields("MTRN_subject").Value
        rscloud!MTRN_message = rslocal.Fields("MTRN_message").Value
        rscloud!Ip_add = rslocal.Fields("Ip_add").Value
        rscloud!MTRN_Date = rslocal.Fields("MTRN_Date").Value
        rscloud!MTRN_Time = rslocal.Fields("MTRN_Time").Value
        rscloud!smsemailtype = rslocal.Fields("smsemailtype").Value
        rscloud!MTRN_Type = rslocal.Fields("MTRN_Type").Value
        rscloud!Attachment = rslocal.Fields("Attachment").Value
        rscloud!On_Offline = rslocal.Fields("On_Offline").Value
        rscloud!USERID = rslocal.Fields("UserId").Value
        rscloud!Temp_Id = rslocal.Fields("Temp_Id").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close
    
    
    
    rscloud.Open "select * from eCabsg_Messenger_Config", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_Messenger_Config", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!Modulename = rslocal.Fields("ModuleName").Value
        rscloud!Msg_type = rslocal.Fields("Msg_type").Value
        rscloud!email = rslocal.Fields("Email").Value
        rscloud!SMS = rslocal.Fields("SMS").Value
        rscloud!EmailTemp = rslocal.Fields("EmailTemp").Value
        rscloud!SMSTemp = rslocal.Fields("SMSTemp").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close


    rscloud.Open "select * from eCabsg_MessengerTransfer", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_MessengerTransfer", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!SMSEMAIL = rslocal.Fields("SMSEmail").Value
        rscloud!Mode = rslocal.Fields("Mode").Value
        rscloud!Module = rslocal.Fields("Module").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close


    rscloud.Open "select * from eCabsg_Messenger_SMSSetting", Cloud_Conn, adOpenKeyset, adLockOptimistic
    rslocal.Open "select * from Cabs_Messenger_SMSSetting", My_Connection, adOpenKeyset, adLockOptimistic
    While Not rslocal.EOF
    rscloud.AddNew
        rscloud!ModuleCode = rslocal.Fields("ModuleCode").Value
        rscloud!B_Guest = rslocal.Fields("B_Guest").Value
        rscloud!B_Mgm = rslocal.Fields("B_Mgm").Value
        rscloud!D_Guest = rslocal.Fields("D_Guest").Value
        rscloud!D_Mgm = rslocal.Fields("D_Mgm").Value
        rscloud!POSID = rslocal.Fields("POSID").Value
        rscloud!EmpId = rslocal.Fields("EmpId").Value
    rscloud.update
    rslocal.MoveNext
    Wend
    rscloud.Close
    rslocal.Close


Screen.MousePointer = vbNormal
    MsgBox "Data Shrink Successfully", vbInformation
    Unload Me
    Exit Sub

'err1:
'    MsgBox "Plese Check Your Cloud Server Setting / Network Connection", 0 + 64, "CLOUD SETUP!"
'    Screen.MousePointer = vbNormal
End Sub


Что я уже пробовал:

 protected void btnOk_Click(object sender, EventArgs e)
    {
        if (txtHRP.Text == "")
        {
            lblmsg.Text = "Please Select Hotel Reservaion Policy";
            txtHRP.Focus();
         }
       else if( txtHCP.Text == "" )
        {
            lblmsg.Text = "Please Select Hotel Cancellation Policy";
            txtHCP.Focus();
       }
        if (txtServerN.Text == "")
        {
            lblmsg.Text = "Please Select Server Name";
            txtServerN.Focus();
        }
        else if (txtDBName.Text == "")
        {
            lblmsg.Text = "Please Select DataBase Name";
            txtDBName.Focus();
        }
        else if (txtUserID.Text == "")
        {
            lblmsg.Text = "Please Select User Id";
            txtUserID.Focus();
        }
        else if (txtPassword.Text == "")
        {
            lblmsg.Text = "Please Select Password";
            txtPassword.Focus();
        }

        else if (txtCompID.Text == "")
        {
            lblmsg.Text = "Please Select Company ID";
            txtCompID.Focus();
        }
        else if (txtOutletID.Text == "")
        {
            lblmsg.Text = "Please Select Outlet ID";
            txtOutletID.Focus();
        }
        else if (txtServiceP.Text == "")
        {
            lblmsg.Text = "Please Select Service Path";
            txtServiceP.Focus();
        }
       
            //End If
            //    Dim fso 'As Scripting.FileSystemObject
            //    Set fso = CreateObject("Scripting.FileSystemObject")
            //    If fso.FileExists(App.path & "\Cabs_WebApp.ini") Then
            //        fso.DeleteFile(App.path & "\Cabs_WebApp.ini")
            //    End If
            //    Open App.path & "\Cabs_WebApp.ini" For Output As #1
            //        Write #1, txtServicePath.Text
            //        Write #1, txtoutletId.Text
            //        Write #1, txtCompId.Text
            //    Close #1
        //strsql = "Delete from HMS_Booking_eng_Confi";
        //statictaxcalculation_trn.submit(strsql);
        ////strsql = "select  count(*) from HMS_Booking_eng_Confi where Cacel_Police='" + txtHCP.Text.ToString() + "'";
        //if (statictaxcalculation_trn.procRecordExists(strsql) == false)
        //{
            strsql = "insert into HMS_Booking_eng_Confi (Cacel_Police,Reserv_Police,Deposit_Police,Hotel_No,Cutof_Hour,Stay_Period,Stay_Period_max,Remark,Add_On_Service,Server_Name,User_Name,Password1,DB_Name,Comp_Id,Outlet_Id,service_path)values('" + txtHCP.Text + "','"+ txtHRP.Text + "','" + txtHDP.Text + "','" + txtHNSP.Text + "','"+ txtHOUR.Text + "','"+ txtPeriod.Text + "','"+ Text1.Text + "','"+ddlRemark.SelectedValue.ToString()+"','"+ddlService.SelectedValue.ToString()+"','"+ txtServerN.Text + "','"+ txtUserID.Text + "','"+ txtPassword.Text + "','"+ txtDBName.Text + "','"+ txtCompID.Text + "','"+ txtOutletID.Text + "','"+ txtServiceP.Text + "')";
            statictaxcalculation_trn.submit(strsql);
        //}
        lblmsg.Text = "Data Save Successfully";
    }
}

1 Ответов

Рейтинг:
6

OriginalGriff

Во-первых, вам нужно использовать return выход из метода при сбое проверки:

if (txtHRP.Text == "")
    {
    lblmsg.Text = "Please Select Hotel Reservaion Policy";
    txtHRP.Focus();
    return;
    }
Но лучший тест-это:
if (string.IsNullOrWhitespace(txtHRP.Text))
    {
    lblmsg.Text = "Please Select Hotel Reservation Policy";
    txtHRP.Focus();
    return;
    }
Поскольку он также отвергает только пробелы (свойство Text текстового поля никогда не является null)
Но главная проблема заключается в том, что вы никогда не должны объединять строки для построения SQL-команды. Это оставляет вас широко открытыми для случайной или преднамеренной атаки SQL-инъекции, которая может уничтожить всю вашу базу данных. Вместо этого используйте параметризованные запросы:
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
        {
        cmd.Parameters.AddWithValue("@C1", myValueForColumn1);
        cmd.Parameters.AddWithValue("@C2", myValueForColumn2);
        cmd.ExecuteNonQuery();
        }
    }