taken
datagridview then define coloumn and fill value by datatable by using
sql server,You can define textbox and combox and bUttons in DataGridView
...
private
void CreateComboPer()
{
DataGridViewComboBoxColumn
ColumnMemoPer = new DataGridViewComboBoxColumn();
ColumnMemoPer.DataPropertyName = "Particular";
ColumnMemoPer.HeaderText = "Particular";
ColumnMemoPer.Width = 150;
dataGridView1.Columns.Add(ColumnMemoPer);
string
part = "SELECT DISTINCT Particular FROM
dbo.Particular_Information";
SqlDataAdapter
daPer = new SqlDataAdapter(part,
dut.Con);
DataTable
dtPer = new DataTable();
dtPer = dut.GetDataTable(part);
ColumnMemoPer.DataSource = dtPer;
ColumnMemoPer.DisplayMember = "Particular";
ColumnMemoPer.ValueMember = "Particular";
}
private
void FillText()
{
DataGridViewTextBoxColumn
ColumnMemoPackId = new DataGridViewTextBoxColumn();
ColumnMemoPackId.DataPropertyName =
"PackingId";
ColumnMemoPackId.HeaderText = "PackingId";
ColumnMemoPackId.Width = 30;
dataGridView1.Columns.Add(ColumnMemoPackId);
DataGridViewTextBoxColumn
ColumnMemoQuality = new DataGridViewTextBoxColumn();
ColumnMemoQuality.DataPropertyName
= "Quality";
ColumnMemoQuality.HeaderText = "Quality";
ColumnMemoQuality.Width = 100;
dataGridView1.Columns.Add(ColumnMemoQuality);
DataGridViewTextBoxColumn
ColumnMemoNoPack = new DataGridViewTextBoxColumn();
ColumnMemoNoPack.DataPropertyName =
"NoPacking";
ColumnMemoNoPack.HeaderText = "NoPacking";
ColumnMemoNoPack.Width = 30;
dataGridView1.Columns.Add(ColumnMemoNoPack);
DataGridViewTextBoxColumn
ColumnMemoPackType = new DataGridViewTextBoxColumn();
ColumnMemoPackType.DataPropertyName
= "SpType";
ColumnMemoPackType.HeaderText = "SpType";
ColumnMemoPackType.Width = 50;
dataGridView1.Columns.Add(ColumnMemoPackType);
DataGridViewTextBoxColumn
ColumnMemoSpe = new DataGridViewTextBoxColumn();
ColumnMemoSpe.DataPropertyName = "Specification";
ColumnMemoSpe.HeaderText = "Specification";
ColumnMemoSpe.Width = 100;
dataGridView1.Columns.Add(ColumnMemoSpe);
DataGridViewComboBoxColumn
cmb = new DataGridViewComboBoxColumn();
cmb.HeaderText = "Select Weight";
cmb.Width = 70;
cmb.Name = "cmb";
cmb.MaxDropDownItems = 2;
cmb.Items.Add("Gross Wt.");
cmb.Items.Add("Net Wt.");
dataGridView1.Columns.Add(cmb);
DataGridViewTextBoxColumn
ColumnMemoQty = new DataGridViewTextBoxColumn();
ColumnMemoQty.DataPropertyName = "TypeofPacking";
ColumnMemoQty.HeaderText = "Quantity";
ColumnMemoQty.Width = 100;
dataGridView1.Columns.Add(ColumnMemoQty);
DataGridViewTextBoxColumn
ColumnMemoUnit = new DataGridViewTextBoxColumn();
ColumnMemoUnit.DataPropertyName = "Unit";
ColumnMemoUnit.HeaderText = "Unit";
ColumnMemoUnit.Width = 50;
dataGridView1.Columns.Add(ColumnMemoUnit);
DataGridViewTextBoxColumn
ColumnMemoRate = new DataGridViewTextBoxColumn();
ColumnMemoRate.DataPropertyName = "Rate";
ColumnMemoRate.HeaderText = "Rate";
ColumnMemoRate.Width = 80;
dataGridView1.Columns.Add(ColumnMemoRate);
DataGridViewTextBoxColumn
ColumnMemoAmt = new DataGridViewTextBoxColumn();
ColumnMemoAmt.DataPropertyName = "Amount";
ColumnMemoAmt.HeaderText = "Amount";
ColumnMemoAmt.Width = 100;
dataGridView1.Columns.Add(ColumnMemoAmt);
string
Querytxt = "SELECT PackingId,
NoPacking,SpType, Specification,TypeofPacking,Unit,NettWt,Nunit FROM
dbo.Pack_Summary_VW WHERE PackingId='" + txtmsPackId.Text.ToString()
+"'";
DataTable
dttxt = new DataTable();
dttxt = dut.GetDataTable(Querytxt);
foreach
(DataRow drtxt in
dttxt.Rows)
{
ColumnMemoPackId.Name =
drtxt[0].ToString();
ColumnMemoNoPack.Name =
drtxt[1].ToString();
ColumnMemoPackType.Name =
drtxt[2].ToString();
ColumnMemoSpe.Name =
drtxt[3].ToString();
ColumnMemoQty.Name =
drtxt[4].ToString();
ColumnMemoUnit.Name =
drtxt[5].ToString();
}
dataGridView1.DataSource = dttxt;
}
No comments:
Post a Comment