Example #1
0
 public ActionResult ContactPerson_InfoPost()
 {
     if (ModelState.IsValid)
     {
         Contact_Person cp = new Contact_Person();
         UpdateModel(cp);
         BusinessLayer businesslayer = new BusinessLayer();
         businesslayer.AddContact_Person_Info(cp);
     }
     return(View());
 }
Example #2
0
        private void userKeyDown(object sender, KeyEventArgs e)
        {
            if (sender.Equals(txtSearch))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    try
                    {
                        try
                        {
                            var bs = new BindingSource();
                            bs.DataSource             = MemberGridView.DataSource;
                            bs.Filter                 = "name LIKE '%" + txtSearch.Text + "%'";
                            MemberGridView.DataSource = bs;
                        }
                        catch (Exception er)
                        {
                            Console.WriteLine(er.Message);
                            try
                            {
                                var bs = new BindingSource();
                                bs.DataSource             = MemberGridView.DataSource;
                                bs.Filter                 = "nomor_induk_anggota LIKE '____" + txtSearch.Text + "%'";
                                MemberGridView.DataSource = bs;
                            }
                            catch (Exception es)
                            {
                                Console.WriteLine(es.Message);
                                try
                                {
                                    var bs = new BindingSource();
                                    bs.DataSource             = MemberGridView.DataSource;
                                    bs.Filter                 = "alamat_asli LIKE '%" + txtSearch.Text + "%'";
                                    MemberGridView.DataSource = bs;
                                }
                                catch (Exception et)
                                {
                                    Console.WriteLine(et.Message);
                                    try
                                    {
                                        var bs = new BindingSource();
                                        bs.DataSource             = MemberGridView.DataSource;
                                        bs.Filter                 = "alamat_kos LIKE '%" + txtSearch.Text + "%'";
                                        MemberGridView.DataSource = bs;
                                    }
                                    catch (Exception eu)
                                    {
                                        Console.WriteLine(eu.Message); try
                                        {
                                            var bs = new BindingSource();
                                            bs.DataSource             = MemberGridView.DataSource;
                                            bs.Filter                 = "perguruan_tinggi LIKE '%" + txtSearch.Text + "%'";
                                            MemberGridView.DataSource = bs;
                                        }
                                        catch (Exception ev)
                                        {
                                            Console.WriteLine(ev.Message); try
                                            {
                                                var bs = new BindingSource();
                                                bs.DataSource             = MemberGridView.DataSource;
                                                bs.Filter                 = "jurusan LIKE '%" + txtSearch.Text + "%'";
                                                MemberGridView.DataSource = bs;
                                            }
                                            catch (Exception ew)
                                            {
                                                Console.WriteLine(ew.Message);
                                                var bs = new BindingSource();
                                                bs.DataSource             = MemberGridView.DataSource;
                                                bs.Filter                 = "phone_number LIKE '%" + txtSearch.Text + "%'";
                                                MemberGridView.DataSource = bs;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtSearch.Text = "";
                }
            }
            else if (e.KeyCode == Keys.Delete)
            {
                if (_restriction == "admin" || _restriction == "sekertaris")
                {
                    if (_code == "")
                    {
                        MessageBox.Show("Code Not Selected!", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }
                    else
                    {
                        File.Delete(Application.StartupPath + "\\Picture\\" + _listItem[0].NIA.ToString() + ".jpg");
                        Console.WriteLine("code = " + _code);
                        var code    = _code;
                        var SosCode = _Soscode;
                        var PtCode  = _Ptcode;
                        var msg     = MessageBox.Show("Are you Sure", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (msg == DialogResult.Yes)
                        {
                            Console.WriteLine("A_id = " + code + ", S_id = " + SosCode + ", P_id = " + PtCode);

                            var data   = new Anggota_KMB(code);
                            var cp     = new Contact_Person(code, SosCode);
                            var sosmed = new Sosial_Media(SosCode);
                            if (cp.Remove())
                            {
                                if (sosmed.Remove())
                                {
                                    if (data.Remove())
                                    {
                                        MessageBox.Show("Berhasil Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        resetcomponent();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Anggota Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("SosMed Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("CP Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        private void btnClicked(object sender, EventArgs e)
        {
            if (sender.Equals(btnInput))
            {
                new loginfrm().Show();
                this.Hide();
            }
            else if (sender.Equals(btnSearch))
            {
                try
                {
                    try
                    {
                        var bs = new BindingSource();
                        bs.DataSource             = MemberGridView.DataSource;
                        bs.Filter                 = "name LIKE '%" + txtSearch.Text + "%'";
                        MemberGridView.DataSource = bs;
                    }
                    catch (Exception er)
                    {
                        Console.WriteLine(er.Message);
                        try
                        {
                            var bs = new BindingSource();
                            bs.DataSource             = MemberGridView.DataSource;
                            bs.Filter                 = "nomor_induk_anggota LIKE '____" + txtSearch.Text + "%'";
                            MemberGridView.DataSource = bs;
                        }
                        catch (Exception es)
                        {
                            Console.WriteLine(es.Message);
                            try
                            {
                                var bs = new BindingSource();
                                bs.DataSource             = MemberGridView.DataSource;
                                bs.Filter                 = "alamat_asli LIKE '%" + txtSearch.Text + "%'";
                                MemberGridView.DataSource = bs;
                            }
                            catch (Exception et)
                            {
                                Console.WriteLine(et.Message);
                                try
                                {
                                    var bs = new BindingSource();
                                    bs.DataSource             = MemberGridView.DataSource;
                                    bs.Filter                 = "alamat_kos LIKE '%" + txtSearch.Text + "%'";
                                    MemberGridView.DataSource = bs;
                                }
                                catch (Exception eu)
                                {
                                    Console.WriteLine(eu.Message); try
                                    {
                                        var bs = new BindingSource();
                                        bs.DataSource             = MemberGridView.DataSource;
                                        bs.Filter                 = "perguruan_tinggi LIKE '%" + txtSearch.Text + "%'";
                                        MemberGridView.DataSource = bs;
                                    }
                                    catch (Exception ev)
                                    {
                                        Console.WriteLine(ev.Message); try
                                        {
                                            var bs = new BindingSource();
                                            bs.DataSource             = MemberGridView.DataSource;
                                            bs.Filter                 = "jurusan LIKE '%" + txtSearch.Text + "%'";
                                            MemberGridView.DataSource = bs;
                                        }
                                        catch (Exception ew)
                                        {
                                            Console.WriteLine(ew.Message);
                                            var bs = new BindingSource();
                                            bs.DataSource             = MemberGridView.DataSource;
                                            bs.Filter                 = "phone_number LIKE '%" + txtSearch.Text + "%'";
                                            MemberGridView.DataSource = bs;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }
            }
            else if (sender.Equals(btnAddMember))
            {
                new DataMember(_restriction).Show();
            }
            else if (sender.Equals(btnAddCollege))
            {
                new DataCollege(_restriction).Show();
            }
            else if (sender.Equals(btnDelete))
            {
                Console.WriteLine("code = " + _code);

                if (_code == "")
                {
                    MessageBox.Show("Code Not Selected!", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }
                else
                {
                    File.Delete(Application.StartupPath + "\\Picture\\" + _listItem[0].NIA.ToString() + ".jpg");
                    Console.WriteLine("code = " + _code);
                    var code    = _code;
                    var SosCode = _Soscode;
                    var PtCode  = _Ptcode;
                    var msg     = MessageBox.Show("Are you Sure", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (msg == DialogResult.Yes)
                    {
                        Console.WriteLine("A_id = " + code + ", S_id = " + SosCode + ", P_id = " + PtCode);

                        var data   = new Anggota_KMB(code);
                        var cp     = new Contact_Person(code, SosCode);
                        var sosmed = new Sosial_Media(SosCode);
                        if (cp.Remove())
                        {
                            if (sosmed.Remove())
                            {
                                if (data.Remove())
                                {
                                    MessageBox.Show("Berhasil Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    resetcomponent();
                                }
                                else
                                {
                                    MessageBox.Show("Anggota Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("SosMed Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("CP Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            else if (sender.Equals(btnReset))
            {
                ShowData();
                resetcomponent();
            }
            else if (sender.Equals(btnEdit))
            {
                if (_code == "")
                {
                    MessageBox.Show("No Code Selected", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    new DataMember(_restriction, _code, _Soscode, _Ptcode, _listItem).Show();
                }
            }
            else if (sender.Equals(btnExit))
            {
                var msg = MessageBox.Show("Are you Sure?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (msg == DialogResult.Yes)
                {
                    this.Dispose();
                }
            }
            else if (sender.Equals(btnExport))
            {
                //new KmbMember.View.IOReport("export", MemberGridView).Show();
                ExportToExcelWithFormatting(MemberGridView);
            }
        }
Example #4
0
        private void userKeyDown(object sender, KeyEventArgs e)
        {
            if (sender.Equals(txtName))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    cmbGender.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    this.Close();
                }
            }
            else if (sender.Equals(cmbGender))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtPlaceBorn.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtName.Focus();
                    txtName.Text = "";
                }
            }
            else if (sender.Equals(txtPlaceBorn))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtDayBorn.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    cmbGender.Focus();
                }
            }
            else if (sender.Equals(txtDayBorn))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtMonthBorn.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtPlaceBorn.Focus();
                    txtPlaceBorn.Text = "";
                }
            }
            else if (sender.Equals(txtMonthBorn))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtYearBorn.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtDayBorn.Focus();
                    txtDayBorn.Text = "";
                }
            }
            else if (sender.Equals(txtYearBorn))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtRealAddress.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtMonthBorn.Focus();
                    txtMonthBorn.Text = "";
                }
            }
            else if (sender.Equals(txtRealAddress))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtBoardingAddress.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtYearBorn.Focus();
                    txtYearBorn.Text = "";
                }
            }
            else if (sender.Equals(txtBoardingAddress))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    cmbNameCollege.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtRealAddress.Focus();
                    txtRealAddress.Text = "";
                }
            }
            else if (sender.Equals(cmbNameCollege))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    try
                    {
                        facultyLabel.Visible      = true;
                        cmbFacultyCollege.Visible = true;
                        FillCboFacultyCollege();
                        Console.WriteLine("Kampus: " + cmbNameCollege.SelectedValue.ToString());
                        cmbFacultyCollege.Focus();
                    }
                    catch
                    {
                        MessageBox.Show("College Name is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtBoardingAddress.Focus();
                    txtBoardingAddress.Text = "";
                }
            }
            else if (sender.Equals(cmbFacultyCollege))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    try
                    {
                        majorLabel.Visible      = true;
                        cmbMajorCollege.Visible = true;
                        FillCboMajorCollege();
                        Console.WriteLine("fakultas: " + cmbFacultyCollege.SelectedValue.ToString());
                        cmbMajorCollege.Focus();
                    }
                    catch
                    {
                        MessageBox.Show("Faculty is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    facultyLabel.Visible      = false;
                    cmbFacultyCollege.Visible = false;
                    cmbNameCollege.Focus();
                }
            }
            else if (sender.Equals(cmbMajorCollege))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    try
                    {
                        yearLabel.Visible      = true;
                        txtTahunAjaran.Visible = true;
                        Console.WriteLine("jurusan: " + cmbMajorCollege.SelectedValue.ToString());
                        txtTahunAjaran.Focus();
                    }
                    catch
                    {
                        MessageBox.Show("Major is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    majorLabel.Visible      = false;
                    cmbMajorCollege.Visible = false;
                    cmbFacultyCollege.Focus();
                }
            }
            else if (sender.Equals(txtTahunAjaran))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtPhone.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    yearLabel.Visible      = false;
                    txtTahunAjaran.Visible = false;
                    cmbMajorCollege.Focus();
                }
            }
            else if (sender.Equals(txtPhone))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtWA.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtTahunAjaran.Focus();
                    txtTahunAjaran.Text = "";
                }
            }
            else if (sender.Equals(txtWA))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtLine.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtPhone.Focus();
                    txtPhone.Text = "";
                }
            }
            else if (sender.Equals(txtLine))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtIG.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtWA.Focus();
                    txtWA.Text = "";
                }
            }
            else if (sender.Equals(txtIG))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtFB.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtLine.Focus();
                    txtLine.Text = "";
                }
            }
            else if (sender.Equals(txtFB))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    txtTwit.Focus();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtIG.Focus();
                    txtIG.Text = "";
                }
            }
            else if (sender.Equals(txtTwit))
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (isValidated())
                    {
                        if (txtNIA.Visible == false)
                        {
                            Console.WriteLine("copyfile: " + Application.StartupPath + "\\Picture\\" + txtNIA.Text + ".jpg");
                            //SOSMED
                            var dataSosMed = new Sosial_Media();
                            var sos_id     = dataSosMed.GenerateCode();
                            dataSosMed = new Sosial_Media(sos_id, txtPhone.Text, txtIG.Text, txtLine.Text, txtWA.Text, txtFB.Text, txtTwit.Text);
                            Console.WriteLine("sos_id: " + sos_id);
                            if (dataSosMed.AttachData())
                            {
                                //PT
                                var dataCollege = new Perguruan_Tinggi();
                                dataCollege.Nama     = cmbNameCollege.SelectedValue.ToString();
                                dataCollege.Fakultas = cmbFacultyCollege.SelectedValue.ToString();
                                dataCollege.Jurusan  = cmbMajorCollege.SelectedValue.ToString();
                                var pt_id = dataCollege.GetCode();
                                Console.WriteLine("Kampus: " + cmbNameCollege.SelectedItem.ToString() + ", Fakultas: " + cmbFacultyCollege.SelectedValue.ToString() /*pake ini*/ + ", Jurusan: " + cmbMajorCollege.SelectedValue.ToString() + ", pt_id: " + pt_id);

                                if (pt_id != "")
                                {
                                    //DataMember
                                    var dataMember = new Anggota_KMB();
                                    var year       = txtTahunAjaran.Text.Substring(2, 2);
                                    var A_id       = dataMember.GenerateCode();
                                    var NIA        = "KMB." + txtTahunAjaran.Text.Substring(2, 2) + "." + dataMember.GenerateNIA(year);
                                    var DateBorn   = txtDayBorn.Text + "/" + txtMonthBorn.Text + "/" + txtYearBorn.Text;
                                    dataMember = new Anggota_KMB(A_id, NIA, txtName.Text, cmbGender.SelectedValue.ToString(), txtPlaceBorn.Text, DateBorn, txtRealAddress.Text, txtBoardingAddress.Text, pt_id);

                                    if (dataMember.AttachData())
                                    {
                                        //CP
                                        try
                                        {
                                            File.Copy(_pathpic, Application.StartupPath + "\\Picture\\" + NIA + ".jpg", true);
                                        }
                                        catch
                                        {
                                            MessageBox.Show("Picture is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                        var dataCp = new Contact_Person(A_id, sos_id);
                                        if (dataCp.AttachData())
                                        {
                                            MessageBox.Show("Berhasil Ditambahkan", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            resetcomponent();
                                        }
                                        else
                                        {
                                            MessageBox.Show("Gagal Ditambahkan", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Gagal Ditambahkan_Member", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }


                                    Console.WriteLine("Kampus: " + cmbNameCollege.SelectedItem.ToString() + ", Fakultas: " + cmbFacultyCollege.SelectedValue.ToString() /*pake ini*/ + ", Jurusan: " + cmbMajorCollege.SelectedValue.ToString() + ", pt_id: " + pt_id);
                                }
                                else
                                {
                                    MessageBox.Show("Gagal Ditambahkan_PT", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Gagal Ditambahkan_SosMed", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            try
                            {
                                File.Copy(_pathpic, Application.StartupPath + "\\Picture\\" + txtNIA.Text + ".jpg", true);
                            }
                            catch
                            {
                                MessageBox.Show("Picture is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            Console.WriteLine("copyfile: " + Application.StartupPath + "\\Picture\\" + txtNIA.Text + ".jpg");
                            var a_code = a_Code;
                            var s_code = s_Code;
                            var p_code = p_Code;
                            try
                            {
                                var sosMed = new Sosial_Media(s_code, txtPhone.Text, txtIG.Text, txtLine.Text, txtWA.Text, txtFB.Text, txtTwit.Text);

                                if (sosMed.Update())
                                {
                                    var dataCollege = new Perguruan_Tinggi(null, cmbNameCollege.SelectedValue.ToString(), cmbFacultyCollege.SelectedValue.ToString(), cmbMajorCollege.SelectedValue.ToString());
                                    var pt_id       = dataCollege.GetCode();
                                    if (pt_id != "")
                                    {
                                        var dataMember = new Anggota_KMB();
                                        var DateBorn   = txtDayBorn.Text + "/" + txtMonthBorn.Text + "/" + txtYearBorn.Text;
                                        dataMember = new Anggota_KMB(a_code, txtNIA.Text, txtName.Text, cmbGender.SelectedValue.ToString(), txtPlaceBorn.Text, DateBorn, txtRealAddress.Text, txtBoardingAddress.Text, cmbMajorCollege.SelectedValue.ToString());
                                        if (dataMember.Update())
                                        {
                                            MessageBox.Show("Berhasil Diperbarui : " + cmbMajorCollege.SelectedValue.ToString(), "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            this.Close();
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Gagal Diperbarui", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        Console.WriteLine("Error - P_T: " + pt_id);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Gagal Diperbarui", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    Console.WriteLine("Error - SosMed");
                                }
                            }
                            catch (Exception er)
                            {
                                MessageBox.Show("Gagal Diperbarui", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                Console.WriteLine("Error - sosmed: " + er.Message);
                            }
                            //
                        }
                    }
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    txtFB.Focus();
                    txtFB.Text = "";
                }
            }
        }
Example #5
0
        private void btnClicked(object sender, EventArgs e)
        {
            if (sender.Equals(btnCancel))
            {
                this.Close();
            }
            else if (sender.Equals(btnSubmit))
            {
                if (isValidated())
                {
                    if (txtNIA.Visible == false)
                    {
                        Console.WriteLine("copyfile: " + Application.StartupPath + "\\Picture\\" + txtNIA.Text + ".jpg");
                        //SOSMED
                        var dataSosMed = new Sosial_Media();
                        var sos_id     = dataSosMed.GenerateCode();
                        dataSosMed = new Sosial_Media(sos_id, txtPhone.Text, txtIG.Text, txtLine.Text, txtWA.Text, txtFB.Text, txtTwit.Text);
                        Console.WriteLine("sos_id: " + sos_id);
                        if (dataSosMed.AttachData())
                        {
                            //PT
                            var dataCollege = new Perguruan_Tinggi();
                            dataCollege.Nama     = cmbNameCollege.SelectedValue.ToString();
                            dataCollege.Fakultas = cmbFacultyCollege.SelectedValue.ToString();
                            dataCollege.Jurusan  = cmbMajorCollege.SelectedValue.ToString();
                            var pt_id = dataCollege.GetCode();
                            Console.WriteLine("Kampus: " + cmbNameCollege.SelectedItem.ToString() + ", Fakultas: " + cmbFacultyCollege.SelectedValue.ToString() /*pake ini*/ + ", Jurusan: " + cmbMajorCollege.SelectedValue.ToString() + ", pt_id: " + pt_id);

                            if (pt_id != "")
                            {
                                //DataMember
                                var dataMember = new Anggota_KMB();
                                var year       = txtTahunAjaran.Text.Substring(2, 2);
                                var A_id       = dataMember.GenerateCode();
                                var NIA        = "KMB." + txtTahunAjaran.Text.Substring(2, 2) + "." + dataMember.GenerateNIA(year);
                                var DateBorn   = txtDayBorn.Text + "/" + txtMonthBorn.Text + "/" + txtYearBorn.Text;
                                dataMember = new Anggota_KMB(A_id, NIA, txtName.Text, cmbGender.SelectedValue.ToString(), txtPlaceBorn.Text, DateBorn, txtRealAddress.Text, txtBoardingAddress.Text, pt_id);

                                if (dataMember.AttachData())
                                {
                                    //CP
                                    var dataCp = new Contact_Person(A_id, sos_id);
                                    try
                                    {
                                        File.Copy(_pathpic, Application.StartupPath + "\\Picture\\" + NIA + ".jpg", true);
                                    }
                                    catch
                                    {
                                        MessageBox.Show("Picture is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    }
                                    if (dataCp.AttachData())
                                    {
                                        MessageBox.Show("Berhasil Ditambahkan", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        resetcomponent();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Gagal Ditambahkan", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Gagal Ditambahkan_Member", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }


                                Console.WriteLine("Kampus: " + cmbNameCollege.SelectedItem.ToString() + ", Fakultas: " + cmbFacultyCollege.SelectedValue.ToString() /*pake ini*/ + ", Jurusan: " + cmbMajorCollege.SelectedValue.ToString() + ", pt_id: " + pt_id);
                            }
                            else
                            {
                                MessageBox.Show("Gagal Ditambahkan_PT", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Gagal Ditambahkan_SosMed", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        var a_code = a_Code;
                        var s_code = s_Code;
                        var p_code = p_Code;
                        Console.WriteLine("Error - SosMed " + s_code);
                        try
                        {
                            File.Copy(_pathpic, Application.StartupPath + "\\Picture\\" + txtNIA.Text + ".jpg", true);
                        }
                        catch
                        {
                            MessageBox.Show("Picture is Empty", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        Console.WriteLine("copyfile: " + Application.StartupPath + "\\Picture\\" + txtNIA.Text + ".jpg");
                        try
                        {
                            var sosMed = new Sosial_Media(s_code, txtPhone.Text, txtIG.Text, txtLine.Text, txtWA.Text, txtFB.Text, txtTwit.Text);

                            if (sosMed.Update())
                            {
                                var dataCollege = new Perguruan_Tinggi(null, cmbNameCollege.SelectedValue.ToString(), cmbFacultyCollege.SelectedValue.ToString(), cmbMajorCollege.SelectedValue.ToString());
                                var pt_id       = dataCollege.GetCode();
                                if (pt_id != "")
                                {
                                    var dataMember = new Anggota_KMB();
                                    var DateBorn   = txtDayBorn.Text + "/" + txtMonthBorn.Text + "/" + txtYearBorn.Text;
                                    dataMember = new Anggota_KMB(a_code, txtNIA.Text, txtName.Text, cmbGender.SelectedValue.ToString(), txtPlaceBorn.Text, DateBorn, txtRealAddress.Text, txtBoardingAddress.Text, cmbMajorCollege.SelectedValue.ToString());
                                    if (dataMember.Update())
                                    {
                                        MessageBox.Show("Berhasil Diperbarui : " + cmbMajorCollege.SelectedValue.ToString(), "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        this.Close();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Gagal Diperbarui", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    Console.WriteLine("Error - P_T: " + pt_id);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Gagal Diperbarui", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                Console.WriteLine("Error - SosMed");
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show("Gagal Diperbarui", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Console.WriteLine("Error - sosmed: " + er.Message);
                        }
                        //
                    }
                }
            }
            else if (sender.Equals(btnEdit))
            {
                txtName.ReadOnly      = false;
                txtPlaceBorn.ReadOnly = false;

                txtDayBorn.Text   = txtTanggal.Text.Substring(0, 2);
                txtMonthBorn.Text = txtTanggal.Text.Substring(3, 2);
                txtYearBorn.Text  = txtTanggal.Text.Substring(6, 4);

                txtRealAddress.ReadOnly     = false;
                txtBoardingAddress.ReadOnly = false;
                txtPhone.ReadOnly           = false;
                txtWA.ReadOnly   = false;
                txtLine.ReadOnly = false;
                txtIG.ReadOnly   = false;
                txtFB.ReadOnly   = false;
                txtTwit.ReadOnly = false;

                btnEdit.Visible   = false;
                btnSubmit.Visible = true;
                FillCboGender();
                FillCboNameCollege();
                txtTanggal.Visible        = false;
                facultyLabel.Visible      = false;
                majorLabel.Visible        = false;
                yearLabel.Visible         = false;
                cmbFacultyCollege.Visible = false;
                cmbMajorCollege.Visible   = false;
                txtTahunAjaran.Visible    = false;
            }
            else if (sender.Equals(pic))
            {
                if (_restriction == "admin" || _restriction == "sekertaris")
                {
                    OFDpic.InitialDirectory = "e:\\";
                    OFDpic.Filter           = "Jpg Image Files (*.jpg)|*.jpg|All files (*.*)|*.*";
                    OFDpic.FilterIndex      = 1;
                    OFDpic.RestoreDirectory = true;
                    if (OFDpic.ShowDialog() == DialogResult.OK)
                    {
                        pic.ImageLocation = OFDpic.FileName;
                        _pathpic          = OFDpic.FileName;
                        Console.WriteLine("pathpic: " + pic.ImageLocation);
                        Console.WriteLine("savefilename: " + OFDpic.SafeFileName);
                    }
                }
            }
        }