Пример #1
0
        private void UpdateInfo()
        {
            signcollection sc = new signcollection
            {
                collectionId       = mySignCollection.collectionId,
                password           = txt_password.Text,
                name               = txt_collectionName.Text,
                contactPerson      = txt_contactPerson.Text,
                contactPersonEmail = txt_contactPersonEmail.Text,
                contactPersonTel   = txt_contactPersonTel.Text,
                contactPersonTitle = txt_contactPersonTitle.Text
            };

            db.UpdateSignCollection(sc);

            organisation org = new organisation
            {
                id      = myOrganisation.id,
                name    = txt_organisation.Text,
                email   = txt_orgEmail.Text,
                address = txt_address.Text,
                tel     = txt_orgTel.Text
            };

            db.UpdateOrganisation(org);

            mySignCollection = db.GetSignCollection(mySignCollection.collectionId);
            mySigns          = db.GetSigns(mySignCollection.collectionId);
            myOrganisation   = db.GetOrganisation(mySignCollection.organisationId);
            this.SetForm();
        }
Пример #2
0
        public FrmCollectionDetails(FrmHomepage parent, String collectionId)
        {
            InitializeComponent();

            this.parent = parent;
            tableLayoutPanel2.SetColumnSpan(txt_address, 3);

            db = new SignChatDB();
            mySignCollection = db.GetSignCollection(collectionId);
            mySigns          = db.GetSigns(collectionId);
            myOrganisation   = db.GetOrganisation(mySignCollection.organisationId);

            SetForm();
            editMode = false;
        }
        private bool ValidateForm()
        {
            bool           validate         = true;
            List <Control> requiredControls = new List <Control>();

            requiredControls.Add(txt_collectionId);
            requiredControls.Add(txt_collectionName);
            requiredControls.Add(txt_password);
            requiredControls.Add(txt_orgEmail);
            requiredControls.Add(txt_orgTel);
            requiredControls.Add(txt_address);
            requiredControls.Add(txt_contactPerson);
            foreach (Control c in requiredControls)
            {
                if (c.Text == "")
                {
                    errorProvider.SetError(c, "Required.");
                    errorProvider.SetIconPadding(c, -20);
                    validate = false;
                }
                else
                {
                    errorProvider.SetError(c, "");
                }
            }
            if (txt_collectionId.Text != "")
            {
                signcollection sc = db.GetSignCollection(txt_collectionId.Text);
                if (sc != null)
                {
                    errorProvider.SetError(txt_collectionId, "Collection ID is in used.");
                    errorProvider.SetIconPadding(txt_collectionId, -20);
                    validate = false;
                }
                else
                {
                    errorProvider.SetError(txt_collectionId, "");
                }
            }

            if (ckBox_newOrg.Checked && txt_organisation.Text == "")
            {
                errorProvider.SetError(txt_organisation, "Required.");
                errorProvider.SetIconPadding(txt_organisation, -20);
                validate = false;
            }
            else if (!ckBox_newOrg.Checked && cbBox_organisation.SelectedIndex < 0)
            {
                errorProvider.SetError(cbBox_organisation, "Required.");
                errorProvider.SetIconPadding(cbBox_organisation, -20);
                validate = false;
            }
            else
            {
                errorProvider.SetError(txt_organisation, "");
                errorProvider.SetError(cbBox_organisation, "");
            }

            if (txt_contactPersonEmail.Text == "" && txt_contactPersonTel.Text == "")
            {
                errorProvider.SetError(txt_contactPersonEmail, "Please enter at least one of the contact method.");
                errorProvider.SetIconPadding(txt_contactPersonEmail, -20);
                errorProvider.SetError(txt_contactPersonTel, "Please enter at least one of the contact method.");
                errorProvider.SetIconPadding(txt_contactPersonTel, -20);
                validate = false;
            }
            else
            {
                errorProvider.SetError(txt_contactPersonEmail, "");
                errorProvider.SetError(txt_contactPersonTel, "");
            }
            return(validate);
        }