Ejemplo n.º 1
0
        void cmb_nama()
        {
            EasyCompletionComboBox cmb_nma = new EasyCompletionComboBox();

            cmb_nma.Name           = "cmb_nma_" + count_nma.ToString();
            cmb_nma.Size           = new Size(200, 21);
            cmb_nma.Location       = new Point(23, pos_nma);
            cmb_nma.MatchingMethod = StringMatchingMethod.UseWildcards;
            cmb_nma.Items.AddRange(item_name);
            cmb_nma.SelectedIndexChanged += cmb_nma_SelectedIndexChanged;
            panel_item.Controls.Add(cmb_nma);
            count_nma += 1;
            pos_nma   += 23;
        }
Ejemplo n.º 2
0
        void load_cmb_add()
        {
            EasyCompletionComboBox cmb_add = new EasyCompletionComboBox();

            cmb_add.Name           = "cmb_add_" + count_cmb.ToString();
            cmb_add.Size           = new Size(205, 21);
            cmb_add.Location       = new Point(23, pos_cmb);
            cmb_add.Text           = "Pilih item";
            cmb_add.MatchingMethod = StringMatchingMethod.NoWildcards;
            cmb_add.Items.AddRange(item_name);
            cmb_add.Tag = count_cmb.ToString();

            count_cmb += 1;
            pos_cmb   += 23;

            panel_data.Controls.Add(cmb_add);
        }
Ejemplo n.º 3
0
        void add_btn_Click(object sender, EventArgs e)
        {
            Button btn_aad = (Button)sender;
            EasyCompletionComboBox cmb_nma = new EasyCompletionComboBox();
            TextBox txt_jlh = new TextBox();
            TextBox txt_hrg = new TextBox();

            if (btn_aad.Text == "+")
            {
                cmb_nama();
                txt_jumlah();
                txt_harga();
                btn_add();
                btn_aad.Text = "-";
            }
            else
            {
                int x = Convert.ToInt32(btn_aad.Name.Substring(8));
                cmb_nma = (EasyCompletionComboBox)panel_item.Controls["cmb_nma_" + x.ToString()];
                txt_jlh = (TextBox)panel_item.Controls["txt_jlh_" + x.ToString()];
                txt_hrg = (TextBox)panel_item.Controls["txt_hrg_" + x.ToString()];
                List <Button> list_btn = new List <Button>();
                List <EasyCompletionComboBox> list_nma = new List <EasyCompletionComboBox>();
                List <TextBox> list_jlh = new List <TextBox>();
                List <TextBox> list_hrg = new List <TextBox>();

                foreach (Control c in panel_item.Controls)
                {
                    if (c.GetType() == typeof(Button))
                    {
                        if (Convert.ToInt32(((Button)c).Name.Substring(8)) > x)
                        {
                            list_btn.Add((Button)c);
                        }
                    }
                    else if (c.GetType() == typeof(EasyCompletionComboBox))
                    {
                        if (Convert.ToInt32(((EasyCompletionComboBox)c).Name.Substring(8)) > x - 1)
                        {
                            list_nma.Add((EasyCompletionComboBox)c);
                        }
                    }
                    else if (c.GetType() == typeof(TextBox))
                    {
                        string z = ((TextBox)c).Name.Substring(4, 3);
                        if (Convert.ToInt32(((TextBox)c).Name.Substring(8)) > x - 1)
                        {
                            if (z == "jlh")
                            {
                                list_jlh.Add((TextBox)c);
                            }
                            else if (z == "hrg")
                            {
                                list_hrg.Add((TextBox)c);
                            }
                        }
                    }
                }
                if (list_btn.Count > 0)
                {
                    foreach (Button b in list_btn)
                    {
                        int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                        b.Location = new Point(b.Location.X, b.Location.Y - 23);
                        string q = b.Name.Remove(8);
                        q      = q.Insert(8, y.ToString());
                        b.Name = q;
                    }
                }
                if (list_nma.Count > 0)
                {
                    foreach (EasyCompletionComboBox b in list_nma)
                    {
                        int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                        b.Location = new Point(b.Location.X, b.Location.Y - 23);
                        string q = b.Name.Remove(8);
                        q      = q.Insert(8, y.ToString());
                        b.Name = q;
                    }
                }
                if (list_jlh.Count > 0)
                {
                    foreach (TextBox b in list_jlh)
                    {
                        int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                        b.Location = new Point(b.Location.X, b.Location.Y - 23);
                        string q = b.Name.Remove(8);
                        q      = q.Insert(8, y.ToString());
                        b.Name = q;
                    }
                }
                if (list_hrg.Count > 0)
                {
                    foreach (TextBox b in list_hrg)
                    {
                        int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                        b.Location = new Point(b.Location.X, b.Location.Y - 23);
                        string q = b.Name.Remove(8);
                        q      = q.Insert(8, y.ToString());
                        b.Name = q;
                    }
                }
                count_btn -= 1;
                count_nma -= 1;
                count_jlh -= 1;
                count_hrg -= 1;
                pos_btn   -= 23;
                pos_nma   -= 23;
                pos_jlh   -= 23;
                pos_hrg   -= 23;
                btn_aad.Dispose();
                cmb_nma.Dispose();
                txt_jlh.Dispose();
                txt_hrg.Dispose();
            }
        }
Ejemplo n.º 4
0
        void load_button_add()
        {
            Button btn_add = new Button();

            btn_add.Name     = "btn_add_" + count_btn.ToString();
            btn_add.Size     = new Size(23, 23);
            btn_add.Text     = "+";
            btn_add.Location = new Point(0, pos_btn);
            btn_add.Tag      = count_btn.ToString();

            count_btn += 1;
            pos_btn   += 23;

            panel_data.Controls.Add(btn_add);

            btn_add.Click += (s, e) =>
            {
                Button  target_btn = (Button)s;
                TextBox target_txt = new TextBox();
                EasyCompletionComboBox target_cmb = new EasyCompletionComboBox();

                if (target_btn.Text == "+")
                {
                    load_button_add();
                    load_txt_add();
                    load_cmb_add();
                    target_btn.Text = "-";
                }
                else
                {
                    int x = Convert.ToInt32(target_btn.Name.Substring(8));
                    target_txt = (TextBox)panel_data.Controls["txt_add_" + x.ToString()];
                    target_cmb = (EasyCompletionComboBox)panel_data.Controls["cmb_add_" + x.ToString()];
                    List <Button>  list_btn = new List <Button>();
                    List <TextBox> list_txt = new List <TextBox>();
                    List <EasyCompletionComboBox> list_cmb = new List <EasyCompletionComboBox>();

                    foreach (Control c in panel_data.Controls)
                    {
                        if (c.GetType() == typeof(Button))
                        {
                            if (Convert.ToInt32(((Button)c).Name.Substring(8)) > x)
                            {
                                list_btn.Add((Button)c);
                            }
                        }
                        else if (c.GetType() == typeof(TextBox))
                        {
                            if (Convert.ToInt32(((TextBox)c).Name.Substring(8)) > x - 1)
                            {
                                list_txt.Add((TextBox)c);
                            }
                        }
                        else if (c.GetType() == typeof(EasyCompletionComboBox))
                        {
                            if (Convert.ToInt32(((EasyCompletionComboBox)c).Name.Substring(8)) > x - 1)
                            {
                                list_cmb.Add((EasyCompletionComboBox)c);
                            }
                        }
                    }
                    if (list_btn.Count > 0)
                    {
                        foreach (Button b in list_btn)
                        {
                            int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                            b.Location = new Point(b.Location.X, b.Location.Y - 23);
                            string q = b.Name.Remove(8);
                            q      = q.Insert(8, y.ToString());
                            b.Name = q;
                        }
                    }
                    if (list_txt.Count > 0)
                    {
                        foreach (TextBox b in list_txt)
                        {
                            int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                            b.Location = new Point(b.Location.X, b.Location.Y - 23);
                            string q = b.Name.Remove(8);
                            q      = q.Insert(8, y.ToString());
                            b.Name = q;
                            //b.Text = b.Name;
                        }
                    }
                    if (list_cmb.Count > 0)
                    {
                        foreach (EasyCompletionComboBox b in list_cmb)
                        {
                            int y = Convert.ToInt32(b.Name.Substring(8)) - 1;
                            b.Location = new Point(b.Location.X, b.Location.Y - 23);
                            string q = b.Name.Remove(8);
                            q      = q.Insert(8, y.ToString());
                            b.Name = q;
                            //b.Text = b.Name;
                        }
                    }
                    count_btn -= 1;
                    pos_btn   -= 23;
                    count_txt -= 1;
                    pos_txt   -= 23;
                    count_cmb -= 1;
                    pos_cmb   -= 23;
                    target_btn.Dispose();
                    target_txt.Dispose();
                    target_cmb.Dispose();
                }
            };
        }