private void iNSERTToolStripMenuItem_Click(object sender, EventArgs e) { ListViewItem li; inputbox b; string cs; if (lvlist.SelectedItems.Count > 0) { li = lvlist.SelectedItems[0]; b = new inputbox(Convert.ToDateTime(li.SubItems[2].Text)); b.ShowDialog(this); } else { b = new inputbox(); b.ShowDialog(this); } if (b.result) { try { //td = Convert.ToDateTime(b.txtInput.Text); cs = "insert into record_ta(Mach_no,pinfo_id,card_number,date_time,fun_key,in_out) values('1'," + uid + ",'" + uid + "','" + b.dtDateTime.Text + "',0,0)"; cmd.CommandText = cs; cmd.ExecuteNonQuery(); filllist(); } catch (Exception er) { MessageBox.Show("invalid value" + " " + er.Message); } } }
private void eDITToolStripMenuItem_Click(object sender, EventArgs e) { DateTime oldtime; ListViewItem li; inputbox b; string cs; li = lvlist.SelectedItems[0]; oldtime = Convert.ToDateTime(li.SubItems[2].Text); //b = new inputbox(String.Format("{0:yyyy}-{0:MM}-{0:dd} {0:HH}:{0:mm}:{0:ss}", oldtime)); b = new inputbox(oldtime); b.ShowDialog(this); if (b.result) { try { //td = Convert.ToDateTime(b.txtInput.Text); //cs = "update record_ta set date_time = '" + b.txtInput.Text + "' where id=" + li.SubItems[3].Text; cs = "update record_ta set date_time = '" + b.dtDateTime.Text + "' where id=" + li.SubItems[3].Text; cmd.CommandText = cs; cmd.ExecuteNonQuery(); filllist(); } catch (Exception er) { MessageBox.Show("invalid value" + " " + er.Message); } } }