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!");
}
}
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);
// 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);
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);
}
Subscribe to:
Posts (Atom)