Ejemplo n.º 1
0
        private string add_characteristics_yes_no()
        {
            string msg_error = "";
            string name = yes_no.name();
            int id = yes_no.id();
            bool value = false;

            if (id == -1) msg_error += "ID value is not correct.\n";
            if (name.Equals("")) msg_error += "Name is not correct.\n";

            if (id != -1 && name.Equals("") == false)
            {
                string msg = "The characteristics will be edited. The software will lose these attributes. Want Continue?";
                DialogResult r = MessageBox.Show(msg, "Edit Characteristics", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (r == DialogResult.Yes)
                {
                    // remove e depois insere
                    bool rem = Business.ManagementDataBase.remove_characteristics(id);
                    // se removeu, vai inserir
                    if (rem)
                    {
                        Business.Characteristic c = new Business.YesNoCharacteristic(id, name, value);
                        bool b = Business.ManagementDataBase.add_characteristics(c);
                        if (b)
                        {
                            MessageBox.Show("Characteristics edited.", "Characteristics", MessageBoxButtons.OK, MessageBoxIcon.None);
                        }
                        else
                        {
                            msg_error += "Error adding.\nPlease check if the ID does not exist yet.\n";
                        }
                    }
                }

            }
            return msg_error;
        }
Ejemplo n.º 2
0
        private string add_characteristics_yes_no()
        {
            string msg_error = "";
            string name = yes_no.name();
            int id = yes_no.id();
            bool value = false;

            if (id == -1) msg_error += "ID value is not correct.\n";
            if (name.Equals("")) msg_error += "Name is not correct.\n";

            if (id != -1 && name.Equals("") == false)
            {
                Business.Characteristic c = new Business.YesNoCharacteristic(id, name, value);
                bool b = Business.ManagementDataBase.add_characteristics(c);
                if (b)
                {
                    MessageBox.Show("Characteristics added.", "Characteristics", MessageBoxButtons.OK, MessageBoxIcon.None);
                    this.Close();
                }
                else
                {
                    msg_error += "Error adding.\nPlease check if the ID does not exist yet.\n";
                }

            }
            return msg_error;
        }