示例#1
0
 private void radioButton1_Form2_Space_CheckedChanged(object sender, EventArgs e)
 {
     delimiterF2 = ' ';
     if (Form1.dataExport)
     {
         if (Form1.dataLoaded)
         {
             dataGridView1_Form2.DataSource = DataHandler.dtToListStr(Form1.dtTarget.AsEnumerable().Take(numberOfRows).CopyToDataTable(), delimiterF2, qualifierF2).ConvertAll(x => new { Value = x });
         }
         else
         {
             dataGridView1_Form2.DataSource = DataHandler.dtToListStr(Form1.dt.AsEnumerable().Take(numberOfRows).CopyToDataTable(), delimiterF2, qualifierF2).ConvertAll(x => new { Value = x });
         }
     }
     else
     {
         temp_dt = DataHandler.FlatToDt(fileWithPathF2, delimiterF2, numberOfRows);
         dataGridView1_Form2.DataSource = temp_dt;
     }
 }
示例#2
0
 private void textBox2_Form2_qualifier_TextChanged(object sender, EventArgs e)
 {
     qualifierF2 = checkBox1_Form2_qualifier.Checked == true ? textBox2_Form2_qualifier.Text : "";
     if (Form1.dataExport)
     {
         if (Form1.dataLoaded)
         {
             dataGridView1_Form2.DataSource = DataHandler.dtToListStr(Form1.dtTarget.AsEnumerable().Take(numberOfRows).CopyToDataTable(), delimiterF2, qualifierF2).ConvertAll(x => new { Value = x });
         }
         else
         {
             dataGridView1_Form2.DataSource = DataHandler.dtToListStr(Form1.dt.AsEnumerable().Take(numberOfRows).CopyToDataTable(), delimiterF2, qualifierF2).ConvertAll(x => new { Value = x });
         }
     }
     else
     {
         temp_dt = DataHandler.FlatToDt(fileWithPathF2, delimiterF2, numberOfRows);
         dataGridView1_Form2.DataSource = temp_dt;
     }
 }
示例#3
0
        private void button1_Form1_import_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(fileWithPath))
                {
                    form2 = new Form2();
                    form2.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please select a file");
                }

                if (Form2.dataOk)
                {
                    delimiterF1 = Form2.delimiterF2;
                    dt          = DataHandler.FlatToDt(fileWithPath, delimiterF1);
                    DataTable dtFirst50 = dt.AsEnumerable().Take(50).CopyToDataTable();

                    //DATA SOURCES TO GRID AND COMBOBOXES
                    dataGridView1.Columns.Clear();
                    dataGridView1.DataSource = dtFirst50;

                    foreach (Control tab in tabControl1.TabPages)
                    {
                        TabPage tabPage = (TabPage)tab;

                        //COMMITED GIVING
                        if (tabPage.Name == "CG_tabPage1")
                        {
                            foreach (Control group in tabPage.Controls)
                            {
                                foreach (Control item in group.Controls)
                                {
                                    if (item.GetType().Name == "ComboBox")
                                    {
                                        ComboBox comboBox = (ComboBox)item;
                                        if (item.Name == "comboBox1_CG_ClientName")
                                        {
                                            comboBox.BindingContext = new BindingContext();
                                            comboBox.DataSource     = new BindingSource(DataHandler.CharityNamesPairs(), null);
                                            comboBox.DisplayMember  = "Value";
                                            comboBox.ValueMember    = "Key";
                                        }
                                        else
                                        {
                                            comboBox.BindingContext = new BindingContext();
                                            comboBox.DataSource     = DataHandler.colNamesArray(dtFirst50, true);
                                        }
                                    }
                                }
                            }
                            comboBox1_CG_duplicates.DataSource = DataHandler.colNamesArray(DataTableFactory.DtScheme(tabPage.Name), true);
                        }
                    }

                    //DEFAULT VALUES
                    textBox3_CG_Primkey.Text               = DateTime.Now.ToString("ddMMyyyy");
                    textBox1_CG_AddedDateTime.Text         = DateTime.Now.ToString("dd/MM/yyyy");
                    textBox1_CG_AddedBy.Text               = "Admin";
                    textBox1_CG_Primkey.Text               = "";
                    label2_CG_RowsImported.Text            = dt.Rows.Count.ToString();
                    radioButton1_CG_RecordTypeWarm.Checked = true;


                    //GLOBAL VALUES
                    fileWithPath = null;
                    textBox1_Form1_filePath.Text = fileWithPath;
                    Form2.fileWithPathF2         = null;
                    dataLoaded   = false;
                    Form2.dataOk = false;
                    label2_CG_RowsImported.Text = dt.Rows.Count.ToString();
                    label2_CG_RowsLoaded.Text   = "0";
                    label2_CG_RowsDeleted.Text  = "0";
                }
            }
            catch (System.InvalidOperationException)
            {
                MessageBox.Show("The file you try to import does not contain any rows");
            }
            catch (Exception)
            {
                MessageBox.Show("There is an issue with your file");
            }
        }