public bool ChkUpdate(CheckListVO chk) { string sql = @"update TBL_CHECKLIST set cl_name = @cl_name, product_id= @product_id, cl_stnd = @cl_stnd, cl_comment = @cl_comment, cl_uadmin = @cl_uadmin, cl_udate = @cl_udate, cl_type = @cl_type where cl_id = @cl_id"; using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@cl_id", chk.cl_id); cmd.Parameters.AddWithValue("@cl_name", chk.cl_name); cmd.Parameters.AddWithValue("@product_id", chk.product_id); cmd.Parameters.AddWithValue("@cl_stnd", chk.cl_stnd); cmd.Parameters.AddWithValue("@cl_comment", chk.cl_comment); cmd.Parameters.AddWithValue("@cl_uadmin", chk.cl_uadmin); cmd.Parameters.AddWithValue("@cl_type", chk.cl_type); cmd.Parameters.AddWithValue("@cl_udate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int iRowAffect = cmd.ExecuteNonQuery(); conn.Close(); return(iRowAffect > 0); } }
public bool ChkInsert(CheckListVO chk) { string sql = @"insert into TBL_CHECKLIST (cl_name, product_id, cl_stnd, cl_comment, cl_uadmin, cl_udate, cl_type) values (cl_name, product_id, cl_stnd, cl_comment, cl_uadmin, cl_udate, cl_type)"; int iRowAffect = 0; using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@cl_name", chk.cl_name); cmd.Parameters.AddWithValue("@product_id", chk.product_id); cmd.Parameters.AddWithValue("@cl_stnd", chk.cl_stnd); cmd.Parameters.AddWithValue("@cl_comment", chk.cl_comment); cmd.Parameters.AddWithValue("@cl_uadmin", chk.cl_uadmin); cmd.Parameters.AddWithValue("@cl_type", chk.cl_type); cmd.Parameters.AddWithValue("@cl_udate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); iRowAffect = cmd.ExecuteNonQuery(); Dispose(); } return(iRowAffect > 0); }
private void btnSave_Click(object sender, EventArgs e) { if (cboProductName.SelectedIndex < 1 && cboCheckType.SelectedIndex < 1 && txtCheckListName.Text.Trim().Length < 1) { MessageBox.Show("필수항목을 채워주세요"); return; } try { if (headName == "검사항목등록") { CheckListVO chk = new CheckListVO { cl_name = txtCheckListName.Text, product_id = cboProductName.SelectedValue.ToString(), cl_type = cboCheckType.Text, cl_stnd = txtStd.Text, cl_comment = txtComment.Text, cl_uadmin = txtUadmin.Text }; CheckListService service = new CheckListService(); bool bResult = service.ChkInsert(chk); if (bResult) { MessageBox.Show("새로운 검사항목을 등록하셨습니다"); } else { MessageBox.Show("등록에 실패하셨습니다"); } } else if (headName == "검사항목수정") { CheckListVO chk = new CheckListVO { cl_id = cl_id, cl_name = txtCheckListName.Text, product_id = cboProductName.SelectedValue.ToString(), cl_type = cboCheckType.Text, cl_stnd = txtStd.Text, cl_comment = txtComment.Text, cl_uadmin = txtUadmin.Text }; CheckListService service = new CheckListService(); bool bResult = service.ChkUpdate(chk); if (bResult) { MessageBox.Show("검사항목을 수정하셨습니다"); } else { MessageBox.Show("수정에 실패하셨습니다"); } } this.Close(); } catch (Exception err) { MessageBox.Show(err.Message); } }
public bool ChkUpdate(CheckListVO chk) { CheckListDAC dac = new CheckListDAC(); return(dac.ChkUpdate(chk)); }
public bool ChkInsert(CheckListVO chk) { CheckListDAC dac = new CheckListDAC(); return(dac.ChkInsert(chk)); }