private void btnok_Click(object sender, EventArgs e) { try { PublicClass.a = 0; bCancel = false; if (!string.IsNullOrEmpty(textBox2.Text.ToString())) { if (!string.IsNullOrEmpty(txtdb.Text.ToString())) { sPathtosave = textBox2.Text.ToString(); sDB = txtdb.Text.ToString(); frmNewDataBaseCreation objDBCreate = new frmNewDataBaseCreation(); if (PublicClass.ValidateDatabase(sDB)) { SplashScreenManager.ShowForm(typeof(WaitForm2)); st = objDBCreate.CreateDataBase(Convert.ToString(sDB).Trim(), st); } else { MessageBox.Show(this, "Only alphanumeric characters may be used in Database Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); txtdb.Text = ""; return; } if (st) { if (PublicClass.currentInstrument == "Kohtect-C911") { try { clsC911 clsdb = new clsC911(); clsdb.PCPath = textBox2.Text; string routefile = null; string areaname = null; string trainname = null; string machinename = null; string pointname = null; if (rbfolder.Checked == true) { string name = "DefaultPlant"; clsdb.InsertItemsInDataBase("Plant", null, name + "|" + "Plant"); string[] dirs = Directory.GetDirectories(sPathtosave); for (int i = 0; i < dirs.Length; i++) { string area = dirs[i]; if (area != null) { string[] split = area.Split(new char[] { '\\' }); areaname = split[7]; DataTable dt = DbClass.getdata(CommandType.Text, "select * from area_info"); if (dt.Rows.Count > 0) { clsdb.facid = Convert.ToString(dt.Rows[0]["Area_ID"]); } clsdb.InsertItemsInDataBase("Area", clsdb.facid, areaname + "|" + "Area"); } string[] dirs1 = Directory.GetDirectories(area); for (int a = 0; a < dirs1.Length; a++) { string train = dirs1[a]; if (train != null) { string[] split = train.Split(new char[] { '\\' }); trainname = split[8]; clsdb.InsertItemsInDataBase("Train", clsdb.facid, trainname + "|" + "Train"); } string[] dirs2 = Directory.GetDirectories(train); for (int t = 0; t < dirs2.Length; t++) { string Mach = dirs2[t]; if (Mach != null) { string[] split = Mach.Split(new char[] { '\\' }); machinename = split[9]; clsdb.InsertItemsInDataBase("Machine", clsdb.facid, machinename + "|" + "Machine"); } //string[] dirs3 = Directory.GetDirectories(Mach); //t++; //--------creating hirerchy-------// // clsdb.datatransfer(sDB, areaname, trainname, machinename, routefile); } //a++; } // i++; } } else { clsdb.datatransfer(sDB, textBox2.Text); } } catch { } } else { ClsSdftodb clsdb = new ClsSdftodb(); clsdb.PCPath = sPathtosave; clsdb.alltransfer(sDB); } SplashScreenManager.CloseForm(); this.Close(); } else { txtdb.Text = string.Empty; SplashScreenManager.CloseForm(); } } else { MessageBox.Show(this, "Please Fill Database Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(this, "Select any .SDF file", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { SplashScreenManager.CloseForm(); } }
private void btnok_Click(object sender, EventArgs e) { try { bCancel = false; if (PublicClass.currentInstrument == "SKF/DI") { if (rbPhysicalDimensions.Checked == true) { if (!string.IsNullOrEmpty(listDB.Text.ToString())) { if (!string.IsNullOrEmpty(txtdb.Text.ToString())) { sPathtosave = listDB.Text.ToString(); sDB = txtdb.Text.ToString(); frmNewDataBaseCreation objDBCreate = new frmNewDataBaseCreation(); if (PublicClass.ValidateDatabase(sDB)) { SplashScreenManager.ShowForm(typeof(WaitForm2)); st = objDBCreate.CreateDataBase(Convert.ToString(sDB).Trim(), st); } else { MessageBox.Show(this, "Only alphanumeric characters used for Database Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); txtdb.Text = ""; return; } if (st) { try { _objgenDi.PCPath = sPathtosave; _objgenDi.Directdownload(sDB, listDB.SelectedIndex); if (_objgenDi.checkbool == "false") { DbClass.executequery(CommandType.Text, "Select Database_name as SCHEMA_NAME from route.databasename where InstrumentName='" + PublicClass.currentInstrument + "' && Database_name!='" + sDB + "'"); Status.Text = "Connection Error.."; MessageBox.Show(this, "Connection Error..Connect Device Properly", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); _objgenDi.m_objSerialPort.Write("\x06"); _objgenDi.m_objSerialPort.Write("\x04"); _objgenDi.m_objSerialPort.Close(); SplashScreenManager.CloseForm(); return; } else { if (_objgenDi.m_objSerialPort.IsOpen == true) { _objgenDi.m_objSerialPort.Write("\x06"); _objgenDi.m_objSerialPort.Write("\x04"); _objgenDi.m_objSerialPort.Close(); SplashScreenManager.CloseForm(); } this.Close(); } } catch { } } else { txtdb.Text = string.Empty; SplashScreenManager.CloseForm(); } } else { Status.Text = "Please Fill Database Name"; MessageBox.Show(this, "Please Fill Database Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { Status.Text = "Select any Database Route Name"; MessageBox.Show(this, "Select any Database Route Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (!string.IsNullOrEmpty(txtdbpath.Text.ToString())) { if (!string.IsNullOrEmpty(txtdb.Text.ToString())) { sDB = txtdb.Text.ToString(); frmNewDataBaseCreation objDBCreate = new frmNewDataBaseCreation(); if (PublicClass.ValidateDatabase(sDB)) { SplashScreenManager.ShowForm(typeof(WaitForm2)); st = objDBCreate.CreateDataBase(Convert.ToString(sDB).Trim(), st); } else { MessageBox.Show(this, "Only alphanumeric characters may be used in Database Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); txtdb.Text = ""; return; } if (st) { _objgenDi.GenerateNewRouteFromFile(spath); bCancel = false; this.Close(); } } else { Status.Text = "Fill Database Name"; MessageBox.Show(this, "Please Fill Database Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { Status.Text = "Select any .DAT file"; MessageBox.Show(this, "Select any .DAT file", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch { } }