Пример #1
0
        private void BT_FileImport_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".xlsx";
            dlg.Filter = "Excel documents|*.xls;*.xlsx";
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                ExcelData exceldata = new ExcelData(dlg.FileName, CurrentProject.mf);
                DG_Items.DataContext = null;;
                DG_Items.ItemsSource = null;
                db.ClearTable("Current_Data");
                db.DoFillData("Current_Data", exceldata, CurrentProject.mf);
                load_Items();               

                if (CurrentProject.InputItems.Count() > 0)
                    BT_FileImport_Checks.IsEnabled = true;

                System.IO.File.Copy(dlg.FileName, System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/CURRENT_EXCEL/current.xls", true);
            }
        }
Пример #2
0
        public void DoFillData(String t, ExcelData ed, MapFieldList m)
        {
            table = t;
            edata = ed;
            mf = m;

            ProgressDialog dlg2 = new ProgressDialog();
            dlg2.Owner = null;
            for (int index = 0; index < App.Current.Windows.Count; index++)
            {
                if (App.Current.Windows[index].Title == "ΕΥΕ Sampling")
                {
                    dlg2.Owner = App.Current.Windows[index];
                    break;
                }
            } 
            dlg2.DialogText = "Καταγραφή δεδομένων στη Βάση.";
            int startValue = 0;
            dlg2.RunWorkerThread(startValue, FillData);
        }
Пример #3
0
        private void BT_FileImport_Checks_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentProject.title == "")
            {
                MessageBox.Show("Παρακαλώ ορίστε τον τίτλο του Project!");
                return;
            } if (CurrentProject.mis == "")
            {
                MessageBox.Show("Παρακαλώ ορίστε τον κωδικό MIS του Project!");
                return;
            }

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".xlsx";
            dlg.Filter = "Excel documents|*.xls;*.xlsx";
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                db.ExecuteNonQuery("Update Current_Data set plithos_elegxon=0, synolo_poinon=0");
                ExcelData exceldata_Check = new ExcelData(dlg.FileName, CurrentProject.mf_check, true);
                string poin = "";
                foreach (DataRow r in exceldata_Check.Data.Table.Rows)
                {
                    if (r["ergo"].ToString() != CurrentProject.title && r["mis"].ToString() != CurrentProject.mis) continue;
                    poin = "";
                    if (r["poines"].ToString()!="")
                        poin=", synolo_poinon=synolo_poinon + "+r["poines"].ToString();
                    db.ExecuteNonQuery("Update Current_Data set plithos_elegxon=plithos_elegxon+1"+poin+" where ekepis=" + r["ekepis"].ToString() + " and praxi=" + r["praxi"].ToString());
                }
                DG_Items.DataContext = null; ;
                DG_Items.ItemsSource = null;
                load_Items();
            }


        }
Пример #4
0
        /// <summary>
        ///     Allows the user to easily clear all data from a specific table.
        /// </summary>
        /// <param name="table">The name of the table to clear.</param>
        /// <returns>A boolean true or false to signify success or failure.</returns>
        public bool FillData(String table, ExcelData edata, MapFieldList mf)
        {
            try
            {

               foreach(DataRow r in edata.Data.Table.Rows)
               {
                   Dictionary<string, string> dict = new Dictionary<string, string>(){};
                   int i = 0;
                   foreach(Mapfield m in mf)
                   {
                       dict.Add(m.Name,r[i++].ToString());
                   }
                   this.Insert(table, dict);
               }
                return true;
            }
            catch
            {
                return false;
            }
        }