Esempio n. 1
0
 public NewDBPage5(NewDBVars n, SSDataBase db)
 {
     ndbv = n;
     mydb = db;
     // This call is required by the Windows Form Designer.
     InitializeComponent();
 }
Esempio n. 2
0
        public MergeDialog(string _path, SSDataBase _mydb)
        {
            InitializeComponent();

            //Additional initialization
            DataTable dt = new DataTable();

            mvars = new MergeVars();
            mvars.defaultDBPath = _path;
            mvars.Masterdb = _mydb;
            oldDBPath = _mydb.MyPath;
            mvars.mergeDBs = new List<SSDataBase>();

            //Check the info of the currently loaded master database and copy it into mvars for later use
            try {
                mvars.Masterdb.GetDBInfo(dt);
                mvars.Masterdbname = Convert.ToString(dt.Rows[0][0]);
                mvars.Masterdblocation = Convert.ToString(dt.Rows[0][1]);
                mvars.Masterdbdate = String.Format("{0:MM/dd/yyyy}", dt.Rows[0][2]);
            } catch (InvalidOperationException) { //Happens when no database is loaded
                mvars.Masterdbname = "";
                mvars.Masterdblocation = "";
            }

            page1 = new MergePage1(mvars);

            Controls.Add(page1);
        }
Esempio n. 3
0
 public NewDBPage9(NewDBVars n, SSDataBase db)
 {
     ndbv = n;
     mydb = db;
     // This call is required by the Windows Form Designer.
     InitializeComponent();
 }
Esempio n. 4
0
        public MergeDialog(string _path, SSDataBase _mydb)
        {
            InitializeComponent();

            //Additional initialization
            DataTable dt = new DataTable();

            mvars = new MergeVars();
            mvars.defaultDBPath = _path;
            mvars.Masterdb      = _mydb;
            oldDBPath           = _mydb.MyPath;
            mvars.mergeDBs      = new List <SSDataBase>();

            //Check the info of the currently loaded master database and copy it into mvars for later use
            try
            {
                mvars.Masterdb.GetDBInfo(dt);
                mvars.Masterdbname     = Convert.ToString(dt.Rows[0][0]);
                mvars.Masterdblocation = Convert.ToString(dt.Rows[0][1]);
                mvars.Masterdbdate     = String.Format("{0:MM/dd/yyyy}", dt.Rows[0][2]);
            }
            catch (InvalidOperationException)
            { //Happens when no database is loaded
                mvars.Masterdbname     = "";
                mvars.Masterdblocation = "";
            }

            page1 = new MergePage1(mvars);

            Controls.Add(page1);
        }
