private void btnBrowse_Click(object sender, EventArgs e) { try { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { txtFolderPath.Text = folderBrowserDialog1.SelectedPath; } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
public static bool DeleteRecordFromSDFile(string _infilename, int _recindex) { bool blStatus = false; try { int intRecIndex = 0; MolInputStream molInStream = new MolInputStream(new FileInputStream(_infilename)); MolImporter molImp = new MolImporter(molInStream); string strInputFilePath = System.IO.Path.GetDirectoryName(_infilename); string strExecPath = Application.StartupPath; string strFileName = System.IO.Path.GetFileName(_infilename); string strOutFile = strExecPath + "\\" + strFileName; DataOutputStream dOutStream = new DataOutputStream(new FileOutputStream(strOutFile)); MolExporter mExpt = new MolExporter(dOutStream, "sdf"); Molecule objMol = new Molecule(); while (molImp.read(objMol)) { intRecIndex++; if (intRecIndex != _recindex) { mExpt.write(objMol); } } molImp.close(); molInStream.close(); mExpt.close(); dOutStream.close(); System.IO.File.Copy(strOutFile, _infilename, true); System.IO.File.Delete(strOutFile); blStatus = true; } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(blStatus); }
private void btnPrev_Click(object sender, EventArgs e) { try { if (currRecIndex <= MaxRecCnt && currRecIndex > 1) { currRecIndex = (currRecIndex - 1); } numGoToRec.Value = currRecIndex; } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private bool ValidateUserInputs_TableLevel(out string _errmsg) { bool blStatus = false; string strErrMsg = ""; try { if (chemRenditor.MolfileString != null) { //Validate R-Group Columns here if (ValidateDrawnAndDefinedRGroups(out strErrMsg)) { if (rtxtOCRData.Text.Trim() != "") { if (txtIdentifier.Text.Trim() != "") { if (txtRGroups.Text.Trim() != "") { blStatus = true; } else { strErrMsg = "Please specify R-Groups"; } } else { strErrMsg = "Please specify Identifier"; } } else { strErrMsg = "No data is available to convert into a table"; } } } else { strErrMsg = "Please draw R-Core"; } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } _errmsg = strErrMsg; return(blStatus); }
public static DataTable ConvertChemicalNameToSMILES_JChem(DataTable _chemnamestbl) { DataTable dtSmiles = null; try { if (_chemnamestbl != null) { if (_chemnamestbl.Rows.Count > 0) { dtSmiles = _chemnamestbl.Copy(); MolHandler molHandler = null; Molecule molObj = null; string strSMILES = ""; for (int rowindex = 0; rowindex < dtSmiles.Rows.Count; rowindex++) { for (int colindex = 1; colindex < dtSmiles.Columns.Count; colindex++) { try { molHandler = new MolHandler(dtSmiles.Rows[rowindex][colindex].ToString()); molObj = molHandler.getMolecule(); strSMILES = molObj.toFormat("smiles:u"); } catch { strSMILES = ""; } if (strSMILES == "") { strSMILES = ""; } dtSmiles.Rows[rowindex][colindex] = strSMILES; } } dtSmiles.AcceptChanges(); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(dtSmiles); }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { try { if (dtGridSmiles.SelectedCells.Count > 0) { if (dtGridSmiles.SelectedCells[0].Value != null) { Clipboard.SetText(dtGridSmiles.SelectedCells[0].Value.ToString(), TextDataFormat.Text); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void chemRenditor_DoubleClick(object sender, EventArgs e) { try { if (chemRenditor.MolfileString != null) { chemaxon.util.MolHandler molHandler = new MolHandler(chemRenditor.MolfileString); Molecule molObj = molHandler.getMolecule(); strInchi_Before = molObj.toFormat("inchi:key"); strInchi_Before = Validations.GetInchiKeyFromInchiString(strInchi_Before); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
public static RgMolecule ReturnRGroupMolecule(string _rgrpSmiles, int _rgrpNum) { try { MolHandler mHandler = new MolHandler(_rgrpSmiles); Molecule objMol = mHandler.getMolecule(); RgMolecule rgMol = new RgMolecule(); MolAtom mAtom = new MolAtom(MolAtom.RGROUP, 1, 0, 0); mAtom.setRgroup(_rgrpNum); rgMol.add(mAtom); int radNum = 0; for (int i = 0; i < objMol.getAtomCount(); i++) { if (objMol.getRadical(i) > 0) { radNum = i; } } for (int i = 0; i < objMol.getAtomCount(); i++) { if (i == 0) { objMol.getAtom(radNum).setRadical(MolAtom.RAD_OFF); } rgMol.add(objMol.getAtom(i)); } for (int j = 0; j < objMol.getBondCount(); j++) { rgMol.add(objMol.getBond(j)); } rgMol.add(new MolBond(objMol.getAtom(radNum), mAtom)); rgMol.clean(2, null, null); return(rgMol); } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(null); }
private void btnADD_Click(object sender, EventArgs e) { try { if (txtTANNo.Text.Trim() != "") { if (txtPageNo.Text.Trim() != "") { if (Validations.IsValidTanNumber(txtTANNo.Text.Trim())) { Cursor = Cursors.WaitCursor; string strErrMsg_out = ""; if (InsertStructureDetailsInDB(out strErrMsg_out)) { Cursor = Cursors.Default; MessageBox.Show("Records inserted to database successfully"); } else { Cursor = Cursors.Default; MessageBox.Show(strErrMsg_out); } } else { MessageBox.Show("Not a Valid TAN number\r\nTAN format is 12345678A"); } } else { MessageBox.Show("Please enter page number"); } } else { MessageBox.Show("Please enter TAN number"); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void btnRemOne_Click(object sender, EventArgs e) { try { if (lstSelTANs.SelectedItem != null) { DeleteItem(lstSelTANs.SelectedItem.ToString()); lstAvailTANs.DataSource = null; lstAvailTANs.DataSource = availList; lstSelTANs.DataSource = null; lstSelTANs.DataSource = selList; } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
public string GetOCRDataFromBMP(Bitmap _bmp) { string strOutput = ""; try { //string strFilePath = @"C:\Sample.bmp"; //Bitmap bmp = new Bitmap(_bmp); //new Bitmap(strFilePath,true); //bmp.Save(@"C:\Sample.bmp"); //Bitmap bmp = new Bitmap(strFilePath); string output = GetOCRfromBMP(_bmp); return(output); } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(strOutput); }
private void btnNext_Click(object sender, EventArgs e) { try { if (currRecIndex < MaxRecCnt) { currRecIndex = currRecIndex + 1; } else if (currRecIndex == MaxRecCnt) { currRecIndex = MaxRecCnt; } numGoToRec.Value = currRecIndex; } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void btnCreate_Click(object sender, EventArgs e) { try { if (txtUserName.Text.Trim() != "") { if (txtPassword.Text.Trim() != "") { //Check for dupliate user here if (!PepsiLiteDataAccess.DataOperations.CheckForDuplicateUser(txtUserName.Text.Trim(), cmbUserRoles.SelectedItem.ToString())) { //if not duplicate then insert into database if (PepsiLiteDataAccess.DataOperations.InsertNewUserDetails(txtUserName.Text.Trim(), txtPassword.Text.Trim(), cmbUserRoles.SelectedItem.ToString(), DateTime.Now)) { //refresh usertable in the grid DataTable dtUserDetails = PepsiLiteDataAccess.DataOperations.RetrieveUserDetails(); if (dtUserDetails != null) { if (dtUserDetails.Rows.Count > 0) { dtGrid_Users.DataSource = dtUserDetails; } } } } } else { MessageBox.Show("Please enter password"); } } else { MessageBox.Show("Please enter user name"); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private bool ReadMoleculeFromTable(int recindex) { bool blStatus = false; try { if (MolDataTbl != null) { if (MolDataTbl.Rows.Count > 0 && (recindex < MolDataTbl.Rows.Count)) { chemRenditor.MolfileString = MolDataTbl.Rows[recindex]["Structure"].ToString(); if (MolDataTbl.Rows[recindex]["IsChiral"].ToString() == "True") { lblChiral.Visible = true; } else { lblChiral.Visible = false; } txtMolFormula.Text = MolDataTbl.Rows[recindex]["MolFormula"].ToString(); txtMolWeight.Text = MolDataTbl.Rows[recindex]["MolWeight"].ToString(); txtIUPACName.Text = MolDataTbl.Rows[recindex]["IupacName"].ToString(); txtPageNo.Text = MolDataTbl.Rows[recindex]["PageNumber"].ToString(); txtPageLabel.Text = MolDataTbl.Rows[recindex]["PageLabel"].ToString(); txtExampleNo.Text = MolDataTbl.Rows[recindex]["ExampleNumber"].ToString(); txten_Name.Text = MolDataTbl.Rows[recindex]["EnName"].ToString(); txtMolFileNo.Text = (recindex + 1).ToString(); blStatus = true; return(blStatus); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(blStatus); }
private bool ReadMoleculeFromTable(int recindex) { bool blStatus = false; try { if (SearchResults != null) { if (SearchResults.Rows.Count > 0 && (recindex < SearchResults.Rows.Count)) { chemRenditor_Trgt.MolfileString = SearchResults.Rows[recindex]["Structure"].ToString(); //if (SearchResults.Rows[recindex]["IsChiral"].ToString() == "True") //{ // lblChiral.Visible = true; //} //else //{ // lblChiral.Visible = false; //} // txtMolFormula.Text = SearchResults.Rows[recindex]["MolFormula"].ToString(); // txtMolWeight.Text = SearchResults.Rows[recindex]["MolWeight"].ToString(); txtIUPACName.Text = SearchResults.Rows[recindex]["iupac_name"].ToString(); txtPageNo.Text = SearchResults.Rows[recindex]["page_number"].ToString(); txtPageLabel.Text = SearchResults.Rows[recindex]["page_label"].ToString(); txtExampleNo.Text = SearchResults.Rows[recindex]["example_number"].ToString(); txten_Name.Text = SearchResults.Rows[recindex]["en_name"].ToString(); txtTableNo.Text = (recindex + 1).ToString(); blStatus = true; return(blStatus); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(blStatus); }
private static int GetRadicalPosition(RgMolecule _rgMol) { int radPos = 0; try { for (int k = 0; k < _rgMol.getAtomCount(); k++) { if (_rgMol.getAtom(k).getRadical() > 0) { radPos = k; } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(radPos); }
private void frmCreateUser_Load(object sender, EventArgs e) { try { cmbUserRoles.SelectedIndex = 0; DataTable dtUserDetails = PepsiLiteDataAccess.DataOperations.RetrieveUserDetails(); if (dtUserDetails != null) { if (dtUserDetails.Rows.Count > 0) { dtGrid_Users.DataSource = dtUserDetails; } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private static int GetRGroupPosition(Molecule _coreMol, int _rgrpNum) { int rgroupPos = 0; try { for (int j = 0; j < _coreMol.getAtomCount(); j++) { if (_coreMol.getAtom(j).getRgroup() == _rgrpNum) { rgroupPos = j; } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(rgroupPos); }
private void ucCheckDuplicates_Load(object sender, EventArgs e) { try { GetTANIds_AssignToTANTxtBox_AutoComplete(); cmbMolFormula.SelectedIndex = 0; cmbMolWeight.SelectedIndex = 0; cmbPageNum.SelectedIndex = 0; cmbPageLabel.SelectedIndex = 0; cmbExampleNo.SelectedIndex = 0; cmbTableNo.SelectedIndex = 0; cmbIUPACName.SelectedIndex = 0; cmbEnName.SelectedIndex = 0; } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { try { object objClipData = Clipboard.GetData(DataFormats.Text); if (objClipData != null) { if (dtGridSmiles.SelectedCells.Count > 0) { for (int i = 0; i < dtGridSmiles.SelectedCells.Count; i++) { dtGridSmiles.SelectedCells[i].Value = objClipData; } } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private int GetMainRecordIndex(int displayindex) { int mainIndex = 0; try { if (SearchResults != null) { if (SearchResults.Rows.Count > 0) { mainIndex = Convert.ToInt16(SearchResults.Rows[displayindex]["tan_dtl_id"]); return(mainIndex); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(mainIndex); }
private void btnRemAll_Click(object sender, EventArgs e) { try { if (lstSelTANs.Items.Count > 0) { for (int i = 0; i < lstSelTANs.Items.Count; i++) { DeleteItem(lstSelTANs.Items[i].ToString()); } lstAvailTANs.DataSource = null; lstAvailTANs.DataSource = availList; lstSelTANs.DataSource = null; lstSelTANs.DataSource = selList; } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void btnExport_Click(object sender, EventArgs e) { try { if (txtFolderPath.Text != "") { FolderPath = txtFolderPath.Text; SelectedProps = selList; this.Close(); } else { MessageBox.Show("Please specify the path"); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void ClearUserInputs() { try { chemRenditor.MolfileString = ""; txtIUPACName.Text = ""; txtPageNo.Text = ""; txtPageLabel.Text = "00"; txtExampleNo.Text = "00"; txtMolFormula.Text = ""; txtMolWeight.Text = ""; txtMolFileNo.Text = ""; txten_Name.Text = ""; } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void chemRenditor_Results_StructureChanged(object sender, EventArgs e) { try { if (chemRenditor_Results.MolfileString != null) { chemaxon.util.MolHandler molHandler = new MolHandler(chemRenditor_Results.MolfileString); Molecule molObj = molHandler.getMolecule(); txtMolWeight.Text = molObj.getMass().ToString(); txtMolFormula.Text = molObj.getFormula(); string strMolfile = molObj.toFormat("mol"); string strIUPACName = ""; string strErrMsg = ""; if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg)) { strIUPACName = Validations.GetConvertedIUPACName(strIUPACName); } else { strIUPACName = "IUPAC name not provided"; } txtIUPACName.Text = strIUPACName; if (molObj.isAbsStereo()) { lblChiral.Visible = true; } else { lblChiral.Visible = false; } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void btnLogin_Click(object sender, EventArgs e) { try { if (txtUserName.Text.Trim() != "") { if (txtPassword.Text.Trim() != "") { int userID = 0; if (PepsiLiteDataAccess.DataOperations.CheckForValidUser(txtUserName.Text.Trim(), txtPassword.Text.Trim(), cmbUserRoles.SelectedItem.ToString(), out userID)) { Classes.Generic_PepsiLite.UserID = userID; Classes.Generic_PepsiLite.UserName = txtUserName.Text.Trim(); Classes.Generic_PepsiLite.UserRole = cmbUserRoles.SelectedItem.ToString(); UserRole = cmbUserRoles.SelectedItem.ToString(); SubmitClick = true; this.Close(); } else { MessageBox.Show("Login Failed", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter password", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter user name", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void btnAdd_Click(object sender, EventArgs e) { try { string strErrmsg = ""; if (ValidateUserInputs(out strErrmsg)) { string strCompname = txtCompName.Text.Trim(); string strSmiles = txtSmiles.Text.Trim(); int userID = Classes.Generic_PepsiLite.UserID; //Check for duplicate before inserting in database if (!PepsiLiteDataAccess.DataOperations.CheckForDuplicateCompName(strCompname)) { if (PepsiLiteDataAccess.DataOperations.InsertDictionaryDetails(strCompname, strSmiles, DateTime.Now, userID)) { MessageBox.Show("Added to dictionary successfully", "Add to Dictionary", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error in adding", "Add to Dictionary", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Record already exist", "Add to Dictionary", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(strErrmsg, "Invalid user inputs", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
private void frmSelectTAN_Xml_Load(object sender, EventArgs e) { try { if (AvailTANs != null) { if (AvailTANs.Count > 0) { for (int i = 0; i < AvailTANs.Count; i++) { lstAvailTANs.Items.Add(AvailTANs[i].ToString()); } availList = AvailTANs; } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
public bool ReadMoleculeFromTable(int recindex) { bool blStatus = false; try { if (EnumResultsTbl != null && recindex >= 0) { if (EnumResultsTbl.Rows.Count > 0 && (recindex < EnumResultsTbl.Rows.Count)) { if (EnumResultsTbl.Rows[recindex]["structure"].ToString() != "") { chemRenditor_Results.MolfileString = EnumResultsTbl.Rows[recindex]["structure"].ToString(); txtMolFileNo.Text = (recindex + 1).ToString(); txtID.Text = EnumResultsTbl.Rows[recindex][0].ToString(); blStatus = true; return(blStatus); } else { chemRenditor_Results.MolfileString = ""; txtIUPACName.Text = ""; txtMolFormula.Text = ""; txtMolWeight.Text = ""; txtID.Text = EnumResultsTbl.Rows[recindex][0].ToString(); } } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(blStatus); }
private void getSmilesToolStripMenuItem_Click(object sender, EventArgs e) { try { if (dtGridSmiles.SelectedCells.Count == 1) { string strCompName = dtGridSmiles.SelectedCells[0].Value.ToString(); string strSmiles = PepsiLiteDataAccess.DataOperations.RetrieveDictSmilesOnCompName(strCompName); if (strSmiles != "") { dtGridSmiles.SelectedCells[0].Value = strSmiles; } else { MessageBox.Show("No record found", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }