%@ CodePage = 1254 LCID = 1055 %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.addHeader "cache-control", "no-cache" Response.addHeader "cache-control", "no-store" Response.CacheControl = "no-cache" %> <% If Not IsLoggedIn Then Response.Redirect "login.asp" %> <% ' Initialize common variables x_id = Null: ox_id = Null: z_id = Null x_ust_yazi = Null: ox_ust_yazi = Null: z_ust_yazi = Null x_resim = Null: ox_resim = Null: z_resim = Null fs_x_resim = 0: fn_x_resim = "": ct_x_resim = "" wd_x_resim = 0: ht_x_resim = 0: a_x_resim = "" x_alt_yazi = Null: ox_alt_yazi = Null: z_alt_yazi = Null x_yan_yazi = Null: ox_yan_yazi = Null: z_yan_yazi = Null x_resimsol = Null: ox_resimsol = Null: z_resimsol = Null x_resim_boy = Null: ox_resim_boy = Null: z_resim_boy = Null x_resim_en = Null: ox_resim_en = Null: z_resim_en = Null %> <% Response.Buffer = True ' Load key from QueryString bCopy = True x_id = Request.QueryString("id") If x_id = "" Or IsNull(x_id) Then bCopy = False End If sAction = "" If Not RequestBlobData() Then If bCopy Then sAction = "C" ' Copy Record Else sAction = "I" ' Display Blank Record End If End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "C": ' Get a record to display If Not LoadData() Then ' Load Record based on key Session(ewSessionMessage) = "Kayıt Bulunmadı" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "iletisimlist.asp" End If Case "A": ' Add If AddData() Then ' Add New Record Session(ewSessionMessage) = "Data Ekleme Başarılı" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "iletisimlist.asp" Else End If End Select %>
Ekle TABLO: iletisim
Listeye Geri Don
<%= Session(ewSessionMessage) %>
<% Session(ewSessionMessage) = "" ' Clear message End If %> <% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function RequestBlobData ' - Handle mult-part data (for file upload) ' - Variables setup: sAction, field variables, EW_Max_File_Size Function RequestBlobData() Dim rawData, separator, lenSeparator, dict Dim currentPos, inStrByte, tempValue, mValue, value Dim intDict, begPos, endPos, nValue Dim nameN, isValid, nameValue, midValue If Request.TotalBytes > 0 Then rawData = Request.BinaryRead(Request.TotalBytes) separator = MidB(rawData, 1, InStrB(1, rawData, ChrB(13)) - 1) lenSeparator = LenB(separator) Set dict = Server.CreateObject("Scripting.Dictionary") currentPos = 1 inStrByte = 1 tempValue = "" While inStrByte > 0 inStrByte = InStrB(currentPos, rawData, separator) mValue = inStrByte - currentPos If mValue > 1 Then value = MidB(rawData, currentPos, mValue) Set intDict = Server.CreateObject("Scripting.Dictionary") begPos = 1 + InStrB(1, value, ChrB(34)) endPos = InStrB(begPos + 1, value, ChrB(34)) nValue = endPos nameN = MidB(value, begPos, endPos - begPos) isValid = True If InStrB(1, value, stringToByte("Content-Type")) > 1 Then begPos = 1 + InStrB(endPos + 1, value, ChrB(34)) endPos = InStrB(begPos + 1, value, ChrB(34)) If endPos = 0 Then endPos = begPos + 1 isValid = False End If midValue = MidB(value, begPos, endPos - begPos) intDict.Add "FileName", Trim(byteToString(midValue)) begPos = 14 + InStrB(endPos + 1, value, stringToByte("Content-Type:")) endPos = InStrB(begPos, value, ChrB(13)) midValue = MidB(value, begPos, endPos - begPos) intDict.Add "ContentType", Trim(byteToString(midValue)) begPos = endPos + 4 endPos = LenB(value) nameValue = MidB(value, begPos, ((endPos - begPos) - 1)) Else nameValue = Trim(byteToString(MidB(value, nValue + 5))) End If If isValid = True Then If dict.Exists(byteToString(nameN)) Then Set intDict = dict.Item(byteToString(nameN)) If Right(intDict.Item("Value"), 2) = vbCrLf Then intDict.Item("Value") = Left(intDict.Item("Value"), Len(intDict.Item("Value"))-2) End If intDict.Item("Value") = intDict.Item("Value") & ", " & nameValue Else intDict.Add "Value", nameValue intDict.Add "Name", nameN dict.Add byteToString(nameN), intDict End If End If End If currentPos = lenSeparator + inStrByte Wend ' Get action sAction = getValue(dict, "a_add") EW_Max_File_Size = getValue(dict, "EW_Max_File_Size") x_id = getValue(dict, "x_id") x_ust_yazi = getValue(dict, "x_ust_yazi") fs_x_resim = getFileSize(dict, "x_resim") ' Check the file size If fs_x_resim > 0 And CLng(EW_Max_File_Size) > 0 Then If fs_x_resim > CLng(EW_Max_File_Size) Then Response.Write Replace("", "%s", EW_Max_File_Size) Response.End End If End If fn_x_resim = getFileName(dict, "x_resim") ' Check the file type If Not ewUploadAllowedFileExt(fn_x_resim) Then Response.Write "" Response.End End If ct_x_resim = getFileContentType(dict, "x_resim") x_resim = getFileData(dict, "x_resim") wd_x_resim = getValue(dict, "wd_x_resim") ht_x_resim = getValue(dict, "ht_x_resim") a_x_resim = getValue(dict, "a_x_resim") x_alt_yazi = getValue(dict, "x_alt_yazi") x_yan_yazi = getValue(dict, "x_yan_yazi") x_resimsol = getValue(dict, "x_resimsol") x_resim_boy = getValue(dict, "x_resim_boy") x_resim_en = getValue(dict, "x_resim_en") If IsObject(intDict) Then intDict.RemoveAll Set intDict = Nothing End If dict.RemoveAll Set dict = Nothing RequestBlobData = True Else RequestBlobData = False End If End Function %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value ' - Variables setup: field variables Function LoadData() Dim rs, sSql, sFilter sFilter = ewSqlKeyWhere sFilter = Replace(sFilter, "@id", AdjustSql(x_id)) ' Replace key value sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadData = False Else LoadData = True rs.MoveFirst ' Get the field contents x_id = rs("id") x_ust_yazi = rs("ust_yazi") x_resim = rs("resim") x_alt_yazi = rs("alt_yazi") x_yan_yazi = rs("yan_yazi") x_resimsol = rs("resimsol") x_resim_boy = rs("resim_boy") x_resim_en = rs("resim_en") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function AddData ' - Add Data ' - Variables used: field variables Function AddData() On Error Resume Next Dim rs, sSql, sFilter Dim bCheckKey, sSqlChk, sWhereChk sFilter = ewSqlKeyWhere ' Check for duplicate key bCheckKey = True If x_id = "" Or IsNull(x_id) Then bCheckKey = False Else sFilter = Replace(sFilter, "@id", AdjustSql(x_id)) ' Replace key value End If If bCheckKey Then sSqlChk = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rsChk = conn.Execute(sSqlChk) If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description rsChk.Close Set rsChk = Nothing AddData = False Exit Function ElseIf Not rsChk.Eof Then Session(ewSessionMessage) = "İkili Miktar Birincil Anahtar İçin" rsChk.Close Set rsChk = Nothing AddData = False Exit Function End If rsChk.Close Set rsChk = Nothing End If ' Add New Record sFilter = "(0 = 1)" sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description rs.Close Set rs = Nothing AddData = False Exit Function End If ' Clone new rs object Dim rsnew Set rsnew = rs.Clone(1) rs.AddNew ' Field ust_yazi sTmp = Trim(x_ust_yazi) If Trim(sTmp) = "" Then sTmp = Null rs("ust_yazi") = sTmp ' Field resim ox_resim = rs("resim") sTmpFolder = ewUploadPathEx(True, EW_UploadDestPath) If ox_resim <> "" Then ewDeleteFile sTmpFolder & ox_resim sTmp = x_resim If Trim(sTmp) = "" Then sTmp = Null If IsNull(sTmp) Then rs("resim") = Null Else rs("resim") = ewUploadFileNameEx(sTmpFolder, fn_x_resim) ewSaveFile sTmpFolder, rs("resim"), sTmp End If ' Field alt_yazi sTmp = Trim(x_alt_yazi) If Trim(sTmp) = "" Then sTmp = Null rs("alt_yazi") = sTmp ' Field yan_yazi sTmp = Trim(x_yan_yazi) If Trim(sTmp) = "" Then sTmp = Null rs("yan_yazi") = sTmp ' Field resimsol sTmp = x_resimsol If sTmp = "Sol" Then rs("resimsol") = True Else rs("resimsol") = False End If ' Field resim_boy sTmp = x_resim_boy If Not IsNumeric(sTmp) Then sTmp = Null Else sTmp = CLng(sTmp) End If rs("resim_boy") = sTmp ' Field resim_en sTmp = x_resim_en If Not IsNumeric(sTmp) Then sTmp = Null Else sTmp = CLng(sTmp) End If rs("resim_en") = sTmp ' Call recordset inserting event If Recordset_Inserting(rs) Then rs.Update If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description AddData = False Else AddData = True End If Else rs.CancelUpdate AddData = False End If rs.Close Set rs = Nothing ' Call recordset inserted event If AddData Then Call Recordset_Inserted(rsnew) End If rsnew.Close Set rsnew = Nothing End Function '------------------------------------------------------------------------------- ' Recordset inserting event Function Recordset_Inserting(rsnew) On Error Resume Next ' Please enter your customized codes here Recordset_Inserting = True End Function '------------------------------------------------------------------------------- ' Recordset inserted event Sub Recordset_Inserted(rsnew) On Error Resume Next ' Get key value Dim sKey sKey = "" If sKey <> "" Then sKey = sKey & "," sKey = sKey & rsnew.Fields("id") x_id = rsnew.Fields("id") End Sub %>