|
 |
|
อยากถามเรื่องการแสดงข้อมูลใน gridview ข้อมูลมันไม่แสดงทุก field ค่ะ |
|
 |
|
|
 |
 |
|
ในตาราง gridview ตรง field OrderCustomerID ข้อมูลตรงส่วนนี้มันไม่แสดง ส่วนอื่นแสดงออกหมดแล้ว รบกวนช่วยดูให้ทีค่ะว่ามันผิดตรงไหน
Code (C#)
private void cmdSearch_Click(object sender, EventArgs e)
{
string sqlSearch = "";
string d1 = startDate.Value.Day + "/" + startDate.Value.Month + "/" + startDate.Value.Year;
string d2 = EndDate.Value.Day + "/" + EndDate.Value.Month + "/" + EndDate.Value.Year;
sqlSearch = "SELECT OrderCustomer.OrderCustomerID, OrderCustomer.CustomerID,Product.ProductName,";
sqlSearch += " OrderCustomer.OrderCustomerDate, OrderCustomer.OrderCustomerStatus, OrderCustomerDetail.*,Product.ProductID";
sqlSearch += " FROM Customer, Product, OrderCustomerDetail INNER JOIN OrderCustomer ON OrderCustomerDetail.OrderCustomerID = OrderCustomer.OrderCustomerID";
sqlSearch += " WHERE (OrderCustomer.OrderCustomerDate BETWEEN #" + d1;
sqlSearch += " # AND #" + d2 + "#)";
sqlSearch += " AND (OrderCustomer.OrderCustomerStatus='1')";
sqlSearch += " AND (OrderCustomerDetail.OrderCustomerID=OrderCustomer.OrderCustomerID)";
sqlSearch += " AND (Product.ProductID=OrderCustomerDetail.ProductID)";
sqlSearch += " ORDER BY OrderCustomer.OrderCustomerDate DESC";
com = new OleDbCommand();
da = new OleDbDataAdapter(sqlSearch, Con);
da.Fill(ds, "OrderCustomer");
if (ds.Tables["OrderCustomer"].Rows.Count != 0) {
cmdPrint.Enabled = true;
dgvOrderCustomer.DataSource = ds.Tables["OrderCustomer"];
CalculateNetPrice();
} else {
dgvOrderCustomer.DataSource = null;
MessageBox.Show("ไม่่มีรายการสั่งซื้อในวันที่" + " " + startDate.Value.ToShortDateString() + " " + "ถึง" + " " + EndDate.Value.ToShortDateString(), "ผลการตรวสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
FormatDgvData();
}
private void FormatDgvData()
{
DataGridViewTextBoxColumn txtCol;
dgvOrderCustomer.Columns.Clear();
dgvOrderCustomer.DefaultCellStyle.BackColor = Color.WhiteSmoke;
dgvOrderCustomer.AlternatingRowsDefaultCellStyle.BackColor = Color.Turquoise;
txtCol = new DataGridViewTextBoxColumn();
txtCol.DataPropertyName = "OrderCustomerID";
txtCol.HeaderText = "หมายเลขใบสั่งซื้อ";
txtCol.ReadOnly = true;
txtCol.Width = 120;
this.dgvOrderCustomer.Columns.Add(txtCol);
txtCol = new DataGridViewTextBoxColumn();
txtCol.DataPropertyName = "CustomerID";
txtCol.HeaderText = "รหัสลูกค้า";
txtCol.ReadOnly = true;
txtCol.Width = 80;
this.dgvOrderCustomer.Columns.Add(txtCol);
txtCol = new DataGridViewTextBoxColumn();
txtCol.DataPropertyName = "OrderCustomerDate";
txtCol.HeaderText = "วันที่สั่งสินค้า";
txtCol.ReadOnly = true;
txtCol.Width = 100;
this.dgvOrderCustomer.Columns.Add(txtCol);
txtCol = new DataGridViewTextBoxColumn();
txtCol.DataPropertyName = "ProductName";
txtCol.HeaderText = "ชื่อสินค้า";
txtCol.ReadOnly = true;
txtCol.Width = 100;
this.dgvOrderCustomer.Columns.Add(txtCol);
txtCol = new DataGridViewTextBoxColumn();
txtCol.DataPropertyName = "Amount";
txtCol.HeaderText = "จำนวน";
txtCol.ReadOnly = true;
txtCol.Width = 100;
txtCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
this.dgvOrderCustomer.Columns.Add(txtCol);
txtCol = new DataGridViewTextBoxColumn();
txtCol.DataPropertyName = "Total";
txtCol.HeaderText = "ราคาสุทธิ";
txtCol.ReadOnly = true;
txtCol.Width = 90;
txtCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
this.dgvOrderCustomer.Columns.Add(txtCol);
}
Tag : .NET, Ms Access, Win (Windows App), C#

|
|
 |
 |
 |
 |
Date :
2013-02-24 17:06:38 |
By :
Guest |
View :
843 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

มันแแสดงแบบนี้ค่ะ
|
 |
 |
 |
 |
Date :
2013-02-24 17:29:48 |
By :
Guest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
DataGridView1.RowHeadersVisible = true;
|
 |
 |
 |
 |
Date :
2013-02-25 06:47:31 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ยังไม่ได้อยู่ดีค่ะ
|
 |
 |
 |
 |
Date :
2013-02-25 17:02:03 |
By :
Guest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดู data ใน db ก่อนว่า field นั้นมี data ไหม
มันแปลกๆ อยู่
|
 |
 |
 |
 |
Date :
2013-02-26 08:33:52 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะ ขอบคุณมากสำหรับคำแนะนำ เป็นที่ db จริงๆ
|
 |
 |
 |
 |
Date :
2013-02-26 17:14:15 |
By :
Guest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|