Esempio n. 5
0
        /// <summary>
        /// Click event for the Select Master button
        /// </summary>
        private void btn_SelectMaster_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = Wizard.defaultpath;
            ofd.Title            = "Select Master Database";
            ofd.Filter           = "SecondSight Databases (*.ssd)|*.ssd|All Files (*.*)|*.*";
            ofd.CheckFileExists  = true;
            ofd.Multiselect      = false;
            ofd.DefaultExt       = ".ssd";

            //Process the open file dialog
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                SSDataBase ssdbt = new SSDataBase();

                //If the file name is the same as the "current" database's filename, that means the user wants to select the
                //database currently open in the main program.  Don't attempt to open that one a second time.  Otherwise
                //attempt to open the selected database
                if (ofd.FileName == Wizard.currentdb.MyPath)
                {
                    Wizard.masterdb = Wizard.currentdb; //Set the master to the currently open db
                }
                else
                {
                    try
                    { //Attempt to open the selected database
                        ssdbt.OpenDB(ofd.FileName);
                    }
                    catch
                    { //Not a valid secondsight database
                        MessageBox.Show("The selected file is not a valid SecondSight database and cannot be used as the master database for a merge.",
                                        "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        return;
                    }
                    Wizard.masterdb = ssdbt; //Set the master to the newly selected db
                }

                //Get the info for the database
                string tname;
                string tloc;
                System.Data.DataTable dt = new System.Data.DataTable();
                try
                {
                    Wizard.masterdb.GetTable(dt, SSTable.DBInfo);
                    tname = Convert.ToString(dt.Rows[0][0]);
                    tloc  = Convert.ToString(dt.Rows[0][1]);
                }
                catch
                {
                    MessageBox.Show("The selected file is not a valid SecondSight database and cannot be used as the master database for a merge.",
                                    "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                lb_CurrentMaster.Text = "Master Database: " + tname + " (" + tloc + ")";
            }
        }
Esempio n. 6
0
        //Constructor
        public MergeCalculator(SSDataBase _ssdb, string _path)
        {
            InitializeComponent();

            currentdb = _ssdb;
            masterdb = _ssdb;

            defaultpath = _path;
            mcvars = new MergeCalculatorVars();

            Controls.Add(new MergeCalculatorPage1());
            Controls.Add(new MergeCalculatorPage2());
            Controls.Add(new MergeCalculatorPage3());
        }
Esempio n. 7
0
        public NewDBWizard(SSDataBase db, string dbpath)
        {
            //			System.Reflection.Assembly tasm = System.Reflection.Assembly.GetEntryAssembly();
            ndbv             = new NewDBVars();
            mydb             = db;
            ndbv.DefaultPath = dbpath + "\\"; //System.IO.Path.GetDirectoryName(tasm.Location) + "\\Databases\\";
            ndbv.Path        = ndbv.DefaultPath;
            InitializeComponent();

            Controls.AddRange(new Control[] {
                new NewDBPage1(),
                new NewDBPage2(),
                new NewDBPage3(ndbv),
                new NewDBPage4(ndbv),
                new NewDBPage5(ndbv, mydb),
                new NewDBPage6(ndbv, mydb),
                new NewDBPage7(ndbv),
                new NewDBPage8(ndbv),
                new NewDBPage9(ndbv, mydb)
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Exports the entire contents of a SecondSight database to an excel-compatible spreadsheet file.
        /// This function overwrites the file chosen if it already exists.
        /// </summary>
        /// <param name="_db">The SecondSight database to export</param>
        /// <param name="_path">The full path to the file being created (or overwritten)</param>
        public static void ExportFullDatabase(SSDataBase _db, string _path)
        {
            DataTable currentinv = new DataTable();
            DataTable dispensedinv = new DataTable();
            DataTable dbinfo = new DataTable();

            Workbook wb = new Workbook();
            Worksheet ciws = new Worksheet("Current Inventory");
            Worksheet diws = new Worksheet("Dispensed Inventory");
            Worksheet infows = new Worksheet("Database Information");

            _db.GetTable(currentinv, SSTable.Current);
            _db.GetTable(dispensedinv, SSTable.Dispensed);
            _db.GetTable(dbinfo, SSTable.DBInfo);

            //Populate the Database Information page
            infows.Cells[1, 1] = new Cell("Name");
            infows.Cells[1, 2] = new Cell("Location");
            infows.Cells[1, 3] = new Cell("Date Created");
            infows.Cells[2, 1] = new Cell(dbinfo.Rows[0][0].ToString());
            infows.Cells[2, 2] = new Cell(dbinfo.Rows[0][1].ToString());
            infows.Cells[2, 3] = new Cell(String.Format("{0:MM/dd/yyyy}", dbinfo.Rows[0][2]));

            //Populate the Current Inventory page (headers)
            ciws.Cells[1, 1] = new Cell("SKU");
            ciws.Cells[1, 2] = new Cell("OD Sphere");
            ciws.Cells[1, 3] = new Cell("OD Cylinder");
            ciws.Cells[1, 4] = new Cell("OD Axis");
            ciws.Cells[1, 5] = new Cell("OD Add");
            ciws.Cells[1, 6] = new Cell("OS Sphere");
            ciws.Cells[1, 7] = new Cell("OS Cylinder");
            ciws.Cells[1, 8] = new Cell("OS Axis");
            ciws.Cells[1, 9] = new Cell("OS Add");
            ciws.Cells[1, 10] = new Cell("Type");
            ciws.Cells[1, 11] = new Cell("Gender");
            ciws.Cells[1, 12] = new Cell("Size");
            ciws.Cells[1, 13] = new Cell("Tint");
            ciws.Cells[1, 14] = new Cell("Date Added");
            ciws.Cells[1, 15] = new Cell("Comment");
            int tindex = 0;

            //Populate the Current Inventory page (data)
            for (int i = 0; i < currentinv.Rows.Count; i++) {
                tindex = i;
                ciws.Cells[i + 2, 1] = new Cell(currentinv.Rows[i][0].ToString());
                ciws.Cells[i + 2, 2] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][1]))); //Sphere
                ciws.Cells[i + 2, 3] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][2]))); //Cylinder
                ciws.Cells[i + 2, 4] = new Cell(currentinv.Rows[i][3].ToString()); //Axis
                ciws.Cells[i + 2, 5] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][4]))); //Add
                ciws.Cells[i + 2, 6] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][5]))); //Sphere
                ciws.Cells[i + 2, 7] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][6]))); //Cylinder
                ciws.Cells[i + 2, 8] = new Cell(currentinv.Rows[i][7].ToString()); //Axis
                ciws.Cells[i + 2, 9] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][8]))); //Add
                ciws.Cells[i + 2, 10] = new Cell(currentinv.Rows[i][9].ToString());
                ciws.Cells[i + 2, 11] = new Cell(currentinv.Rows[i][10].ToString());
                ciws.Cells[i + 2, 12] = new Cell(currentinv.Rows[i][11].ToString());
                ciws.Cells[i + 2, 13] = new Cell(currentinv.Rows[i][12].ToString());
                ciws.Cells[i + 2, 14] = new Cell(String.Format("{0:MM/dd/yyyy}", currentinv.Rows[i][13])); //Date Added
                ciws.Cells[i + 2, 15] = new Cell(currentinv.Rows[i][14].ToString());
            }

            //Populate the Dispensed Inventory page (headers)
            diws.Cells[1, 1] = new Cell("SKU");
            diws.Cells[1, 2] = new Cell("OD Sphere");
            diws.Cells[1, 3] = new Cell("OD Cylinder");
            diws.Cells[1, 4] = new Cell("OD Axis");
            diws.Cells[1, 5] = new Cell("OD Add");
            diws.Cells[1, 6] = new Cell("OS Sphere");
            diws.Cells[1, 7] = new Cell("OS Cylinder");
            diws.Cells[1, 8] = new Cell("OS Axis");
            diws.Cells[1, 9] = new Cell("OS Add");
            diws.Cells[1, 10] = new Cell("Type");
            diws.Cells[1, 11] = new Cell("Gender");
            diws.Cells[1, 12] = new Cell("Size");
            diws.Cells[1, 13] = new Cell("Tint");
            diws.Cells[1, 14] = new Cell("Date Added");
            diws.Cells[1, 15] = new Cell("Date Dispensed");
            diws.Cells[1, 16] = new Cell("Comment");

            //Populate the Dispensed Inventory page (data)
            for (int i = 0; i < dispensedinv.Rows.Count; i++) {
                diws.Cells[i + 2, 1] = new Cell(dispensedinv.Rows[i][0].ToString());
                diws.Cells[i + 2, 2] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][1]))); //Sphere
                diws.Cells[i + 2, 3] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][2]))); //Cylinder
                diws.Cells[i + 2, 4] = new Cell(dispensedinv.Rows[i][3].ToString()); //Axis
                diws.Cells[i + 2, 5] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][4]))); //Add
                diws.Cells[i + 2, 6] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][5]))); //Sphere
                diws.Cells[i + 2, 7] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][6]))); //Cylinder
                diws.Cells[i + 2, 8] = new Cell(dispensedinv.Rows[i][7].ToString()); //Axis
                diws.Cells[i + 2, 9] = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][8]))); //Add
                diws.Cells[i + 2, 10] = new Cell(dispensedinv.Rows[i][9].ToString());
                diws.Cells[i + 2, 11] = new Cell(dispensedinv.Rows[i][10].ToString());
                diws.Cells[i + 2, 12] = new Cell(dispensedinv.Rows[i][11].ToString());
                diws.Cells[i + 2, 13] = new Cell(dispensedinv.Rows[i][12].ToString());
                diws.Cells[i + 2, 14] = new Cell(String.Format("{0:MM/dd/yyyy}", dispensedinv.Rows[i][13])); //Date Added
                diws.Cells[i + 2, 15] = new Cell(String.Format("{0:MM/dd/yyyy}", dispensedinv.Rows[i][14])); //Date Dispensed
                diws.Cells[i + 2, 16] = new Cell(dispensedinv.Rows[i][15].ToString());
            }

            //Add worksheets to the workbook
            wb.Worksheets.Add(ciws);
            wb.Worksheets.Add(diws);
            wb.Worksheets.Add(infows);

            //Save the workbook
            wb.Save(_path);
        }
