private void btnOK_Click(object sender, EventArgs e) { if (Check()) { IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL(); if (!CheckDup()) { MessageBox.Show("Model Sub exist in database!", "Database Responce", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { bool show = false; if (ModelId == "") { string sqlAdd = "Insert into m_model(model_id, model_cd, model_sub_cd, user_id, registration_date_time) values((select max(model_id)+1 from m_model),'" + txtModel.Text + "', '" + txtModelSub.Text + "', (select user_id from m_user where user_name ='" + User + "'), now())"; show = tf.sqlExecuteNonQuery(sqlAdd, false); } else { string sqlUpdate = "update m_model set model_sub_cd = '" + txtModelSub.Text + "', user_id = (select user_id from m_user where user_name = '" + User + "'), registration_date_time = now() where model_id = " + int.Parse(ModelId); show = tf.sqlExecuteNonQuery(sqlUpdate, false); } if (show) { MessageBox.Show("Successful!", "Database Responce", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Info is null", "Note", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnOK_Click(object sender, EventArgs e) { if (Check()) { IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL(); if (!CheckDup()) { MessageBox.Show("Drawing Code exist in Database", "Note", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { bool showMes = false; if (DrawingId == "") { string sqlAdd = "Insert into m_drawing(model_id, dwr_cd, dwr_name, doc_name, user_id, registration_date_time) values(" + int.Parse(cmbSubModel.SelectedValue.ToString()) + ", '" + txtDwrCd.Text + "', '" + txtDwrName.Text + "', '" + txtDoc.Text + "', (select user_id from m_user where user_name ='" + User + "'), now())"; showMes = tf.sqlExecuteNonQuery(sqlAdd, false); } else { string sqlUpdate = "update m_drawing set dwr_cd = '" + txtDwrCd.Text + "', dwr_name = '" + txtDwrName.Text + "', doc_name = '" + txtDoc.Text + "', user_id = (select user_id from m_user where user_name = '" + User + "'), registration_date_time = now() where dwr_id = " + DrawingId; showMes = tf.sqlExecuteNonQuery(sqlUpdate, false); } if (showMes) { MessageBox.Show("Successful!", "Database Responce", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dgvDwr.RowCount > 0) { int dwrlId = int.Parse(dgvDwr.Rows[dgvDwr.CurrentRow.Index].Cells["dwr_id"].Value.ToString()); IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL(); string sqlDel = "delete from m_drawing where dwr_id = " + dwrlId; DialogResult dialog = MessageBox.Show("Do you want to delete " + dgvDwr.Rows[dgvDwr.CurrentRow.Index].Cells["dwr_cd"].Value.ToString(), "Note !", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialog == DialogResult.Yes) { tf.sqlExecuteNonQuery(sqlDel, false); btnSearch_Click(sender, e); } } else { MessageBox.Show("Choose a Drawing", "Note", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Choose a Drawing", "Note", MessageBoxButtons.OK, MessageBoxIcon.Information); } }