예제 #1
0
        private async void btn_save_Click(object sender, EventArgs e)
        {
            bool        isAppointment = false;
            Tasks       tasks         = new Tasks();
            Appointment appointment   = new Appointment();

            PictureBox pictureBox = commonUtil.addLoaderImage(this.btn_save.Location.X + 205, this.btn_save.Location.Y + 2);

            this.Controls.Add(pictureBox);
            this.btn_save.Enabled = false;
            bool task = await Task.Run(() => this.DoValidations());

            UserEvent userEvent = this.GenerateUserEvent();

            if (task)
            {
                bool contact = false;
                contact = await Task.Run(() => eventHelper.UpdateEvent(userEvent));

                if (contact)
                {
                    this.Controls.Remove(pictureBox);
                    this.Close();
                }
                else
                {
                    Banner banner = new Banner();
                    banner = uiMessage.AddBanner("Unable to add Event. Please try again later", "error");
                    this.Controls.Add(banner);
                    banner.BringToFront();
                    this.Controls.Remove(pictureBox);
                    this.btn_save.Enabled = true;
                }
            }
            else
            {
                this.Controls.Remove(pictureBox);
                this.btn_save.Enabled = true;
            }
        }
        private async void btn_save_Click(object sender, EventArgs e)
        {
            PictureBox pictureBox = commonUtil.addLoaderImage(this.btn_save.Location.X + 205, this.btn_save.Location.Y + 2);

            this.Controls.Add(pictureBox);
            this.btn_save.Enabled = false;
            this.GenerateContactObject();
            bool task = await Task.Run(() => this.DoValidations());

            if (task)
            {
                bool update = await Task.Run(() => contactHelper.UpdateContacts(contact));

                if (update)
                {
                    this.Controls.Remove(pictureBox);
                    this.Close();
                }
                else
                {
                    Banner banner = new Banner();
                    banner = uiMessage.AddBanner("Unable to add contact. Please try again later", "error");
                    this.Controls.Add(banner);
                    banner.BringToFront();
                    this.Controls.Remove(pictureBox);
                    this.btn_save.Enabled = true;
                }
            }
            else
            {
                this.Controls.Remove(pictureBox);
                this.btn_save.Enabled = true;
            }
            this.Controls.Remove(pictureBox);
            this.btn_save.Enabled = true;
        }