Esempio n. 9
0
        /// <summary>
        /// Exports the entire contents of a SecondSight database to an excel-compatible spreadsheet file.
        /// This function overwrites the file chosen if it already exists.
        /// </summary>
        /// <param name="_db">The SecondSight database to export</param>
        /// <param name="_path">The full path to the file being created (or overwritten)</param>
        public static void ExportFullDatabase(SSDataBase _db, string _path)
        {
            DataTable currentinv   = new DataTable();
            DataTable dispensedinv = new DataTable();
            DataTable dbinfo       = new DataTable();

            Workbook  wb     = new Workbook();
            Worksheet ciws   = new Worksheet("Current Inventory");
            Worksheet diws   = new Worksheet("Dispensed Inventory");
            Worksheet infows = new Worksheet("Database Information");

            _db.GetTable(currentinv, SSTable.Current);
            _db.GetTable(dispensedinv, SSTable.Dispensed);
            _db.GetTable(dbinfo, SSTable.DBInfo);

            //Populate the Database Information page
            infows.Cells[1, 1] = new Cell("Name");
            infows.Cells[1, 2] = new Cell("Location");
            infows.Cells[1, 3] = new Cell("Date Created");
            infows.Cells[2, 1] = new Cell(dbinfo.Rows[0][0].ToString());
            infows.Cells[2, 2] = new Cell(dbinfo.Rows[0][1].ToString());
            infows.Cells[2, 3] = new Cell(String.Format("{0:MM/dd/yyyy}", dbinfo.Rows[0][2]));

            //Populate the Current Inventory page (headers)
            ciws.Cells[1, 1]  = new Cell("SKU");
            ciws.Cells[1, 2]  = new Cell("OD Sphere");
            ciws.Cells[1, 3]  = new Cell("OD Cylinder");
            ciws.Cells[1, 4]  = new Cell("OD Axis");
            ciws.Cells[1, 5]  = new Cell("OD Add");
            ciws.Cells[1, 6]  = new Cell("OS Sphere");
            ciws.Cells[1, 7]  = new Cell("OS Cylinder");
            ciws.Cells[1, 8]  = new Cell("OS Axis");
            ciws.Cells[1, 9]  = new Cell("OS Add");
            ciws.Cells[1, 10] = new Cell("Type");
            ciws.Cells[1, 11] = new Cell("Gender");
            ciws.Cells[1, 12] = new Cell("Size");
            ciws.Cells[1, 13] = new Cell("Tint");
            ciws.Cells[1, 14] = new Cell("Date Added");
            ciws.Cells[1, 15] = new Cell("Comment");
            int tindex = 0;

            //Populate the Current Inventory page (data)
            for (int i = 0; i < currentinv.Rows.Count; i++)
            {
                tindex = i;
                ciws.Cells[i + 2, 1]  = new Cell(currentinv.Rows[i][0].ToString());
                ciws.Cells[i + 2, 2]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][1]))); //Sphere
                ciws.Cells[i + 2, 3]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][2]))); //Cylinder
                ciws.Cells[i + 2, 4]  = new Cell(currentinv.Rows[i][3].ToString());                                   //Axis
                ciws.Cells[i + 2, 5]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][4]))); //Add
                ciws.Cells[i + 2, 6]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][5]))); //Sphere
                ciws.Cells[i + 2, 7]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][6]))); //Cylinder
                ciws.Cells[i + 2, 8]  = new Cell(currentinv.Rows[i][7].ToString());                                   //Axis
                ciws.Cells[i + 2, 9]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(currentinv.Rows[i][8]))); //Add
                ciws.Cells[i + 2, 10] = new Cell(currentinv.Rows[i][9].ToString());
                ciws.Cells[i + 2, 11] = new Cell(currentinv.Rows[i][10].ToString());
                ciws.Cells[i + 2, 12] = new Cell(currentinv.Rows[i][11].ToString());
                ciws.Cells[i + 2, 13] = new Cell(currentinv.Rows[i][12].ToString());
                ciws.Cells[i + 2, 14] = new Cell(String.Format("{0:MM/dd/yyyy}", currentinv.Rows[i][13])); //Date Added
                ciws.Cells[i + 2, 15] = new Cell(currentinv.Rows[i][14].ToString());
            }

            //Populate the Dispensed Inventory page (headers)
            diws.Cells[1, 1]  = new Cell("SKU");
            diws.Cells[1, 2]  = new Cell("OD Sphere");
            diws.Cells[1, 3]  = new Cell("OD Cylinder");
            diws.Cells[1, 4]  = new Cell("OD Axis");
            diws.Cells[1, 5]  = new Cell("OD Add");
            diws.Cells[1, 6]  = new Cell("OS Sphere");
            diws.Cells[1, 7]  = new Cell("OS Cylinder");
            diws.Cells[1, 8]  = new Cell("OS Axis");
            diws.Cells[1, 9]  = new Cell("OS Add");
            diws.Cells[1, 10] = new Cell("Type");
            diws.Cells[1, 11] = new Cell("Gender");
            diws.Cells[1, 12] = new Cell("Size");
            diws.Cells[1, 13] = new Cell("Tint");
            diws.Cells[1, 14] = new Cell("Date Added");
            diws.Cells[1, 15] = new Cell("Date Dispensed");
            diws.Cells[1, 16] = new Cell("Comment");

            //Populate the Dispensed Inventory page (data)
            for (int i = 0; i < dispensedinv.Rows.Count; i++)
            {
                diws.Cells[i + 2, 1]  = new Cell(dispensedinv.Rows[i][0].ToString());
                diws.Cells[i + 2, 2]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][1]))); //Sphere
                diws.Cells[i + 2, 3]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][2]))); //Cylinder
                diws.Cells[i + 2, 4]  = new Cell(dispensedinv.Rows[i][3].ToString());                                   //Axis
                diws.Cells[i + 2, 5]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][4]))); //Add
                diws.Cells[i + 2, 6]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][5]))); //Sphere
                diws.Cells[i + 2, 7]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][6]))); //Cylinder
                diws.Cells[i + 2, 8]  = new Cell(dispensedinv.Rows[i][7].ToString());                                   //Axis
                diws.Cells[i + 2, 9]  = new Cell(String.Format("{0:0.00}", Convert.ToSingle(dispensedinv.Rows[i][8]))); //Add
                diws.Cells[i + 2, 10] = new Cell(dispensedinv.Rows[i][9].ToString());
                diws.Cells[i + 2, 11] = new Cell(dispensedinv.Rows[i][10].ToString());
                diws.Cells[i + 2, 12] = new Cell(dispensedinv.Rows[i][11].ToString());
                diws.Cells[i + 2, 13] = new Cell(dispensedinv.Rows[i][12].ToString());
                diws.Cells[i + 2, 14] = new Cell(String.Format("{0:MM/dd/yyyy}", dispensedinv.Rows[i][13])); //Date Added
                diws.Cells[i + 2, 15] = new Cell(String.Format("{0:MM/dd/yyyy}", dispensedinv.Rows[i][14])); //Date Dispensed
                diws.Cells[i + 2, 16] = new Cell(dispensedinv.Rows[i][15].ToString());
            }

            //Add worksheets to the workbook
            wb.Worksheets.Add(ciws);
            wb.Worksheets.Add(diws);
            wb.Worksheets.Add(infows);

            //Save the workbook
            wb.Save(_path);
        }
Esempio n. 10
0
        //Click event for Add Databases button
        //Opens an OpenFileDialog for user to browse for merge-able database files,
        //verifies them, and adds them to the list
        private void btn_AddDatabases_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = mvars.defaultDBPath;
            ofd.Title = "Select Databases to Merge";
            ofd.Filter = "SecondSight Partial Databases (*.ssp)|*.ssp|All Files (*.*)|*.*";
            ofd.CheckFileExists = true;
            ofd.Multiselect = true;
            ofd.DefaultExt = ".ssp";

            //Process selected files if user didn't cancel
            if( ofd.ShowDialog() == DialogResult.OK ) {
                string errmsg = ""; //Holds composite error message
                Cursor.Current = Cursors.WaitCursor;

                //For each file selected, open the database, grab the DB info, check DB info against
                //master DB info and exclude if they don't match (display error message after batch processing)
                //check for mergeDB-specific info (the label and the assigned min/max SKUs) and include it in the
                //list box entry if available
                foreach (string fname in ofd.FileNames) {
                    SSDataBase ssdb = new SSDataBase();
                    DataTable dt = new DataTable();
                    string[] info = new string[3];

                    if (fname != mvars.Masterdb.MyPath) {
                        try {
                            ssdb.OpenDB(fname);
                            ssdb.GetTable(dt, SSTable.DBInfo);
                            info[0] = dt.Rows[0][0].ToString();
                            info[1] = dt.Rows[0][1].ToString();
                            info[2] = String.Format("{0:MM/dd/yyyy}", dt.Rows[0][2]);
                        } catch { //An exception will be thrown if something
                            info[0] = info[1] = info[2] = "Unknown";
                        }

                        //If the database info doesn't match, compile an error message,
                        //otherwise include the info in the listbox and mvars
                        if( (info[0] != mvars.Masterdbname) ||
                            (info[1] != mvars.Masterdblocation) ||
                            (info[2] != mvars.Masterdbdate)) {
                            errmsg += System.IO.Path.GetFileName(fname) + ": " + info[0] + " (" + info[1] + "), Created on " + info[2] + "\n";
                        } else {
                            mvars.mergeDBs.Add(ssdb);
                            string ts = info[0] + " (" + info[1] + ")"; //Compile the listbox item string
                            try {
                                dt.Reset();
                                ssdb.GetTable(dt, SSTable.MergeInfo);
                                ts += " - For " + dt.Rows[0][0].ToString() + " - SKU Assignment: " + Convert.ToInt16(dt.Rows[0][1]) +
                                    " to " + Convert.ToInt16(dt.Rows[0][2]);
                            }
                            catch {
                                ts += " - No additional information";
                            }

                            lbox_DatabasesToMerge.Items.Add(ts);
                        }
                        try {ssdb.CloseDB();} catch{} //Attempt to close the current merge database
                    }
                }

                Cursor.Current = Cursors.Default;

                //Display the error message if any databases were excluded
                if(errmsg.Length > 0) {
                    errmsg = "The following files you selected are either not valid SecondSight database files or are " +
                        "SecondSight databases that do not match the master database.\n\n" + errmsg + "\n\nThese files " +
                        "will not be included in the merge.";
                    MessageBox.Show(errmsg, "Some Files Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //else {
                //    MessageBox.Show("The selected databases were successfully merged into the selected master.", "Merge Successful",
                //        MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
            }
        }
Esempio n. 11
0
        //Click event for Select Master button
        //Opens an open file dialog and switches the currently selected master database
        //after verifying the selection is valid.
        private void btn_SelectMaster_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = mvars.defaultDBPath;
            ofd.Title = "Select Master Database";
            ofd.Filter = "SecondSight Databases (*.ssd)|*.ssd|All Files (*.*)|*.*";
            ofd.CheckFileExists = true;
            ofd.Multiselect = false;
            ofd.DefaultExt = ".ssd";

            //Process the open file dialog
            if (ofd.ShowDialog() == DialogResult.OK) {
                SSDataBase ssdbt = new SSDataBase();
                try {
                    ssdbt.OpenDB(ofd.FileName);
                } catch { //Not a valid secondsight database
                    MessageBox.Show("The selected file is not a valid SecondSight database and cannot be used as the master database for a merge.",
                        "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                //Get the info for the new database
                string tname = mvars.Masterdbname;
                string tloc = mvars.Masterdblocation;
                string tdate = mvars.Masterdbdate;
                DataTable dt = new DataTable();
                try {
                    ssdbt.GetTable(dt, SSTable.DBInfo);
                    mvars.Masterdbname = Convert.ToString(dt.Rows[0][0]);
                    mvars.Masterdblocation = Convert.ToString(dt.Rows[0][1]);
                    mvars.Masterdbdate = String.Format("{0:MM/dd/yyyy}", dt.Rows[0][2]);
                } catch {
                    MessageBox.Show("The selected file is not a valid SecondSight database and cannot be used as the master database for a merge.",
                        "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    mvars.Masterdbname = tname;
                    mvars.Masterdblocation = tloc;
                    mvars.Masterdbdate = tdate;
                    return;
                }

                //Close the previously selected master database, switch the pointer to the new one and
                //update the label on the control
                if(mvars.Masterdb.IsOpen()) {
                    try {
                        mvars.Masterdb.CloseDB();
                    } catch {}
                }
                mvars.Masterdb = ssdbt;
                lb_CurrentMaster.Text = "Master Database: " + mvars.Masterdbname + " (" + mvars.Masterdblocation + ")";
            }
        }
Esempio n. 12
0
        //Click event for Select Master button
        //Opens an open file dialog and switches the currently selected master database
        //after verifying the selection is valid.
        private void btn_SelectMaster_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = mvars.defaultDBPath;
            ofd.Title            = "Select Master Database";
            ofd.Filter           = "SecondSight Databases (*.ssd)|*.ssd|All Files (*.*)|*.*";
            ofd.CheckFileExists  = true;
            ofd.Multiselect      = false;
            ofd.DefaultExt       = ".ssd";

            //Process the open file dialog
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                SSDataBase ssdbt = new SSDataBase();
                try
                {
                    ssdbt.OpenDB(ofd.FileName);
                }
                catch
                { //Not a valid secondsight database
                    MessageBox.Show("The selected file is not a valid SecondSight database and cannot be used as the master database for a merge.",
                                    "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                //Get the info for the new database
                string    tname = mvars.Masterdbname;
                string    tloc  = mvars.Masterdblocation;
                string    tdate = mvars.Masterdbdate;
                DataTable dt    = new DataTable();
                try
                {
                    ssdbt.GetTable(dt, SSTable.DBInfo);
                    mvars.Masterdbname     = Convert.ToString(dt.Rows[0][0]);
                    mvars.Masterdblocation = Convert.ToString(dt.Rows[0][1]);
                    mvars.Masterdbdate     = String.Format("{0:MM/dd/yyyy}", dt.Rows[0][2]);
                }
                catch
                {
                    MessageBox.Show("The selected file is not a valid SecondSight database and cannot be used as the master database for a merge.",
                                    "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    mvars.Masterdbname     = tname;
                    mvars.Masterdblocation = tloc;
                    mvars.Masterdbdate     = tdate;
                    return;
                }

                //Close the previously selected master database, switch the pointer to the new one and
                //update the label on the control
                if (mvars.Masterdb.IsOpen())
                {
                    try
                    {
                        mvars.Masterdb.CloseDB();
                    }
                    catch { }
                }
                mvars.Masterdb        = ssdbt;
                lb_CurrentMaster.Text = "Master Database: " + mvars.Masterdbname + " (" + mvars.Masterdblocation + ")";
            }
        }
Esempio n. 13
0
        //Click event for Add Databases button
        //Opens an OpenFileDialog for user to browse for merge-able database files,
        //verifies them, and adds them to the list
        private void btn_AddDatabases_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = mvars.defaultDBPath;
            ofd.Title            = "Select Databases to Merge";
            ofd.Filter           = "SecondSight Partial Databases (*.ssp)|*.ssp|All Files (*.*)|*.*";
            ofd.CheckFileExists  = true;
            ofd.Multiselect      = true;
            ofd.DefaultExt       = ".ssp";

            //Process selected files if user didn't cancel
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string errmsg = ""; //Holds composite error message
                Cursor.Current = Cursors.WaitCursor;

                //For each file selected, open the database, grab the DB info, check DB info against
                //master DB info and exclude if they don't match (display error message after batch processing)
                //check for mergeDB-specific info (the label and the assigned min/max SKUs) and include it in the
                //list box entry if available
                foreach (string fname in ofd.FileNames)
                {
                    SSDataBase ssdb = new SSDataBase();
                    DataTable  dt   = new DataTable();
                    string[]   info = new string[3];

                    if (fname != mvars.Masterdb.MyPath)
                    {
                        try
                        {
                            ssdb.OpenDB(fname);
                            ssdb.GetTable(dt, SSTable.DBInfo);
                            info[0] = dt.Rows[0][0].ToString();
                            info[1] = dt.Rows[0][1].ToString();
                            info[2] = String.Format("{0:MM/dd/yyyy}", dt.Rows[0][2]);
                        }
                        catch
                        { //An exception will be thrown if something
                            info[0] = info[1] = info[2] = "Unknown";
                        }

                        //If the database info doesn't match, compile an error message,
                        //otherwise include the info in the listbox and mvars
                        if ((info[0] != mvars.Masterdbname) ||
                            (info[1] != mvars.Masterdblocation) ||
                            (info[2] != mvars.Masterdbdate))
                        {
                            errmsg += System.IO.Path.GetFileName(fname) + ": " + info[0] + " (" + info[1] + "), Created on " + info[2] + "\n";
                        }
                        else
                        {
                            mvars.mergeDBs.Add(ssdb);
                            string ts = info[0] + " (" + info[1] + ")"; //Compile the listbox item string
                            try
                            {
                                dt.Reset();
                                ssdb.GetTable(dt, SSTable.MergeInfo);
                                ts += " - For " + dt.Rows[0][0].ToString() + " - SKU Assignment: " + Convert.ToInt16(dt.Rows[0][1]) +
                                      " to " + Convert.ToInt16(dt.Rows[0][2]);
                            }
                            catch
                            {
                                ts += " - No additional information";
                            }

                            lbox_DatabasesToMerge.Items.Add(ts);
                        }
                        try
                        { ssdb.CloseDB(); }
                        catch { } //Attempt to close the current merge database
                    }
                }

                Cursor.Current = Cursors.Default;

                //Display the error message if any databases were excluded
                if (errmsg.Length > 0)
                {
                    errmsg = "The following files you selected are either not valid SecondSight database files or are " +
                             "SecondSight databases that do not match the master database.\n\n" + errmsg + "\n\nThese files " +
                             "will not be included in the merge.";
                    MessageBox.Show(errmsg, "Some Files Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //else {
                //    MessageBox.Show("The selected databases were successfully merged into the selected master.", "Merge Successful",
                //        MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
            }
        }