Blog Of Sem: 2017

Devexpress gridview export customised header

using DevExpress.XtraPrinting;
using DevExpress.Printing.ExportHelpers;
using DevExpress.Export;

private void simpleButton1_Click(object sender, EventArgs e) {
    // Ensure that the data-aware export mode is enabled.
    DevExpress.Export.ExportSettings.DefaultExportType = ExportType.DataAware;           
    // Create a new object defining how a document is exported to the XLSX format.
    XlsxExportOptionsEx options = new XlsxExportOptionsEx();
    // Subscribe to the CustomizeSheetHeader event. 
    options.CustomizeSheetHeader += options_CustomizeSheetHeader;
    // Export the grid data to the XLSX format.
    string file = "grid-export.xlsx";
    gridControl.ExportToXlsx(file, options);
    // Open the created document.
    System.Diagnostics.Process.Start(file);           
}

void options_CustomizeSheetHeader(DevExpress.Export.ContextEventArgs e) {
    // Create a new row.
    CellObject row = new CellObject();
    // Specify row values.
    row.Value = "The document is exported from the IssueList database.";
    // Specify row formatting.
    XlFormattingObject rowFormatting = new XlFormattingObject();
    rowFormatting.Font = new XlCellFont { Bold = true, Size = 14 };
    rowFormatting.Alignment = new DevExpress.Export.Xl.XlCellAlignment { HorizontalAlignment = DevExpress.Export.Xl.XlHorizontalAlignment.Center, VerticalAlignment = DevExpress.Export.Xl.XlVerticalAlignment.Top };
    row.Formatting = rowFormatting;
    // Add the created row to the output document.
    e.ExportContext.AddRow(new [] {row});
    // Add an empty row to the output document.
    e.ExportContext.AddRow();
    // Merge cells of two new rows. 
    e.ExportContext.MergeCells(new DevExpress.Export.Xl.XlCellRange(new DevExpress.Export.Xl.XlCellPosition(0, 0), new DevExpress.Export.Xl.XlCellPosition(5, 1)));
}

Visual c# ms sql database çifte kontrol

           SqlConnection connectionString = new SqlConnection("Server = " + ondegerler.SQLBAGLANTISI_KAYNAK + "; Database = " + ondegerler.SQLBAGLANTISI_VERITABANI + "; User Id = " + ondegerler.SQLBAGLANTISI_KULLANICI + "; Password = " + ondegerler.SQLBAGLANTISI_PAROLA);
            connectionString.Open();
            {
             
                SqlCommand sqlcom2 = new SqlCommand("select count(malzeme_kodu) from tbl_malzeme  where tbl_malzeme.malzeme_kodu = '" + Text_malzeme_kodu.Text + "'", connectionString);

                if (sqlcom2.ExecuteScalar() != null)
                {
                    int UserExist = (int)sqlcom2.ExecuteScalar();
                    if (UserExist > 0)
                    {
                        MessageBox.Show("Bu İsimde Malzeme Kodu Daha Önceden Yaratılmıştır!");
                    }
                }

visual c# update ms sql table from query inside txt file

 // MessageBox.Show(Text_malzeme_grubu.EditValue.ToString());
            //  string connectionString = null;
            SqlConnection connectionString = new SqlConnection("Server = " + ondegerler.SQLBAGLANTISI_KAYNAK + "; Database = " + ondegerler.SQLBAGLANTISI_VERITABANI + "; User Id = " + ondegerler.SQLBAGLANTISI_KULLANICI + "; Password = " + ondegerler.SQLBAGLANTISI_PAROLA);
            connectionString.Open();
            FileInfo file = new FileInfo(Application.StartupPath + "\\tbl_cari_kartlari_duzenle_kaydet.txt");
            string duzenle = file.OpenText().ReadToEnd();
            //MessageBox.Show(silinecekkod.ToString());
            SqlCommand sqlcom = new SqlCommand(duzenle, connectionString);
            sqlcom.Parameters.AddWithValue("@cari_turu", Text_cari_turu.Text.Trim());
            sqlcom.Parameters.AddWithValue("@cari_adi", Text_cari_adi.Text.Trim());
            sqlcom.Parameters.AddWithValue("@irtibat", Text_irtibat.Text.Trim());
            sqlcom.Parameters.AddWithValue("@adres", Text_adres.Text.Trim());
            sqlcom.Parameters.AddWithValue("@paremetre", text_paremetre.Text.Trim());
            sqlcom.Parameters.AddWithValue("@cari_kodu", Text_cari_kodu.Text.Trim());

            sqlcom.ExecuteNonQuery();
            connectionString.Close();
            MessageBox.Show("Cari Başarıyla Düzenlendi!", "CARİ KARTI DÜZENLEME", MessageBoxButtons.OK, MessageBoxIcon.Information);
----------------------------------------------------------
txt file =
update tbl_cariler
set cari_turu=@cari_turu , cari_adi = @cari_adi ,irtibat=@irtibat , adres = @adres, paremetre = @paremetre
where cari_kodu = @cari_kodu

gridview connect to ms sql with txt file query and get data to gridview with summary




            string connectionString = null;
            SqlConnection cnn;
            connectionString = "Server = " + ondegerler.SQLBAGLANTISI_KAYNAK + "; Database = " + ondegerler.SQLBAGLANTISI_VERITABANI + "; User Id = " + ondegerler.SQLBAGLANTISI_KULLANICI + "; Password = " + ondegerler.SQLBAGLANTISI_PAROLA;
            FileInfo file = new FileInfo(Application.StartupPath + "\\tbl_cariler.txt");
            string script = file.OpenText().ReadToEnd();
            cnn = new SqlConnection(connectionString);
            SqlDataAdapter da = new SqlDataAdapter(script, cnn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            gridControl1.DataSource = dt;
            gridView1.Columns[1].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Count;
            gridView1.Columns[1].SummaryItem.DisplayFormat = "Adet = {0}";

            gridView1.Columns["Bakiye"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            gridView1.Columns["Bakiye"].SummaryItem.DisplayFormat = "Toplam = {0}";
            gridView1.BestFitColumns();

Devexpress grid databar

            GridFormatRule gridFormatRule = new GridFormatRule();
            FormatConditionRuleDataBar formatConditionRuleDataBar = new FormatConditionRuleDataBar();
            gridFormatRule.Column = gridView1.Columns["Bakiye"];
            formatConditionRuleDataBar.PredefinedName = "Blue Gradient";
            gridFormatRule.Rule = formatConditionRuleDataBar;
            this.gridView1.FormatRules.Add(gridFormatRule);


Devexpress gridview export to excel with savefiledialog

         
            string filename;
            saveFileDialog1.Filter = "xlsx files (*.xlsx)|*.xlsx";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.ShowDialog();
            filename = saveFileDialog1.FileName;
            if (filename == "") filename = "";
            else
            {
                gridView1.ExportToXlsx(filename);
                System.Diagnostics.Process.Start(filename);
            }

VISUAL STUDIO 2013 VISUAL BASIC GRIDE EXCELDEN YAPIŞTIR

VISUAL STUDIO 2013 VISUAL BASIC GRIDE EXCELDEN YAPIŞTIR

ONCE BU FONKSIYONU EKLE;
----------------------
Sub pastefromclipboardtodatagridview(ByVal dgv As DataGridView)
        Dim rowSplitter As Char() = {vbCr, vbLf}
        Dim columnSplitter As Char() = {vbTab}

        'get the text from clipboard

        Dim dataInClipboard As IDataObject = Clipboard.GetDataObject()
        Dim stringInClipboard As String = CStr(dataInClipboard.GetData(DataFormats.Text))

        'split it into lines
        Dim rowsInClipboard As String() = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries)

        'get the row and column of selected cell in grid
        Dim r As Integer = dgv.SelectedCells(0).RowIndex
        Dim c As Integer = dgv.SelectedCells(0).ColumnIndex

        'add rows into grid to fit clipboard lines
        If (dgv.Rows.Count < (r + rowsInClipboard.Length)) Then
            dgv.Rows.Add(r + rowsInClipboard.Length - dgv.Rows.Count)
        End If

        ' loop through the lines, split them into cells and place the values in the corresponding cell.
        Dim iRow As Integer = 0
        While iRow < rowsInClipboard.Length
            'split row into cell values
            Dim valuesInRow As String() = rowsInClipboard(iRow).Split(columnSplitter)
            'cycle through cell values
            Dim iCol As Integer = 0
            While iCol < valuesInRow.Length
                'assign cell value, only if it within columns of the grid
                If (dgv.ColumnCount - 1 >= c + iCol) Then
                    dgv.Rows(r + iRow).Cells(c + iCol).Value = valuesInRow(iCol)
                End If
                iCol += 1
            End While
            iRow += 1
        End While

    End Sub

---------------

1 ADET DATAGRIDVIEW YARAT
1 ADET BUTTON YARAT
CİFT TIKLA BUTTONA
KOD:
        DataGridView1.AllowUserToAddRows = False
        DataGridView1.Rows.Add()
        pastefromclipboardtodatagridview(DataGridView1)
        DataGridView1.AllowUserToAddRows = False
        DataGridView1.Rows.Add()
        pastefromclipboardtodatagridview(DataGridView1)

Wordpress Yit woocommerce Back to top turkce yap

/wp-content/themes/regency/theme/functions-template.php

Bul;
echo '<div id="back-top"><a href="#top"><i class="fa fa-chevron-up"></i>' . __('Back to top', 'yit') . '</a></div>';


Deiştir;
echo '<div id="back-top"><a href="#top"><i class="fa fa-chevron-up"></i>' . __('Yukarı Git', 'yit') . '</a></div>';

wordpress woocommerce yit framework search for türkçe yapma

Bunu bul ve deieştir: /wp-content/themes/regency/theme/templates/searchform/post.php

<?php
/*
 * This file belongs to the YIT Framework.
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */
?>

<div class="searchform">
    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <div>
            <label class="screen-reader-text" for="s"><?php _e( 'Ara:', 'yit' ) ?></label>
            <div class="search-wrapper"><input  type="text" value="" name="s" id="s"  /></div>
            <input  type="submit" class="button" id="searchsubmit" value="<?php _e( 'Ara', 'yit' ) ?>" />
            <?php
            $post_types =  apply_filters( 'yit_searchform_post_types', array( 'post' ) );

            foreach( $post_types as $post_type ) : ?>
                <input type="hidden" name="post_type[]" value="<?php echo $post_type ?>" />
            <?php endforeach ?>
        </div>
    </form>
</div>

vs 2013 c# Devexpress gridview sağ tıklayarak excel dosyası olarak kaydet

Forma 1 adet contextMenuStrip1 ve 1 adet saveFileDialog1 at gridControl1de ki dataları excele kaydetmek için;


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.OleDb;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid;


contextMenuStrip1  tıkla Excele kaydet item yarat ve çift tıkla ve yaz;

            //excele kaydet
            string filename;
            saveFileDialog1.Filter = "xlsx files (*.xlsx)|*.xlsx";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.ShowDialog();
            filename = saveFileDialog1.FileName;
            if (filename == "") filename = ""; else gridView1.ExportToXlsx(filename);

Daha sonra gridcontrola tıkla ve contextmenustripini contextMenuStrip1 olarak seç

Visual C# 2013 Windows 7 Programa taskabara kısayollar ekleme IKONLU


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Taskbar;
using Microsoft.WindowsAPICodePack.Shell;
using System.IO;
using System.Reflection;
using System.Diagnostics;



             private void Form1_Shown(object sender, EventArgs e)
        {
            //KISAYOLLAR DOSYA YOLLARI
            string VP = "D:\\Dosyalar\\semih\\visionpluskontrol32bit\\VisionPlusKontrol32bit\\VisionPlusKontrol32bit\\bin\\Debug\\VisionPlusKontrol32bit.exe";
            string OTOMASYON = "D:\\vs 2013 projeleri\\vp\\vpws\\vpws2\\EasyEkontor3g\\EasyEkontor3g\\bin\\Debug\\EasyEkontor3g.exe";
            string DOSTELWEB = "http://182.125.142.9/ws/";
            string DOSTELWEBICONIE = "C:\\Program Files\\Internet Explorer\\iexplore.exe";

            //SIK KULLANILANLAR DOSYA YOLLARI
            string COREL = "C:\\Program Files\\Corel\\CorelDRAW Graphics Suite X6\\Programs64\\CorelDRW.exe";
            string PHOTOSHOP = "D:\\Program Files\\Adobe\\Adobe Photoshop CC 2015\\Photoshop.exe";
            string DOSYALARVEBOYUTLAR = "D:\\Program Files (x86)\\WinDirStat\\windirstat.exe";
            string SEARCHEVERYTHING = "D:\\Program Files\\Everything\\Everything.exe";
            string SMSCASTER = "C:\\Program Files (x86)\\SMSCaster\\smscaster.exe";

            JumpList KISAYOLLAR = JumpList.CreateJumpList();
            KISAYOLLAR.ClearAllUserTasks();
            JumpListLink JLLVP = new JumpListLink(VP, "VP") { IconReference = new IconReference(VP, 0) };
            JumpListLink JLLOTOMASYON = new JumpListLink(OTOMASYON, "OTOMASYON") { IconReference = new IconReference(OTOMASYON, 0) };
            JumpListLink JLLDOSTELWEB = new JumpListLink(DOSTELWEB, "DOSTEL WEB") { IconReference = new IconReference(DOSTELWEBICONIE, 0) };
            JumpListCustomCategory kategori = new JumpListCustomCategory("KISAYOLLAR");
            kategori.AddJumpListItems(JLLVP);
            kategori.AddJumpListItems(JLLOTOMASYON);
            kategori.AddJumpListItems(JLLDOSTELWEB);
            KISAYOLLAR.AddCustomCategories(kategori);

            JumpListLink JLLCOREL = new JumpListLink(COREL, "COREL X6") { IconReference = new IconReference(COREL, 0) };
            JumpListLink JLLPHOTOSHOP = new JumpListLink(PHOTOSHOP, "PHOTOSHOP 2015") { IconReference = new IconReference(PHOTOSHOP, 0) };
            JumpListLink JLLDOSYALARVEBOYUTLAR = new JumpListLink(DOSYALARVEBOYUTLAR, "WINDIRSTAT DOSYA BOYUTLARI") { IconReference = new IconReference(DOSYALARVEBOYUTLAR, 0) };
            JumpListLink JLLSEARCHEVERYTHING = new JumpListLink(SEARCHEVERYTHING, "SEARCH EVERYTHING") { IconReference = new IconReference(SEARCHEVERYTHING, 0) };
            JumpListLink JLLSMSCASTER = new JumpListLink(SMSCASTER, "SMS CASTER") { IconReference = new IconReference(SMSCASTER, 0) };
            JumpListCustomCategory kategori2 = new JumpListCustomCategory("SIK KULLANILANLAR");
            kategori2.AddJumpListItems(JLLCOREL);
            kategori2.AddJumpListItems(JLLPHOTOSHOP);
            kategori2.AddJumpListItems(JLLDOSYALARVEBOYUTLAR);
            kategori2.AddJumpListItems(JLLSEARCHEVERYTHING);
            kategori2.AddJumpListItems(JLLSMSCASTER);
            KISAYOLLAR.AddCustomCategories(kategori2);
            KISAYOLLAR.Refresh();
        }

Python ile webden altın fiyatlarını çekme

import re , urllib
liste=["Kuyumcu Alis","Kuyumcu Satis"]
# size gerekli olan adres
website=urllib.urlopen("http://www.bigpara.com/altin/ceyrek-altin-fiyati")
htmltext=website.read()
# site icinde altin fiyatinin bulundugu alan
getinspect='<span class="value up">(.+?)</span>'
pattern=re.compile(getinspect)
price=re.findall(pattern,htmltext)
j=0
for i in price:
    print liste[j]+" fiyati: "+i
    j+=1


output: 
Kuyumcu Alis fiyati: 226,72
Kuyumcu Satis fiyati: 232,39

Python 27 beatifulsoap siteden tüm linkleri çek

önce cmd satırında pip.exeyi bul ve easy_install bs4
pip install lxml


from bs4 import BeautifulSoup
import urllib2

resp = urllib2.urlopen("http://www.gpsbasecamp.com/national-parks")
soup = BeautifulSoup(resp,  "lxml")

for link in soup.find_all('a', href=True):
    print link['href']



alternatif

from bs4 import BeautifulSoup
import urllib
import re

html_page = urllib.urlopen("http://arstechnica.com")
soup = BeautifulSoup(html_page, "lxml")
for link in soup.findAll('a', attrs={'href': re.compile("^http://")}):
    print link.get('href')

Python ms sql servere bağlan

sql server kütüphanesi yüklü deilse yükle pip install pyodbc

import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=192.168.1.200;DATABASE=TIGER;UID=testu;PWD=testp')
cursor = cnxn.cursor()
cursor.execute("select * from LG_INVOICE")
rows = cursor.fetchall()
for row in rows:
    print row.DATE_


Python kütüphane ekleme

python 27 kurulduğu klasöre örnek c:\pyhton27\script cmd satırıyla git ve pip install pyodc örnek entere bas kurar.


not: cmdnin klasöre sağ tıkladığında aktif olmasını isdersen HKEY_CLASSES_ROOT\Directory\shell\cmd
den Extendedi sil ve artık klasörlere shifte basılı tutarak sağ tıklarsan okeydir...