 |
|


Code (C#)
private void Psave()
{
objconn.Conn();
string strSQL;
strSQL = "Select Per_ID,Per_CardID,Per_Sex,Per_Firstname,Per_Lastname,Per_Add,Per_District,Per_Province,Per_Postcode,Per_Phon,Per_Date,Per_Username,Per_Password,Per_Email,De_ID from Personels order by Per_ID";
sqlCMD = new SqlCommand(strSQL, objconn.conn1);
sqlDR = sqlCMD.ExecuteReader();
if (sqlDR.Read())
{
strSQL = "Update Personels set Per_CardID = '" + maskedTextBox1.Text + "'";
strSQL += ",Per_Sex = '" + comboBox1.Text + "'";
strSQL += ",Per_Firstname = '" + txtName.Text + "'";
strSQL += ",Per_Lastname = '" + txtlastname.Text + "'";
strSQL += ",Per_Add = '" + txtAdd.Text + "'";
strSQL += ",Per_District = '" + txtOum.Text + "'";
strSQL += ",Per_Province = '" + ComboBox.Text + "'";
strSQL += ",Per_Postcode = '" + txtPostcard.Text + "'";
strSQL += ",Per_Phon = '" + txtPhone.Text + "'";
strSQL += ",Per_Date = '" + txtdate.Text + "'";
strSQL += ",Per_Username = '" + dateTimePicker1.Value.ToString("s") + "'";
strSQL += ",Per_Password = '" + txtpass.Text + "'";
strSQL += ",Per_Email = '" + txtmail.Text + "'";
strSQL += ",De_ID = '" + comboBox2.Text + "'";
strSQL += "where Per_ID = '" + txtID.Text +"'";
}
else
{
strSQL = "Insert into Personels(Per_ID,Per_CardID,Per_Sex,Per_Firstname,Per_Lastname,Per_Add,Per_District,Per_Province,Per_Postcode,Per_Phon,Per_Date,Per_Username,Per_Password,Per_Email,De_ID)";
strSQL += "Values('" + txtID.Text + "','" + maskedTextBox1.Text + "','" + comboBox1.Text + "'";
strSQL += ",'" + txtName.Text + "','" + txtlastname.Text + "','" + txtAdd.Text + "','" + txtOum.Text + "','" + ComboBox.Text + "'";
strSQL += ",'" + txtPostcard.Text + "','" + txtPhone.Text + "','" + txtdate.Text + "'";
strSQL += ",'" + dateTimePicker1.Value.ToString("s") + "','" + txtpass.Text + "','" + txtmail.Text + "','" + comboBox2.Text + "')";
}
sqlDR.Close();
sqlCMD = new SqlCommand(strSQL, objconn.conn1);
int numRec = sqlCMD.ExecuteNonQuery();
if (numRec > 0)
{
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว", "บันทึกข้อมูล");
}
else
{
MessageBox.Show("ไม่สามารถบันทึกข้อมูลได้", "บันทึกข้อมูล");
}
txtID.Text = AddPer_ID().ToString();
showpesonel();
}
Tag : Ms SQL Server 2012, VB.NET, C#
|
ประวัติการแก้ไข 2013-09-08 21:13:29 2013-09-08 21:15:47
|
 |
 |
 |
 |
Date :
2013-09-08 21:12:05 |
By :
coutiho |
View :
929 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |