예제 #1
0
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            listBox1.SelectedItems.Clear();
            if (comboBox1.Text == "Toate")
            {
                PopuleazaLista();

                this.listBox1.Enabled = false;
                this.button1.Enabled  = false;
                this.button2.Enabled  = false;
            }
            else
            {
                this.listView1.CheckBoxes = true;

                foreach (var x in ListaTranzactii)
                {
                    if (x.ContClient.Banca.Nume == comboBox1.Text)
                    {
                        ListViewItem Lvi = new ListViewItem(x.Id.ToString());
                        Lvi.SubItems.Add(x.ContClient.Companie.Nume);
                        Lvi.SubItems.Add(x.ContFurnizor.Companie.Nume);
                        Lvi.SubItems.Add(x.ContClient.IBAN);
                        Lvi.SubItems.Add(x.ContFurnizor.IBAN);
                        Lvi.SubItems.Add(x.ValoareTotala.ToString("N2"));
                        Lvi.SubItems.Add(x.Moneda);
                        Lvi.SubItems.Add(x.Data.ToString(DateFormat));

                        Lvi.SubItems.Add(x.ContClient.Banca.Nume);

                        Lvi.Checked = true;
                        this.listView1.Items.Add(Lvi);
                    }
                }

                this.listBox1.Enabled = true;
                this.button1.Enabled  = true;
                this.button2.Enabled  = true;
            }

            using (FacturiContext context = new FacturiContext()) {
                try {
                    templateBanci = context.TemplateExportBanci.Where(x => x.NumeBanca.Equals(comboBox1.Text)).First();
                } catch {
                    templateBanci = null;
                }

                if (templateBanci != null)
                {
                    foreach (var x in templateBanci.Template.Split(','))
                    {
                        listBox1.SelectedIndex = indexiListBox[x];
                    }
                }
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndices == null)
            {
                MessageBox.Show("Nu ati selectat niciun element!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (FacturiContext context = new FacturiContext()) {
                DialogResult result = MessageBox.Show("Sunteti sigur ca doriti salvarea template-ului in baza de date?", "Template", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                if (result == DialogResult.OK)
                {
                    TemplateExportBanci temp = new TemplateExportBanci();
                    List <string>       elementeSelectate = new List <string>();
                    foreach (int x in listBox1.SelectedIndices)
                    {
                        elementeSelectate.Add(listBox1.Items[x].ToString());
                    }

                    temp.Template = string.Join(",", elementeSelectate);

                    if (templateBanci == null)
                    {
                        templateBanci = new TemplateExportBanci();
                    }

                    templateBanci.Template  = temp.Template;
                    templateBanci.NumeBanca = comboBox1.Text;

                    if (context.TemplateExportBanci.Any(x => x.NumeBanca == comboBox1.Text))
                    {
                        context.Entry <TemplateExportBanci>(templateBanci).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        context.Entry <TemplateExportBanci>(templateBanci).State = System.Data.Entity.EntityState.Added;
                    }

                    context.SaveChanges();
                }
            }
        }