Example #1
0
        public void getAllRecordsBySystemUserId()
        {
            contactService  contactService = new contactService();
            List <contacts> dataList       = contactService.getAllRecordsBySystemUserId();

            if (dataList != null || dataList.Count > 0)
            {
                grdContacts.DataSource = dataList;

                grdContacts.Columns["systemUserId"].Visible = false;
                grdContacts.Columns["id"].Visible           = false;
                grdContacts.Columns["createDate"].Visible   = false;


                grdContacts.Columns["firstName"].HeaderText = "İsim";
                grdContacts.Columns["firstName"].Width      = 100;

                grdContacts.Columns["lastName"].HeaderText = "Soyisim";
                grdContacts.Columns["lastName"].Width      = 100;

                grdContacts.Columns["company"].HeaderText = "Firma";
                grdContacts.Columns["company"].Width      = 100;

                grdContacts.Columns["title"].HeaderText = "Ünvan";
                grdContacts.Columns["title"].Width      = 100;

                grdContacts.Columns["personelNote"].HeaderText = "Not";
                grdContacts.Columns["personelNote"].Width      = 310;
            }
        }
        private void btnNewContact_Click(object sender, EventArgs e)
        {
            contactService contactService = new contactService();
            int            resultInt      = contactService.addNewContact(txtFirstName.Text, txtLastName.Text, txtCompany.Text, txtTitle.Text, txtNote.Text);

            if (resultInt > 0)
            {
                MessageBox.Show("Kayıt ekleme işlemi başarılı", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);

                DialogResult result = MessageBox.Show("Kayıt detaylarını şimdi girmek ister misiniz?", "Bilgilendirme", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (result == DialogResult.Yes)
                {
                    // Eğer tamam ise o zaman bizim burada güncelleme formun açmamız gerekli... Burada unuttuğumuz bir şey var ...
                }
                else
                {
                    mainForm OpenForm = (mainForm)Application.OpenForms["mainForm"];
                    OpenForm.getAllRecordsBySystemUserId();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Kayıt eklenemedi, Form içerisinde bulunan alanlardan isim ve soyisim değerlerinin dolu olduğuna emin olunuz", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        void getContactById(Guid recordId)
        {
            contactService contactService = new contactService();

            data = contactService.getRecordByContactId(recordId);
            txtFirstname.Text = data.firstName;
            txtLastname.Text  = data.lastName;
            txtCompany.Text   = data.company;
            txtTitle.Text     = data.title;
        }
        void getContactDetail(Guid contactID)
        {
            contactService contactService = new contactService();

            data = contactService.getRecordByContactId(contactID);
            txtFirstname.Text = data.firstName;
            txtLastname.Text  = data.lastName;
            txtTitle.Text     = data.title;
            txtCompany.Text   = data.company;
        }
        void getContactData(Guid contactId)
        {
            contactService contactService = new contactService();

            data = contactService.getRecordByContactId(contactId);
            txtFirstName.Text = data.firstName;
            txtLastName.Text  = data.lastName;
            txtCompany.Text   = data.company;
            txtTitle.Text     = data.title;
            txtNote.Text      = data.personelNote;
        }
        private void btnRecordDelete_Click(object sender, EventArgs e)
        {
            contactService contactService = new contactService();
            int            resultInt      = contactService.deleteRecordByID(data.id);

            if (resultInt > 0)
            {
                mainForm mainformValue = (mainForm)Application.OpenForms["mainForm"];
                mainformValue.getAllRecordsBySystemUserId();
                this.Close();
            }
            else
            {
                MessageBox.Show("Silme işlemi başarısız", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void btnUpdateContact_Click(object sender, EventArgs e)
        {
            contactService contactService = new contactService();
            int            resultInt      = contactService.updateContact(data.id, txtFirstName.Text, txtLastName.Text, txtCompany.Text, txtTitle.Text, txtNote.Text);

            if (resultInt > 0)
            {
                MessageBox.Show("Kayıt güncelleme işlemi başarılı", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                mainForm formMain = (mainForm)Application.OpenForms["mainForm"];
                formMain.getAllRecordsBySystemUserId();

                DialogResult res = MessageBox.Show("İletişim bilgisi girmeye veya kaydı incelemeye devam etmek istiyor musunuz ?", "Bilgilendirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (res == DialogResult.No)
                {
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Kayıt güncelleme işlemi başarısız", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        void getContact(Guid contactId)
        {
            contactService contactService = new contactService();

            data = contactService.getRecordByContactId(contactId);
        }