Tùy biến control – Thêm control runtime

Khi đã chạy web bạn có thể thêm hoặc remove các control với jQuery 1.4

Thêm thư viện jQuery

<script type="text/javascript" src="jquery-1.4.min.js"></script>
<script type="text/javascript" src="jquery.sheepItPlugin-1.0.0.min.js"></script>
Phần Javascript
$(document).ready(function() {
    
    var sheepItForm = $('#sheepItForm').sheepIt({
        separator: '',
        allowRemoveLast: true,
        allowRemoveCurrent: true,
        allowRemoveAll: true,
        allowAdd: true,
        allowAddN: true,
        maxFormsCount: 10,
        minFormsCount: 0,
        iniFormsCount: 2
    });
});
Phần HTML
<!-- sheepIt Form -->
<div id="sheepItForm">
  <!-- Form template-->
  <div id="sheepItForm_template">
    <label for="sheepItForm_#index#_phone">Phone <span id="sheepItForm_label"></span></label>
    <input id="sheepItForm_#index#_phone" name="person[phones][#index#][phone]" type="text"/>
    <a id="sheepItForm_remove_current">
      <img class="delete" src="images/cross.png" width="16" height="16" border="0">
    </a>
  </div>
  <!-- /Form template-->
  
  <!-- No forms template -->
  <div id="sheepItForm_noforms_template">No phones</div>
  <!-- /No forms template-->
  
  <!-- Controls -->
  <div id="sheepItForm_controls">
    <div id="sheepItForm_add"><a><span>Add phone</span></a></div>
    <div id="sheepItForm_remove_last"><a><span>Remove</span></a></div>
    <div id="sheepItForm_remove_all"><a><span>Remove all</span></a></div>
    <div id="sheepItForm_add_n">
      <input id="sheepItForm_add_n_input" type="text" size="4" />
      <div id="sheepItForm_add_n_button"><a><span>Add</span></a></div></div>
  </div>
  <!-- /Controls -->
  
</div>
<!-- /sheepIt Form -->

Hiển thị code trong bài viết WordPress

[c o d e language=”c-sharp”]

//Noi dung code

//Các bạn gõ chữ code liền lại nhé

[/ c o d e]

  • Bash — bash, sh
  • C++ — cpp, c, c++
  • C# — c#, c-sharp, csharp
  • CSS — css
  • Delphi — delphi, pascal
  • Diff — diff
  • Groovy — groovy
  • Java — java
  • JavaScript — js, jscript, javascript
  • Perl — perl, pl
  • PHP — php
  • Plain text — plain, text
  • Python — py, python
  • Ruby — rb, ruby, rails, ror
  • Scala — scala
  • SQL — sql
  • VB — vb, vb.net
  • XML/HTML — xml, html, xhtml, xslt

private static void ShowMain()
{
Console.WriteLine("Hello!");
}

Rows next,previous,last,first in dataGridView

btnPrevious_Click

if (itemsDataGridView.CurrentRow == null) return;
 if (itemsDataGridView.CurrentRow.Index==0)
 {
 itemsDataGridView.CurrentCell =
 itemsDataGridView.Rows[
 Math.Min(itemsDataGridView.CurrentRow.Index, itemsDataGridView.Rows.Count)].Cells[
 itemsDataGridView.CurrentCell.ColumnIndex];
 }
 else
 {
 itemsDataGridView.ClearSelection();
 itemsDataGridView.CurrentCell =
 itemsDataGridView.Rows[Math.Min(itemsDataGridView.CurrentRow.Index - 1, itemsDataGridView.Rows.Count - 1)].Cells
 [itemsDataGridView.CurrentCell.ColumnIndex];
 }

btnLast_Click

if (itemsDataGridView.CurrentRow!=null)
 {
 itemsDataGridView.CurrentCell = itemsDataGridView[itemsDataGridView.CurrentCell.ColumnIndex, itemsDataGridView.Rows.Count-2];
 }

btnFirst_Click

if (itemsDataGridView.CurrentRow!=null)
 {
 itemsDataGridView.CurrentCell = itemsDataGridView[itemsDataGridView.CurrentCell.ColumnIndex, 0];
 }
btnNext_Click
if (itemsDataGridView.CurrentRow == null) return;
 if (itemsDataGridView.Rows.Count == itemsDataGridView.CurrentRow.Index+1)
 {
 itemsDataGridView.CurrentCell =
 itemsDataGridView.Rows[
 Math.Min(itemsDataGridView.CurrentRow.Index, itemsDataGridView.Rows.Count)].
 Cells[itemsDataGridView.CurrentCell.ColumnIndex];
 }
 else
 {
 itemsDataGridView.ClearSelection();
 itemsDataGridView.CurrentCell =
 itemsDataGridView.Rows[Math.Min(itemsDataGridView.CurrentRow.Index + 1, itemsDataGridView.Rows.Count - 1)].Cells
 [itemsDataGridView.CurrentCell.ColumnIndex];
 }

Create crystal report VS 2010 using sql query

Now, we create crystal report using sql query

—————————

DATABASE

CREATE DATABASE Products

GO

USE Products

GO

CREATE TABLE Product

(

ProID int PRIMARY KEY IDENTITY,

ProName VARCHAR(50),

Quantity int,

UnitPrice int

)

Step 1: Create Project windows form

Step 2: Add 1 button, 1 textbox and 1 crystalReportViewer on your form.

Step 3: Add New Item (Ctrl+Shit+A), create new DataSet, in DataSet you create DataTable, then you add columns(Ctrl+L)

Note: name column must be as same name culomns in database and data type (you edit at Properties)

Step 4: Create CrystalReport, then choose Project Data > ADO.Net >DataSet you created >> >>>

Step 5: Write event for button

SqlConnection conn = new SqlConnection(“server=.;database=Products;uid=sa;pwd=sa”);
conn.Open();
var sql =”SELECT ProID,ProName,Quantity,UnitPrice FROM Products WHERE ProName = ‘”+textbox1.Text+”‘;
var DA = new SqlDataAdapter(sql,conn);
var DS = new DataSet1();
DA.Fill(DS);
conn.Close();
var objCry = new CrystalReport1();
objCry.SetDataSource(DS.Tables[1]);
crystalReportViewer1.ReportSource = objCry;
crystalReportViewer1.Refresh();