コード例 #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 signcollection GetSignCollection(String collectionId)
 {
     using (database content = new database())
     {
         signcollection collection = content.signcollection.Where(i => i.collectionId == collectionId).FirstOrDefault();
         return(collection);
     }
 }
コード例 #3
0
 public void NewCollection(signcollection clt)
 {
     using (database content = new database())
     {
         content.signcollection.Add(clt);
         content.SaveChanges();
     }
 }
コード例 #4
0
        private void FrmCollectionDetails_VisibleChanged(object sender, EventArgs e)
        {
            // if change for invisible to visible
            if (!isVisible && this.Visible && !editMode)
            {
                mySignCollection = db.GetSignCollection(mySignCollection.collectionId);
                mySigns          = db.GetSigns(mySignCollection.collectionId);
                myOrganisation   = db.GetOrganisation(mySignCollection.organisationId);
                textBox1.Text    = "";
                SetForm();
            }

            isVisible = this.Visible;
        }
コード例 #5
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 void FrmOrganisationDetails_VisibleChanged(object sender, EventArgs e)
        {
            // if change for invisible to visible
            if (!isVisible && this.Visible)
            {
                myOrganisation      = db.GetOrganisation(myOrganisation.id);
                signcollectionsList = db.GetCollectionList(myOrganisation.id);

                txt_organisation.Text = myOrganisation.name;
                txt_orgId.Text        = myOrganisation.id.ToString();
                txt_orgEmail.Text     = myOrganisation.email;
                txt_orgTel.Text       = myOrganisation.tel;
                txt_address.Text      = myOrganisation.address;

                List <signcollection> temp = signcollectionsList;
                foreach (DataGridViewRow row in dgv_collection.Rows)
                {
                    signcollection sc = temp.FirstOrDefault(i => i.collectionId == row.Cells[0].Value.ToString());
                    if (sc == null)
                    {
                        dgv_collection.Rows.Remove(row);
                        continue;
                    }
                    int signNum    = db.GetNoOfSign(sc.collectionId);
                    int datasetNum = db.GetNoOfDataset(sc.collectionId);

                    row.Cells[1].Value = sc.name;
                    row.Cells[2].Value = signNum;
                    row.Cells[3].Value = datasetNum;
                    row.Cells[4].Value = sc.contactPerson;
                    temp.Remove(sc);
                }

                if (temp.Count > 0)
                {
                    foreach (signcollection sc in temp)
                    {
                        organisation o          = db.GetOrganisation(sc.organisationId);
                        int          signNum    = db.GetNoOfSign(sc.collectionId);
                        int          datasetNum = db.GetNoOfDataset(sc.collectionId);

                        dgv_collection.Rows.Add(sc.collectionId, sc.name, signNum, datasetNum, sc.contactPerson);
                    }
                }
            }

            isVisible = this.Visible;
        }
コード例 #7
0
 public void UpdateSignCollection(signcollection sc)
 {
     using (database content = new database())
     {
         signcollection ori = content.signcollection.FirstOrDefault(i => i.collectionId == sc.collectionId);
         if (ori != null)
         {
             ori.password           = sc.password;
             ori.name               = sc.name;
             ori.contactPerson      = sc.contactPerson;
             ori.contactPersonEmail = sc.contactPersonEmail;
             ori.contactPersonTel   = sc.contactPersonTel;
             ori.contactPersonTitle = sc.contactPersonTitle;
             content.SaveChanges();
         }
     }
 }
コード例 #8
0
        private void FrmCollectionList_VisibleChanged(object sender, EventArgs e)
        {
            // if change for invisible to visible
            if (!isVisible && this.Visible)
            {
                signcollectionsList = db.GetCollectionList();
                List <signcollection> temp = signcollectionsList;
                foreach (DataGridViewRow row in dgv_collection.Rows)
                {
                    signcollection sc = temp.FirstOrDefault(i => i.collectionId == row.Cells[0].Value.ToString());
                    if (sc == null)
                    {
                        dgv_collection.Rows.Remove(row);
                        continue;
                    }
                    organisation o          = db.GetOrganisation(sc.organisationId);
                    int          signNum    = db.GetNoOfSign(sc.collectionId);
                    int          datasetNum = db.GetNoOfDataset(sc.collectionId);

                    row.Cells[1].Value = sc.name;
                    row.Cells[2].Value = o.name;
                    row.Cells[3].Value = signNum;
                    row.Cells[4].Value = datasetNum;
                    temp.Remove(sc);
                }

                if (temp.Count > 0)
                {
                    foreach (signcollection sc in temp)
                    {
                        organisation o          = db.GetOrganisation(sc.organisationId);
                        int          signNum    = db.GetNoOfSign(sc.collectionId);
                        int          datasetNum = db.GetNoOfDataset(sc.collectionId);

                        dgv_collection.Rows.Add(sc.collectionId, sc.name, o.name, signNum, datasetNum);
                    }
                }
            }

            isVisible = this.Visible;
        }
コード例 #9
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                return;
            }

            // New sign collection
            signcollection sc = new signcollection
            {
                collectionId       = txt_collectionId.Text,
                password           = txt_password.Text,
                name               = txt_collectionName.Text,
                contactPerson      = txt_contactPerson.Text,
                contactPersonEmail = txt_contactPersonEmail.Text,
                contactPersonTel   = txt_contactPersonTel.Text,
                contactPersonTitle = txt_contactPersonTitle.Text,
                organisationId     = organisations.ElementAt(cbBox_organisation.SelectedIndex).id
            };

            // New organisation
            if (ckBox_newOrg.Checked)
            {
                organisation org = new organisation
                {
                    name    = txt_organisation.Text,
                    email   = txt_orgEmail.Text,
                    address = txt_address.Text,
                    tel     = txt_orgTel.Text
                };
                sc.organisationId = db.NewOrganisation(org);
            }

            db.NewCollection(sc);

            // Change page
            FrmCollectionDetails frm = new FrmCollectionDetails(parent, sc.collectionId);

            parent.ReplaceWith(frm);
        }
コード例 #10
0
        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);
        }