private void buttonSave_Click(object sender, EventArgs e) { if (listView1.Items.Count > 0) { if (File.Exists(pathReadAnWrite)) { File.Delete(pathReadAnWrite); } string addString = ""; for (int column = 0; column < listView1.Items.Count; column++) { for (int row = 0; row < listView1.Items[column].SubItems.Count; row++) { addString += listView1.Items[column].SubItems[row].Text + "?"; } } addString = addString.TrimEnd('?'); addString = addString.ToUpper(); try { generalMethods callToMethod = new generalMethods(); callToMethod.writeInFiles(pathReadAnWrite, addString); MessageBox.Show("GUARDADDO CORRECTAMENTE"); } catch (Exception) { MessageBox.Show("ERROR AL GUARDAR"); } } else { MessageBox.Show("NO SE GUARDARA, NO EXISTEN DATOS"); } }
private void labelSave_Click(object sender, EventArgs e) { bool allowSave = true; string wrongMessage = "NO SE PODRA GUARDAR, PROBLEMAS:"; if (textBoxName.Text == " " || textBoxName.Text == "") { wrongMessage += "\n-CASILLA NOMBRE VACIO"; allowSave = false; } if (textBoxHeight.Text == " " || textBoxHeight.Text == "") { wrongMessage += "\n-CASILLA ANCHO VACIO"; allowSave = false; } bool answer = callToGeneralMethods.parseRightFormatNumbers(textBoxWidth.Text, textBoxHeight.Text); if (answer == false) { allowSave = false; wrongMessage += "\n-FORMATO NUMEROS INCORRECTO, METROS Y CENTIMENTROS, CENTIMETROS"; } if (textBoxWidth.Text == " " || textBoxWidth.Text == "") { wrongMessage += "\n-CASILLA LARGO VACIO"; allowSave = false; } if (comboBoxSize.Text == threeLine) { wrongMessage += "\n-CASILLA MEDIDA VACIO"; allowSave = false; } if (allowSave == true) { int index = panel1.Controls.Count + 1; index -= 3; string name = textBoxName.Text.ToUpper(); string pathWrite = globalPathReadAndWrite; pathWrite += name + ".txt"; string addString = ""; addString += globalOrderMaterial + index.ToString() + "?"; addString += textBoxHeight.Text + "?"; addString += textBoxWidth.Text + "?"; addString += comboBoxSize.Text; callToGeneralMethods.writeInFiles(pathWrite, addString); componentsRestart(); chargeDataStart(); MessageBox.Show("GUARDADO EXITOSAMENTE"); } else { MessageBox.Show(wrongMessage); } }