private void button2_Click(object sender, EventArgs e) { AutoGenAsssetCode autoGen = new AutoGenAsssetCode(); autoGen.AutoGenCode(); txtMaTS.Text = autoGen.code; btnAddNew.Enabled = true; btnNewItem2.Enabled = true; cbTypeLV2.Enabled = false; loaddata.LoadModel(cbModel); txtFATag.ResetText(); txtITTag.ResetText(); txtSN.ResetText(); }
private void btnAddType_Click(object sender, EventArgs e) { try { string TypeCode = ""; AutoGenAsssetCode asssetCode = new AutoGenAsssetCode(); asssetCode.AutoGenTypeCode(); TypeCode = asssetCode.TypeCode; string strNewType = "Insert into Loai_TS_cap2 (Ma_loai, Ten_loai, Phan_loai) VALUES (:Type, :Name, :Class)"; OracleCommand cmdNewType = new OracleCommand(); cmdNewType.Connection = con; cmdNewType.CommandType = CommandType.Text; cmdNewType.CommandText = strNewType; cmdNewType.Parameters.Add("Type", TypeCode.ToString()); cmdNewType.Parameters.Add("Name", txtType2Name.Text.ToString()); cmdNewType.Parameters.Add("Class", cbType1.SelectedValue); if (AntiDuplicated.CheckTypeLevel2(txtType2Name.Text.ToString().Trim(), cbType1.SelectedValue.ToString())) { con.Open(); cmdNewType.ExecuteNonQuery(); con.Close(); } else if (!(AntiDuplicated.CheckTypeLevel2(txtType2Name.Text.ToString().Trim(), cbType1.SelectedValue.ToString()))) { MessageBox.Show("Trùng!!!"); } LoadTypeDevice(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }