private void F050102_Load(object sender, EventArgs e)
        {
            cbxJenisJaminan.SelectedIndex = 0;
            firstLoad = true;
            foreach (Control item in this.Controls)
            {
                if (item is TextBox)
                {
                    if (item.Name != "txtNoAnggota")
                    {
                        item.Enabled      = false;
                        item.TextChanged += new EventHandler(item_Text);
                    }
                }
            }
            //comboBox1.SelectedIndex = 0;
            ds_data.Clear();
            DataTable        dataTable;
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("SELECT `NM_COLLECTOR` FROM `collector`", c.connetionString);

            ds.Fill(ds_data, "collector");

            dataTable = ds_data.Tables["collector"];
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                cbxCollector.Items.Add(dataTable.Rows[i].Field <string>(0));
            }
            if (cbxCollector.Items.Count > 0)
            {
                cbxCollector.SelectedIndex = 0;
            }

            Clear();
        }
Exemple #2
0
        private void fn_cari()
        {
            ds_data.Clear();
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("SELECT '' as Chk,`SALES_ID`, `NM_SALES`, `ALAMAT_SALES`, `TELP_SALES`, `IS_ACTIVE` FROM `sales` WHERE NM_SALES LIKE '%" + txtNamaSales.Text + "%' ", c.connetionString);

            ds.Fill(ds_data, "SALES");

            dataTable = ds_data.Tables["SALES"];

            dataGridView1.DataSource            = dataTable;
            dataGridView1.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            dataGridView1.AllowUserToResizeRows = false;

            if (dataGridView1.Columns is null)
            {
                return;
            }
            foreach (Control item in this.Controls)
            {
                if (item is TextBox)
                {
                    if (item.Name != "txtNamaSales")
                    {
                        item.Text    = "";
                        item.Enabled = false;
                    }
                }
            }
            dataGridView1.Columns[0].ReadOnly = true;
            dataGridView1.Columns[0].Width    = 40;
            dataGridView1.Columns[1].ReadOnly = true;
            dataGridView1.Columns[1].Width    = 30;
        }
Exemple #3
0
        private string getID()
        {
            string          query           = "SELECT (MAX(id) + 1) AS ID FROM SALES";
            string          connetionString = null;
            MySqlConnection cnn;
            connection      con = new connection();

            connetionString = con.connetionString;

            cnn = new MySqlConnection(connetionString);
            MySqlCommand cmd = cnn.CreateCommand();

            cnn.Open();
            cmd.CommandText = query;
            MySqlDataReader reader = cmd.ExecuteReader();
            string          id     = "";

            while (reader.Read())
            {
                id = reader[0].ToString();
            }
            string now = DateTime.Now.ToString("yyyyMM");

            cnn.Close();
            if (id == "")
            {
                id = "1";
            }
            return(id);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            connection a = new connection();

            nud.Value = 0;
            //a.fn_IUD is insert Update Delete
            nud.Value = a.fn_IUD("UPDATE PINJAMAN SET JLH_TENOR=99 WHERE id=1"); //Change query update
        }
        private void PopUp_Load(object sender, EventArgs e)
        {
            connection       c  = new connection();
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM NASABAH", c.connetionString);
            DataSet          ds = new DataSet();

            da.Fill(ds, "Nasabah");
            dataGridView1.DataSource = ds.Tables["Nasabah"].DefaultView;
        }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            dataGridView1.Refresh();
            connection       c  = new connection();
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM NASABAH where NAMA_COSTUMER LIKE '" + textBox1.Text + "%' AND NO_ANGGOTA LIKE '" + textBox2.Text + "%'", c.connetionString);
            DataSet          ds = new DataSet();

            da.Fill(ds, "Nasabah");
            dataGridView1.DataSource = ds.Tables["Nasabah"].DefaultView;
        }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            dataGridView1.Refresh();
            connection       c  = new connection();
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM JAMINAN where NO_JAMINAN LIKE '" + txtNoJaminan.Text + "%' AND NO_ANGGOTA LIKE '" + textBox2.Text + "%'", c.connetionString);
            DataSet          ds = new DataSet();

            da.Fill(ds, "JAMINAN");
            dataGridView1.DataSource = ds.Tables["JAMINAN"].DefaultView;
        }
Exemple #8
0
        private void txtNoJaminan_TextChanged(object sender, EventArgs e)
        {
            // timer1.Start();
            ds_data.Clear();
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("SELECT `id`, `NO_JAMINAN`, `JENIS_JAMINAN`, `NO_ANGGOTA`, `TANGGAL_MASUK`, `NAMA_BARANG`, `TIPE_BARANG`, `KET1`, `KET2`, `NAMA_COLLECTOR` FROM `jaminan` WHERE NO_JAMINAN='" + txtNoJaminan.Text + "'", c.connetionString);

            ds.Fill(ds_data, "JAMINAN");
            button1.Enabled = true;
            //KetJaminanKeluar = textBox2.Text;
            //KetJaminanKeluar += "\n===========================================";
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            ds_single1.Clear();
            DataGridViewRow  dr = dataGridView1.Rows[e.RowIndex];
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("" +
                                                       "SELECT  `id`,`NM_NASABAH`, `NM_SALES`, `NM_COLLECTOR`, `JLH_PINJAMAN`, `TIPE_PINJAMAN`,`JLH_TENOR` FROM `pinjaman`" +
                                                       " where id = '" + dr.Cells["id"].Value.ToString() + "' ", c.connetionString);

            ds.Fill(ds_single1, "PINJAMAN");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool   login = false;
            string nip   = "";

            try
            {
                string          connetionString = null;
                MySqlConnection cnn;
                connection      con = new connection();
                connetionString = con.connetionString;
                cnn             = new MySqlConnection(connetionString);
                MySqlCommand cmd = cnn.CreateCommand();
                cnn.Open();
                cmd.CommandText = "SELECT NIP FROM USERS WHERE NIP='" + textBox1.Text + "' AND PASSWORD='******' LIMIT 1";
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    nip   = reader[0].ToString();
                    login = true;
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                DialogResult dg = MessageBox.Show("Database Erorr\n\nDetail : \n" + ex.Message, "Erorr", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                if (dg == DialogResult.Cancel)
                {
                    Application.Exit();
                }
            }
            if (login)
            {
                this.Hide();
                Form1 main = new Form1();
                Form1.NIP = nip;
                main.Show();
            }
            else
            {
                string notif = count == 0 ? "ID dan Password tidak cocok" : "ID dan Password tidak cocok(" + count + ")";
                label3.Text    = notif;
                label3.Visible = true;
                count++;
                return;
            }
        }
        private void fn_cari()
        {
            ds_data.Clear();
            DataTable        dataTable;
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("" +
                                                       "SELECT  `id`,`NM_NASABAH`, `NM_SALES`, `NM_COLLECTOR`, `JLH_PINJAMAN`, `TIPE_PINJAMAN` FROM `pinjaman`" +
                                                       " where NM_NASABAH LIKE '%" + txtNamaAnggota.Text + "%' ", c.connetionString);

            ds.Fill(ds_data, "PINJAMAN");

            dataTable = ds_data.Tables["PINJAMAN"];

            dataGridView1.DataSource            = dataTable;
            dataGridView1.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            dataGridView1.AllowUserToResizeRows = false;
        }
        private void txtNoAnggota_TextChanged(object sender, EventArgs e)
        {
            if (i > 10)
            {
                timer1.Stop();
            }
            ds_data.Clear();
            connection       c  = new connection();
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT `NAMA_COSTUMER`, `NO_KTP`, `NO_KK`, `AGAMA`, `TEMPAT_LAHIR`, `TANGGAL_LAHIR`, `JK`, `ALAMAT_KTP`, `ALAMAT_DOMISILI`, `TELP`, `PEKERJAAN`, `NAMA_IBU_KANDUNG`, `TANGGAL_LAHIR_IBU`, `NAMA_USAHA`, `ALAMAT_UsAHA`, `JENIS_USAHA`, `NAMA_BANK`, `NO_REKENING`, `NAMA_REKENING`, `NAMA_SALES`, `WILAYAH_AREA_TAGIH`, `STATUS_APPL`, `STATUS_MENIKAH`, `NAMA_PASANGAN`, `NO_KTP_PASANGAN`, `ALAMAT_PASANGAN`, `TELP_PASANGAN` FROM NASABAH WHERE NO_ANGGOTA = '" + txtNoAnggota.Text + "' LIMIT 1", c.connetionString);

            da.Fill(ds_data, "NASABAH");

            MySqlDataAdapter ds = new MySqlDataAdapter("SELECT `id`, `NO_JAMINAN`, `JENIS_JAMINAN`, `NO_ANGGOTA`, `TANGGAL_MASUK`, `NAMA_BARANG`, `TIPE_BARANG`, `KET1`, `KET2`, `NAMA_COLLECTOR` FROM `jaminan` WHERE NO_ANGGOTA='" + txtNoAnggota.Text + "'", c.connetionString);

            ds.Fill(ds_data, "JAMINAN");
            dataGridView1.DataSource = ds_data.Tables["JAMINAN"].DefaultView;
        }
        private void F050101_Load(object sender, EventArgs e)
        {
            radioButton1.Checked   = true;
            radioButton3.Checked   = true;
            rdbsttsaplnew.Checked  = true;
            cbxAgama.SelectedIndex = 0;
            firstLoad = true;

            foreach (Control item in this.Controls)
            {
                if (item is TextBox)
                {
                    item.TextChanged += new EventHandler(item_Text);
                }
                if (item is GroupBox)
                {
                    if (item.Name == "DetailPasangan")
                    {
                        foreach (Control t in item.Controls)
                        {
                            if (t is TextBox)
                            {
                                t.TextChanged += new EventHandler(item_Text);
                            }
                        }
                    }
                }
            }

            ds_data.Clear();
            DataTable        dataTable;
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("SELECT  `SALES_ID`, `NM_SALES`, `ALAMAT_SALES`, `TELP_SALES`, `IS_ACTIVE` FROM `sales`", c.connetionString);

            ds.Fill(ds_data, "SALES");

            dataTable = ds_data.Tables["SALES"];
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                namasales.Items.Add(dataTable.Rows[i].Field <string>(1));
            }
            if (namasales.Items.Count > 0)
            {
                namasales.SelectedIndex = 0;
            }
        }
        private void insertData()
        {
            string ket2  = "";
            string query = "INSERT INTO `pinjaman`" +
                           "(`NM_NASABAH`, `NM_SALES`, `NM_COLLECTOR`, `JLH_PINJAMAN`,`TIPE_PINJAMAN`) " +
                           "VALUES " +
                           "('" + txtNamaCustomer.Text + "','" + namasales.Text + "','" + cbxCollector.Text + "'," + nudJlhPinjaman.Value + ",'" + getTipePinjaman() + "')";
            MySqlConnection cnn;
            connection      con = new connection();

            cnn = new MySqlConnection(con.connetionString);
            MySqlCommand cmd = cnn.CreateCommand();

            cnn.Open();
            cmd.CommandText = query;
            nud.Value       = cmd.ExecuteNonQuery();
            cnn.Close();
        }
        private void F050105_Load(object sender, EventArgs e)
        {
            rdbHarian.Checked = true; //initial radio button cheked



            //Collector load
            ds_data.Clear();
            DataTable        dataTable;
            connection       c  = new connection();
            MySqlDataAdapter ds = new MySqlDataAdapter("SELECT `NM_COLLECTOR` FROM `collector`", c.connetionString);

            ds.Fill(ds_data, "collector");

            dataTable = ds_data.Tables["collector"];
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                cbxCollector.Items.Add(dataTable.Rows[i].Field <string>(0));
            }
            if (cbxCollector.Items.Count > 0)
            {
                cbxCollector.SelectedIndex = 0;
            }

            //sales load
            dataTable.Clear();
            ds = null;
            ds = new MySqlDataAdapter("SELECT  `SALES_ID`, `NM_SALES` FROM `sales`", c.connetionString);
            ds.Fill(ds_data, "SALES");

            dataTable = ds_data.Tables["SALES"];
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                namasales.Items.Add(dataTable.Rows[i].Field <string>(1));
            }
            if (namasales.Items.Count > 0)
            {
                namasales.SelectedIndex = 0;
            }
            nud.Value         = 0;
            nud.ValueChanged += new EventHandler(rowAffected);
        }
Exemple #16
0
        public int fn_IUD(string query)
        {
            int a = 0;

            try
            {
                MySqlConnection cnn;
                connection      con = new connection();
                cnn = new MySqlConnection(con.connetionString);
                MySqlCommand cmd = cnn.CreateCommand();
                cnn.Open();
                cmd.CommandText = query;
                a = cmd.ExecuteNonQuery();
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Terjadi Kesalahan!\n" + "Detail: \n" + ex.StackTrace);
            }
            return(a);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (!Validation())
            {
                return;
            }

            string query = string.Format("INSERT INTO NASABAH " +
                                         "(`id`,`NO_ANGGOTA`, `NAMA_COSTUMER`, `NO_KTP`, `NO_KK`, `AGAMA`, `TEMPAT_LAHIR`, `TANGGAL_LAHIR`, `JK`, `ALAMAT_KTP`, `ALAMAT_DOMISILI`, `TELP`, `PEKERJAAN`, `NAMA_IBU_KANDUNG`, `TANGGAL_LAHIR_IBU`, `NAMA_USAHA`, `ALAMAT_UsAHA`, `JENIS_USAHA`, `NAMA_BANK`, `NO_REKENING`, `NAMA_REKENING`, `NAMA_SALES`, `WILAYAH_AREA_TAGIH`, `STATUS_APPL`, `STATUS_MENIKAH`, `NAMA_PASANGAN`, `NO_KTP_PASANGAN`, `ALAMAT_PASANGAN`, `TELP_PASANGAN`) " +
                                         "VALUES " +
                                         "('" + getID() + "','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}')"
                                         , getNoAnggota(), txtNamaCustomer.Text, txtNomorKTP.Text,
                                         txtNomorKK.Text, cbxAgama.Text, txtTempatLahir.Text, dtmTanggalLahir.Value.ToString(), getJenisKelamin(),
                                         txtAlamatKTp.Text, txtAlamatDomisili.Text, txtTelp.Text,
                                         txtPekerjaan.Text, txtNamaIbuKandung.Text, txtTanggalLahirIbu.Text, txtNamaUsaha.Text, txtAlamatUsaha.Text,
                                         txtJenisUsaha.Text, txtNamaBank.Text, txtNoRek.Text, txtNamarek.Text, namasales.Text, areatagis.Text, getsttsapppl(), getStatus(), txtnamapasangan.Text, txtnoktppasangan.Text,
                                         txtalamatpasangan.Text, txtnotelppasangan.Text
                                         );
            string          connetionString = null;
            MySqlConnection cnn;
            connection      con = new connection();

            connetionString = con.connetionString;

            cnn = new MySqlConnection(connetionString);
            MySqlCommand cmd = cnn.CreateCommand();

            cnn.Open();
            cmd.CommandText = query;
            int a = cmd.ExecuteNonQuery();

            if (a >= 0)
            {
                MessageBox.Show("Data Tersimpan!", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            cnn.Close();
        }
Exemple #18
0
        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            treeView1.Nodes.Clear();
            Dictionary <string, string[]> X = new Dictionary <string, string[]>();
            Dictionary <string, Dictionary <string, string[]> > Y = new Dictionary <string, Dictionary <string, string[]> >();

            string[] rootParent = new string[0];

            string          connetionString = null;
            MySqlConnection cnn;
            connection      con = new connection();

            connetionString = con.connetionString;

            cnn = new MySqlConnection(connetionString);
            MySqlCommand cmd = cnn.CreateCommand();

            cnn.Open();
            cmd.CommandText = "SELECT DISTINCT(GROUP_NM) FROM MENUDEPARTMENT where MENUTOP_NM='" + e.ClickedItem.Text + "'";
            MySqlDataReader reader = cmd.ExecuteReader();
            int             loop   = 0;

            while (reader.Read())
            {
                Array.Resize(ref rootParent, rootParent.Length + 1);
                rootParent[loop] = reader[0].ToString();
                loop            += 1;
            }
            loop = 0;
            cnn.Close();

            Dictionary <string, string[]> rtpar = new Dictionary <string, string[]>();

            for (int i = 0; i < rootParent.Length; i++)
            {
                cnn.Open();
                cmd.CommandText = "SELECT DISTINCT(MAPVAL1) FROM MENUDEPARTMENT WHERE GROUP_NM='" + rootParent[i] + "'";
                reader          = cmd.ExecuteReader();
                loop            = 0;
                string[] ch  = new string[0];
                int      chk = -1;
                while (reader.Read())
                {
                    Array.Resize(ref ch, ch.Length + 1);
                    ch[loop] = reader[0].ToString();
                    loop    += 1;
                    chk      = i;
                }
                cnn.Close();
                if (chk == i)
                {
                    rtpar.Add(rootParent[i], ch);
                }
                ch = null;
            }


            Dictionary <string, Dictionary <string, string[]> > allValue = new Dictionary <string, Dictionary <string, string[]> >();
            TreeNode TR   = null;
            bool     flag = false;

            for (int i = 0; i < rootParent.Length; i++)
            {
                if (rootParent[i] != "")
                {
                    flag = true;
                    TR   = new TreeNode(rootParent[i]);
                    treeView1.Nodes.Add(TR);
                    //string x = rootParent[i] + ":";
                    for (int j = 0; j < rtpar[rootParent[i]].Length; j++)
                    {
                        // x += "" + rtpar[rootParent[i]][j].ToString();
                        if (rtpar[rootParent[i]][j] != "")
                        {
                            treeView1.Nodes[i].Nodes.Add(rtpar[rootParent[i]][j].ToString());
                        }
                        cnn.Open();
                        cmd.CommandText = "SELECT DISTINCT(MAPVAL2) FROM MENUDEPARTMENT WHERE GROUP_NM='" + rootParent[i] + "' AND MAPVAL1 = '" + rtpar[rootParent[i]][j] + "'";
                        reader          = cmd.ExecuteReader();
                        loop            = 0;
                        string[] ch  = new string[0];
                        int      chk = -1;
                        while (reader.Read())
                        {
                            if (reader[0].ToString() != "")
                            {
                                treeView1.Nodes[i].Nodes[j].Nodes.Add(reader[0].ToString());
                            }
                            //x += reader[0].ToString();
                        }
                        cnn.Close();
                    }
                }
                //x += "END";
                //MessageBox.Show(x);
            }
            if (!flag)
            {
                bool    chek = false;
                TabPage temp = new TabPage();
                for (int i = 0; i < tabControl1.TabPages.Count; i++)
                {
                    if (tabControl1.TabPages[i].Text == e.ClickedItem.Text)
                    {
                        chek = true;
                        temp = tabControl1.TabPages[i];
                        break;
                    }
                }

                if (chek)
                {
                    tabControl1.SelectedTab = temp;
                    lblScreenName.Text      = e.ClickedItem.Text;
                    return;
                }
                TabPage Apple = new TabPage(e.ClickedItem.Text);
                Apple.Controls.Clear();
                string          connetionString1 = null;
                MySqlConnection cnn1;
                connection      con1 = new connection();
                connetionString1 = con1.connetionString;

                cnn1 = new MySqlConnection(connetionString1);
                MySqlCommand cmd1 = cnn1.CreateCommand();
                cnn1.Open();
                cmd1.CommandText = "SELECT DISTINCT(FORM_NM) FROM MENUDEPARTMENT WHERE MENUTOP_NM='" + e.ClickedItem.Text + "'";
                MySqlDataReader reader1 = cmd1.ExecuteReader();
                string          form_nm = "";
                while (reader1.Read())
                {
                    form_nm = reader1[0].ToString();
                }
                cnn1.Close();

                // MessageBox.Show(e.ClickedItem.Text);
                FlowLayoutPanel pn = new FlowLayoutPanel();
                pn.Dock = DockStyle.Fill;
                string formToCall = form_nm;

                var type = Type.GetType(nameSpace + "." + formToCall);
                if (type != null)
                {
                    var userControl = Activator.CreateInstance(type) as UserControl;
                    if (Activator.CreateInstance(type) as UserControl != null)
                    {
                        userControl.Parent = pn;
                        userControl.Dock   = DockStyle.Fill;
                        userControl.Anchor = AnchorStyles.Right;
                        // userControl.Width = tabControl1.Width - 10;
                        //userControl.Height = tabControl1.Height - 10;
                        userControl.Show();
                        pn.Controls.Add(userControl);
                    }
                }
                pn.AutoScroll = true;
                Apple.Controls.Add(pn);
                lblScreenName.Text      = Apple.Text;
                Apple.Parent            = tabControl1;
                Apple.Padding           = new Padding(0);
                tabControl1.SelectedTab = Apple;
                return;
            }
        }
Exemple #19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Start();
            menuStrip1.Items.Clear();
            menuTop = new string[0];
            tabControl1.TabPages.Clear();
            treeView1.Nodes.Clear();
            maxTabPage = 15;
            nameSpace  = "Management";

            if (NIP == "")
            {
                MessageBox.Show("NOT LOGIN");
                return;
            }

            string          connetionString = null;
            MySqlConnection cnn;
            connection      con = new connection();

            connetionString = con.connetionString;
            cnn             = new MySqlConnection(connetionString);
            try
            {
                MySqlCommand command = cnn.CreateCommand();
                command.CommandText = "SELECT MENUACCES FROM USERS WHERE NIP='" + NIP + "' LIMIT 1";
                cnn.Open();
                string          menuacces = "";
                MySqlDataReader READ      = command.ExecuteReader();
                while (READ.Read())
                {
                    menuacces = READ[0].ToString();
                }
                cnn.Close();


                MySqlCommand cmd = cnn.CreateCommand();
                cmd.CommandText = "SELECT NAME FROM MENUTOP WHERE id in(" + menuacces + ")";
                // cmd.CommandText = "SELECT NAME from menutop";
                cnn.Open();
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Array.Resize(ref menuTop, menuTop.Length + 1);
                    menuTop[menuTop.Length - 1] = reader[0].ToString();
                }
                cnn.Close();
                for (int i = 0; i < menuTop.Length; i++)
                {
                    menuStrip1.Items.Add(menuTop[i]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! " + ex.Message);
            }

            tabControl1.DrawMode  = TabDrawMode.OwnerDrawFixed;
            tabControl1.DrawItem += tabControl1_DrawItem;
            CloseImage            = Management.Properties.Resources.icons8_close_window_14px;
            tabControl1.Padding   = new Point(10);

            tabControl1.Padding = new System.Drawing.Point(21, 3);
        }
Exemple #20
0
        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (findLastNode(e.Node))
            {
                // MessageBox.Show(e.Node.ToString());
                bool    chek = false;
                TabPage temp = new TabPage();
                for (int i = 0; i < tabControl1.TabPages.Count; i++)
                {
                    if (e.Node.Text == tabControl1.TabPages[i].Text)
                    {
                        temp = tabControl1.TabPages[i];
                        chek = true;
                    }
                }
                if (chek)
                {
                    tabControl1.SelectedTab = temp;
                    lblScreenName.Text      = temp.Text;
                    return;
                }
                if (tabControl1.TabPages.Count >= maxTabPage)
                {
                    MessageBox.Show("Maximum tab : " + tabControl1.TabPages.Count.ToString(), "TAB", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                TabPage Apple = new TabPage(e.Node.Text);

                Apple.Controls.Clear();
                string queryExe = "";
                if (e.Node.Level == 0)
                {
                    queryExe = "SELECT DISTINCT(FORM_NM) FROM MENUDEPARTMENT WHERE GROUP_NM='" + e.Node.Text + "'";
                }
                else if (e.Node.Level == 1)
                {
                    queryExe = "SELECT DISTINCT(FORM_NM) FROM MENUDEPARTMENT WHERE MAPVAL1='" + e.Node.Text + "'";
                }
                else if (e.Node.Level == 2)
                {
                    queryExe = "SELECT DISTINCT(FORM_NM) FROM MENUDEPARTMENT WHERE MAPVAL2='" + e.Node.Text + "'";
                }
                else
                {
                    MessageBox.Show("Erorr Occured");
                    return;
                }

                string          connetionString = null;
                MySqlConnection cnn;
                connection      con = new connection();
                connetionString = con.connetionString;

                cnn = new MySqlConnection(connetionString);
                MySqlCommand cmd = cnn.CreateCommand();
                cnn.Open();
                cmd.CommandText = queryExe;
                MySqlDataReader reader  = cmd.ExecuteReader();
                string          form_nm = "";
                while (reader.Read())
                {
                    form_nm = reader[0].ToString();
                }
                cnn.Close();



                FlowLayoutPanel pn = new FlowLayoutPanel();
                pn.Dock = DockStyle.Fill;
                string formToCall = form_nm;

                var type = Type.GetType(nameSpace + "." + formToCall);
                if (type != null)
                {
                    var userControl = Activator.CreateInstance(type) as UserControl;
                    if (Activator.CreateInstance(type) as UserControl != null)
                    {
                        userControl.Parent = pn;
                        userControl.Dock   = DockStyle.Fill;
                        userControl.Anchor = AnchorStyles.Right;
                        userControl.Width  = tabControl1.Width - 10;
                        userControl.Height = tabControl1.Height - 10;
                        userControl.Show();
                        pn.Controls.Add(userControl);
                    }
                }
                pn.AutoScroll = true;
                Apple.Controls.Add(pn);
                lblScreenName.Text      = Apple.Text;
                Apple.Parent            = tabControl1;
                Apple.Padding           = new Padding(0);
                tabControl1.SelectedTab = Apple;
                return;
            }
        }