/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (FieldError(txtName) == false) { return; } else if (FieldError(txtCharacters) == false) { return; } else if (FieldError(txtBarcode) == false) { return; } else if (FieldError(txtASSYNo) == false) { return; } else { string content = $"{txtName.Text},{txtCharacters.Text},{txtBarcode.Text},{txtASSYNo.Text}"; Ultils.Write(path, content); LoadModelsData(); MessageBox.Show("Save success!"); txtBarcode.ResetText(); txtCharacters.ResetText(); txtName.ResetText(); txtASSYNo.ResetText(); } }
private void btnAdd_Click(object sender, EventArgs e) { if (FieldError(txtModel) == false) { return; } else if (FieldError(txtCode) == false) { return; } else { string modelName = $"{txtModel.Text},{txtCode.Text}"; var data = Ultils.ReadAllLines(path, Encoding.ASCII).SingleOrDefault(l => l.Contains(modelName)); if (data == null) { Ultils.Write(path, modelName); LoadData(); MessageBox.Show("Save success!"); txtModel.ResetText(); txtCode.ResetText(); } else { errorProvider1.SetError(txtModel, "Model already exists!"); txtModel.Focus(); return; } } }