|
|
|
ถามเกี่ยวกับการจำค่า toolStripButton ไปแก้ไข้อีก From ครับๆๆ จำค่าต้องใช้คำสั่งอะไร |
|
|
|
|
|
|
|
Code (C#)
f._strID = this.toolStripCboYear1.Items.ToString();
ส่งแบบนี้ก็ถูกแล้วน่ะครับ
|
|
|
|
|
Date :
2011-09-04 21:33:34 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้ครับๆๆ นี้เป็นไฟร์ Edti
Code (C#)
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 MySql.Data.MySqlClient;
namespace StudentsEazy
{
public partial class frmStudentsEdit : Form
{
MySqlConnection objConn = new MySqlConnection();
MySqlCommand objCmd = new MySqlCommand();
string strID = "";
public frmStudentsEdit()
{
InitializeComponent();
}
public string _strID
{
get { return strID; }
set { strID = value; }
}
private void frmStudentsEdit_Load(object sender, EventArgs e)
{
String strConnString;
MySqlConnection myConnection = default(MySqlConnection);
DataTable dt = new DataTable();
MySqlDataAdapter Adapter = default(MySqlDataAdapter);
strConnString = "Server=localhost;User Id=root; Password=123123; Database=db_project; Pooling=false";
myConnection = new MySqlConnection(strConnString);
myConnection.Open();
MySqlCommand myCommand = myConnection.CreateCommand();
// myCommand.CommandText = "SELECT PrefixID,StdFirstname,StdLastname,Pin,Gender,Brithdate,National,Region,BanNo,Moo,Tumbol,Ampher,Province,ZIPcode,Phone,StdStatus,InAcmYear,DateInSch,ExSchool,SchProvince,LastClass,ExReason,Father,Mother,Parent FROM register WHERE StdID = '" + strID + "' ";
myCommand.CommandText = "SELECT StdFirstname FROM students WHERE StdID = '" + strID + "' ";
myCommand.CommandType = CommandType.Text;
Adapter = new MySqlDataAdapter(myCommand);
Adapter.Fill(dt);
myConnection.Close();
if (dt.Rows.Count < 0)
{
this.txtFirstname.Text = dt.Rows[0]["StdFirstname"].ToString();
this.txtStdID.Text = dt.Rows[0]["StdID"].ToString();
/* this.cmbPrefix.Text = dt.Rows[0]["Name"].ToString();
this.Lastname.Text = dt.Rows[0]["Lastname"].ToString();
this.txtLastname.Text = dt.Rows[0]["Degree"].ToString();
this.txtPin.Text = dt.Rows[0]["Room"].ToString();
this.txtSex.Text = dt.Rows[0]["Number"].ToString();
this.dateTimePicker1.Text = dt.Rows[0]["Number_ID"].ToString();
this.txtNational.Text = dt.Rows[0]["Term"].ToString();
this.txtRegion.Text = dt.Rows[0]["Academic_year"].ToString();
this.txtNo.Text = dt.Rows[0]["Code_1"].ToString();
this.txtMoo.Text = dt.Rows[0]["Code_2"].ToString();
this.txtTambol.Text = dt.Rows[0]["Code_3"].ToString();
this.txtAmpher.Text = dt.Rows[0]["Code_4"].ToString();
this.cmbProvince.Text = dt.Rows[0]["Code_5"].ToString();
this.txtSphone.Text = dt.Rows[0]["Code_6"].ToString();
this.txtStatus.Text = dt.Rows[0]["Code_7"].ToString();
this.txtYearIn.Text = dt.Rows[0]["Code_8"].ToString();
this.dateTimePicker2.Text = dt.Rows[0]["Sub_ID_1"].ToString();
this.cmbExProv.Text = dt.Rows[0]["Sub_ID_2"].ToString();
this.txtExClass.Text = dt.Rows[0]["Sub_ID_3"].ToString();
this.txtExReason.Text = dt.Rows[0]["Sub_ID_4"].ToString();
this.txtFather.Text = dt.Rows[0]["Sub_ID_5"].ToString();
this.txtMother.Text = dt.Rows[0]["Sub_ID_6"].ToString();
this.txtParent.Text = dt.Rows[0]["Sub_ID_7"].ToString();
this.ZIP_code.Text = dt.Rows[0]["Sub_ID_8"].ToString();*/
}
dt = null;
}
private void toolStripButton8_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtStdID.Text))
{
MessageBox.Show("Please input (เลขประจำตัวนักเรียน)");
this.txtStdID.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtPin.Text))
{
MessageBox.Show("Please input (เลขประจำตัวประชาชน)");
this.txtPin.Focus();
return;
}
if (string.IsNullOrEmpty(this.cmbPrefix.Text))
{
MessageBox.Show("Please input (คำนำหน้า)");
this.cmbPrefix.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtFirstname.Text))
{
MessageBox.Show("Please input (ชื่อ)");
this.txtFirstname.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtLastname.Text))
{
MessageBox.Show("Please input (สกุล)");
this.txtLastname.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtSex.Text))
{
MessageBox.Show("Please input (เพศ)");
this.txtSex.Focus();
return;
}
if (string.IsNullOrEmpty(this.dateTimePicker1.Text))
{
MessageBox.Show("Please input (วัน/เดือน/ปี เกิด)");
this.dateTimePicker1.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtNational.Text))
{
MessageBox.Show("Please input (สัญชาติ)");
this.txtNational.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtRegion.Text))
{
MessageBox.Show("Please input (ศาสนา)");
this.txtRegion.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtNo.Text))
{
MessageBox.Show("Please input บ้านเลขที่");
this.txtNo.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtMoo.Text))
{
MessageBox.Show("Please input หมู่ที่");
this.txtMoo.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtTambol.Text))
{
MessageBox.Show("Please input ตำบล");
this.txtTambol.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtAmpher.Text ))
{
MessageBox.Show("Please input อำเภอ");
this.txtAmpher.Focus();
return;
}
if (string.IsNullOrEmpty(this.cmbProvince.Text))
{
MessageBox.Show("Please input จังหวัด");
this.cmbProvince.Focus();
return;
}
if (string.IsNullOrEmpty(this.ZIP_code.Text ))
{
MessageBox.Show("Please input รหัสไปรษณีย์");
this.ZIP_code.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtSphone.Text ))
{
MessageBox.Show("Please input เบอร์โทร");
this.txtSphone.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtStatus.Text))
{
MessageBox.Show("Please input สถานะนักเรียน");
this.txtStatus.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtYearIn.Text ))
{
MessageBox.Show("Please input ปีการศึกษาที่เข้าวัน");
this.txtYearIn.Focus();
return;
}
if (string.IsNullOrEmpty(this.dateTimePicker2.Text))
{
MessageBox.Show("Please input วัน/เดือน/ปี ที่เข้า");
this.dateTimePicker2.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtOldSch.Text ))
{
MessageBox.Show("Please input โรงเรียนเดิม");
this.txtOldSch.Focus();
return;
}
if (string.IsNullOrEmpty(this.cmbExProv.Text ))
{
MessageBox.Show("Please input จังหวัด");
this.cmbExProv.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtExClass.Text))
{
MessageBox.Show("Please input ชั้นเรียนสุดท้าย");
this.txtExClass.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtExReason.Text ))
{
MessageBox.Show("Please input เหตุการที่ออกจากโรงเรียนเดิม");
this.txtExReason.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtFather.Text))
{
MessageBox.Show("Please input ชื่อ บิดา");
this.txtFather.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtMother.Text ))
{
MessageBox.Show("Please input ชื่อ มารดา");
this.txtMother.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtParent.Text ))
{
MessageBox.Show("Please input ชื่อผู้ปกครอง");
this.txtParent.Focus();
return;
}
string dt = dateTimePicker1.Value.ToString("yyyy-MM-dd");
string dtpIn = dateTimePicker2.Value.ToString("yyyy-MM-dd");
String strConnString;
strConnString = "Server=localhost;User Id=root; Password=123123; Database=db_project; Pooling=false; Allow Zero Datetime=false;";
objConn = new MySqlConnection(strConnString);
objConn.Open();
strConnString = "UPDATE students SET PrefixID ='" + this.cmbPrefix.Text + "',StdFirstname ='" + this.txtFirstname.Text + "',StdLastname ='" + this.txtLastname.Text + "',Pin ='" + this.txtPin.Text + "',Gender ='" + this.txtSex.Text + "',Brithdate ='" + dt + "',National ='" + this.txtNational.Text + "',Region ='" + this.txtRegion.Text + "',BanNo ='" + this.txtNo.Text + "',Moo ='" + this.txtMoo.Text + "',Tumbol ='" + this.txtTambol.Text + "',Ampher ='" + this.txtAmpher.Text + "',Province ='" + this.cmbProvince.Text + "',ZIPcode ='" + this.ZIP_code.Text + "',Phone ='" + this.txtSphone.Text + "',StdStatus ='" + this.txtStatus.Text + "',InAcmYear ='" + this.txtYearIn.Text + "',DateInSch ='" + dtpIn + "',ExSchool ='" + this.txtOldSch.Text + "',SchProvince ='" + this.cmbExProv.Text + "',LastClass ='" + this.txtExClass.Text + "',ExReason ='" + this.txtExReason.Text + "',Father ='" + this.txtFather.Text + "',Mother ='" + this.txtMother.Text + "',Parent ='" + this.txtParent.Text + "'WHERE StdID ='" + this.txtStdID.Text + "' ";
objCmd = new MySqlCommand(strConnString, objConn);
objCmd.ExecuteReader();
MessageBox.Show("Save Successfully.");
this.Hide();
frmStudents f = new frmStudents();
f.Show();
}
}
}
|
|
|
|
|
Date :
2011-09-04 21:44:15 |
By :
noi014 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยทีครับยังไม่ได้จิงๆๆ
|
|
|
|
|
Date :
2011-09-04 21:44:52 |
By :
noi014 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันไปหน้า ต่อไปได้อยุ่ครับ แต่มันไม่ดึงฐานข้อมูล ออกมาแสดงๆๆครับๆ ว่างไปเลย
|
|
|
|
|
Date :
2011-09-04 21:52:57 |
By :
noi014 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้างั้นคุณจะต้อง Debug ดูที่ SQL Statement ครับ
|
|
|
|
|
Date :
2011-09-04 21:54:22 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
public partial class frmStudentsEdit : Form
{
MySqlConnection objConn = new MySqlConnection();
MySqlCommand objCmd = new MySqlCommand();
public frmStudentsEdit()
{
InitializeComponent();
}
string strID = "";
public string _strID
{
get { return strID; }
set { strID = value; }
}
private void frmStudentsEdit_Load(object sender, EventArgs e)
{
String strConnString;
MySqlConnection myConnection = default(MySqlConnection);
DataTable dt = new DataTable();
MySqlDataAdapter Adapter = default(MySqlDataAdapter);
strConnString = "Server=localhost;User Id=root; Password=123123; Database=db_project; Pooling=false";
myConnection = new MySqlConnection(strConnString);
myConnection.Open();
MySqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = "SELECT PrefixID,StdFirstname,StdLastname,Pin,Gender,Brithdate,National,Region,BanNo,Moo,Tumbol,Ampher,Province,ZIPcode,Phone,StdStatus,InAcmYear,DateInSch,ExSchool,SchProvince,LastClass,ExReason,Father,Mother,Parent FROM students WHERE StdID = '" + strID + "' ";
myCommand.CommandType = CommandType.Text;
Adapter = new MySqlDataAdapter(myCommand);
Adapter.Fill(dt);
myConnection.Close();
if (dt.Rows.Count > 0)
{
this.cmbPrefix.Text = dt.Rows[0]["PrefixID"].ToString();
this.txtFirstname.Text = dt.Rows[0]["StdFirstname"].ToString();
this.txtStdID.Text = dt.Rows[0]["StdID"].ToString();
//this.Lastname.Text = dt.Rows[0]["StdLastname"].ToString();
this.txtLastname.Text = dt.Rows[0]["StdLastname"].ToString();
this.txtPin.Text = dt.Rows[0]["Pin"].ToString();
this.txtSex.Text = dt.Rows[0]["Gender"].ToString();
this.dateTimePicker1.Text = dt.Rows[0]["Brithdate"].ToString();
this.txtNational.Text = dt.Rows[0]["National"].ToString();
this.txtRegion.Text = dt.Rows[0]["Region"].ToString();
this.txtNo.Text = dt.Rows[0]["BanNo"].ToString();
this.txtMoo.Text = dt.Rows[0]["Moo"].ToString();
this.txtTambol.Text = dt.Rows[0]["Tumbol"].ToString();
this.txtAmpher.Text = dt.Rows[0]["Ampher"].ToString();
this.cmbProvince.Text = dt.Rows[0]["Province"].ToString();
this.txtSphone.Text = dt.Rows[0]["Phone"].ToString();
this.txtStatus.Text = dt.Rows[0]["StdStatus"].ToString();
this.txtYearIn.Text = dt.Rows[0]["InAcmYear"].ToString();
this.dateTimePicker2.Text = dt.Rows[0]["DateInSch"].ToString();//,,,,,,,,ExSchool
this.cmbExProv.Text = dt.Rows[0]["SchProvince"].ToString();
this.txtExClass.Text = dt.Rows[0]["LastClass"].ToString();
this.txtExReason.Text = dt.Rows[0]["ExReason"].ToString();
this.txtFather.Text = dt.Rows[0]["Father"].ToString();
this.txtMother.Text = dt.Rows[0]["Mother"].ToString();
this.txtParent.Text = dt.Rows[0]["Paren"].ToString();
this.ZIP_code.Text = dt.Rows[0]["ZIPcode"].ToString();
}
dt = null;
ยังไม่ได้ครับๆๆ ช่วยที
|
|
|
|
|
Date :
2011-09-04 22:21:48 |
By :
noi014 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|