Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strErrMsg = "";
                if (ValidatePaticipantControls(ref strErrMsg))
                {
                    if (PaticipantData == null)
                    {
                        PaticipantData = new ParticipantInfo();
                    }

                    PaticipantData.ParticipantName = txtName.Text;
                    PaticipantData.StructureNo     = txtStructNo.Text;
                    PaticipantData.Grade           = txtGrade.Text;
                    PaticipantData.ParticipantType = (string)cmbType.SelectedItem;
                    PaticipantData.Structure       = ChemRenditor.MolfileString;
                    PaticipantData.StructureImage  = (object)ChemRenditor.Image;
                    PaticipantData.InchiKey        = Convert.ToString(ChemistryOperations.GetStructureInchiKey(ChemRenditor.MolfileString));

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(strErrMsg.Trim(), GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void chemRenditor_Results_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                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;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
 private void ChemRenditor_ComStructureChanged()
 {
     try
     {
         if (!string.IsNullOrEmpty(ChemRenditor.MolfileString))
         {
             lblStructureInchi.Text = ChemistryOperations.GetStructureInchiKey(ChemRenditor.MolfileString);
         }
         else
         {
             lblStructureInchi.Text = "";
         }
     }
     catch (Exception ex)
     {
         ErrorHandling.WriteErrorLog(ex.Message);
     }
 }
Ejemplo n.º 4
0
        private void chemRenditor_Trgt_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                if (chemRenditor_Trgt.MolfileString != null)
                {
                    MolHandler molHandler1 = new MolHandler(chemRenditor_Trgt.MolfileString);
                    Molecule   molObj1     = molHandler1.getMolecule();

                    txtMolWeight.Text  = "";
                    txtMolFormula.Text = "";

                    txtMolWeight.Text  = molObj1.getMass().ToString();
                    txtMolFormula.Text = molObj1.getFormula();

                    if (molObj1.isAbsStereo())
                    {
                        lblChiral.Visible = true;
                    }
                    else
                    {
                        lblChiral.Visible = false;
                    }

                    string strMolfile   = molObj1.toFormat("mol");
                    string strIUPACName = "";
                    string strErrMsg    = "";
                    if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                    {
                        //strIUPACName = Validations.RemoveSMILESFromIUPACName(strIUPACName);
                        strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                    }
                    else
                    {
                        strIUPACName = "IUPAC name not provided";
                    }
                    txtIUPACName.Text = strIUPACName;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strErrMsg = "";
                if (ValidateProductControls(ref strErrMsg))
                {
                    ProductData             = new ProductInfo();
                    ProductData.ProductName = txtProductName.Text.Trim();
                    ProductData.StructureNo = txtStructNo.Text.Trim();
                    if (!string.IsNullOrEmpty(txtYieldFrom.Text.Trim()) && !string.IsNullOrEmpty(txtYieldTo.Text.Trim()))
                    {
                        ProductData.Yield = txtYieldFrom.Text.Trim() + " to " + txtYieldTo.Text.Trim();
                    }
                    else
                    {
                        ProductData.Yield = txtYieldFrom.Text.Trim();
                    }

                    if (!string.IsNullOrEmpty(ChemRenditor.MolfileString))
                    {
                        ProductData.Structure      = ChemRenditor.MolfileString;
                        ProductData.StructureImage = (object)ChemRenditor.Image;
                    }
                    ProductData.CS           = txtCS.Text.Trim();
                    ProductData.DS           = txtDS.Text.Trim();
                    ProductData.DE           = txtDe.Text.Trim();
                    ProductData.EE           = txtEE.Text.Trim();
                    ProductData.ProductGrade = txtGrade.Text.Trim();
                    ProductData.InchiKey     = ChemistryOperations.GetStructureInchiKey(ChemRenditor.MolfileString);

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(strErrMsg.Trim(), GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 6
0
 private void renderer1_StructureChanged(object sender, EventArgs e)
 {
     try
     {
         if (chkSrchByStruct.Checked)
         {
             string    inchi      = ChemistryOperations.GetStructureInchiKey(renderer1.MolfileString);
             DataTable dtFiltered = GetFilteredData(inchi, "INCHI");
             BindReferenceToGrid(dtFiltered);
         }
         //else
         //{
         //    BindReferenceToGrid(GlobalVariables.SolAgentMaster);
         //}
     }
     catch (Exception ex)
     {
         ErrorHandling.WriteErrorLog(ex.Message);
     }
 }
Ejemplo n.º 7
0
        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());
            }
        }
Ejemplo n.º 8
0
        private void GetDuplicateStructures(string filename, string molfile)
        {
            try
            {
                // txtTANNo.Text = strTANNumber;

                int       totalRecCnt = 0;
                DataTable dtDupRecs   = ChemistryOperations.GetDuplicateRecords(filename, molfile, out totalRecCnt);
                if (dtDupRecs != null)
                {
                    if (dtDupRecs.Rows.Count > 1)
                    {
                        pnlDups.Enabled = true;

                        SearchResults  = dtDupRecs;
                        lblRecCnt.Text = dtDupRecs.Rows.Count.ToString() + " duplicates out of  " + totalRecCnt + "  records";

                        ToTalRecCnt = totalRecCnt;

                        MaxRecCnt = dtDupRecs.Rows.Count;

                        currRecIndex = 1;

                        numGoToRec.Value   = 1;
                        numGoToRec.Minimum = 1;
                        numGoToRec.Maximum = MaxRecCnt;
                        numGoToRec.Value   = currRecIndex;
                    }
                    else
                    {
                        MessageBox.Show("No duplicate records found", "No Duplicates", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 9
0
        private void ChemRenditor_ComStructureChanged()
        {
            try
            {
                if (!string.IsNullOrEmpty(ChemRenditor.MolfileString))
                {
                    string strMolFormula = "";
                    txtMolWeight.Text  = ChemistryOperations.GetMoleculeWeightAndMolFormula(ChemRenditor.MolfileString, out strMolFormula);
                    txtMolFormula.Text = strMolFormula;

                    //string strIUPACName = "";
                    //string strErrMsg = "";
                    //if (ChemistryOperations.GetIUPACNameFromStructure(ChemRenditor.MolfileString, out strIUPACName, out strErrMsg))
                    //{
                    //    txtIUPAC.Text = strIUPACName;
                    //}
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 10
0
        public CompoundInfo GetCompoundInformation()
        {
            CompoundInfo objCompInfo = null;

            try
            {
                objCompInfo               = new CompoundInfo();
                objCompInfo.Compound      = ChemRenditor.MolfileString;
                objCompInfo.CompoundNo    = txtCompNo.Text.Trim();
                objCompInfo.CompoundLabel = txtCompLabel.Text.Trim();
                objCompInfo.MolFormula    = txtMolFormula.Text.Trim();
                objCompInfo.MolWeight     = txtMolWeight.Text.Trim();
                objCompInfo.IUPACName     = txtIUPAC.Text.Trim();
                objCompInfo.PageNo        = txtPageLabel.Text.Trim();
                objCompInfo.Synonyms      = txtSynonyms.Text.Trim();
                objCompInfo.InchiKey      = ChemistryOperations.GetStructureInchiKey(ChemRenditor.MolfileString);
                objCompInfo.Comments      = txtComments.Text.Trim();
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
            return(objCompInfo);
        }
Ejemplo n.º 11
0
        private void GetStructureFromImage()
        {
            try
            {
                IDataObject clipData = Clipboard.GetDataObject();
                if (clipData.GetDataPresent(DataFormats.Bitmap))
                {
                    Cursor = Cursors.WaitCursor;

                    Image imgChemistry = Clipboard.GetImage();

                    string strMol_out     = "";
                    bool   blIsChiral_out = false;
                    string strErrMsg_out  = "";

                    if (ImageToStructure.GetStructureFromImage(imgChemistry, out strMol_out, out blIsChiral_out, out strErrMsg_out))
                    {
                        ChemRenditor.MolfileString = strMol_out;

                        try
                        {
                            chemaxon.util.MolHandler molHandler_Trgt = new MolHandler(ChemRenditor.MolfileString);
                            Molecule molObj = molHandler_Trgt.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 = ChemistryOperations.RemoveSMILESFromIUPACName(strIUPACName);
                                strIUPACName = ChemistryOperations.GetConvertedIUPACName(strIUPACName);
                            }
                            else
                            {
                                strIUPACName = "IUPAC name not provided";
                            }
                        }
                        catch
                        {
                        }

                        //if (molObj.isAbsStereo())
                        //{
                        //    lblChiral.Visible = true;
                        //}
                        //else
                        //{
                        //    lblChiral.Visible = false;
                        //}


                        //txtIUPACName.Text = strIUPACName;

                        Cursor = Cursors.Default;
                    }
                    else
                    {
                        Cursor = Cursors.Default;
                        MessageBox.Show(strErrMsg_out);
                    }

                    Clipboard.Clear();
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
            Cursor = Cursors.Default;
        }
Ejemplo n.º 12
0
        private bool InsertStructureDetailsInDB(out string _errMsg)
        {
            string strErrMsg = "";

            try
            {
                if (EnumResultsTbl != null)
                {
                    if (EnumResultsTbl.Rows.Count > 0)
                    {
                        int intPageNo = Convert.ToInt32(txtPageNo.Text.Trim());

                        string strTanNumber  = txtTANNo.Text.Trim();
                        string strMolString  = "";
                        string strMolFormula = "";
                        double dblMolWeight  = 0.0;
                        string strIUPACName  = "";
                        string strInchiKey   = "";
                        string strEnName     = "";
                        string strIdentifier = "";

                        string strPageLabel = txtPageLabel.Text.Trim();
                        string strExampleNo = txtExampleNo.Text.Trim();
                        string strTableNo   = txtTableNo.Text.Trim();

                        int userID = Classes.Generic_PepsiLite.UserID;

                        bool blVerified    = false;
                        int  tanDtl_Id_out = 0;

                        int intCntr = 0;

                        for (int i = 0; i < EnumResultsTbl.Rows.Count; i++)
                        {
                            strMolString  = EnumResultsTbl.Rows[i]["structure"].ToString();
                            strMolFormula = EnumResultsTbl.Rows[i]["mol_formula"].ToString();
                            Double.TryParse(EnumResultsTbl.Rows[i]["mol_weight"].ToString(), out dblMolWeight);

                            strIUPACName  = EnumResultsTbl.Rows[i]["iupac_name"].ToString();
                            strInchiKey   = EnumResultsTbl.Rows[i]["inchi_key"].ToString();
                            strIdentifier = EnumResultsTbl.Rows[i]["id"].ToString();

                            blVerified = false;

                            if (chkVerifyV2000.Checked)
                            {
                                if (!ChemistryOperations.CheckForV3000Format(strMolString))
                                {
                                    blVerified = true;
                                }
                                else
                                {
                                    strErrMsg = "Molecule is in V3000 format";
                                    break;
                                }
                            }
                            else
                            {
                                blVerified = true;
                            }
                            if (blVerified)
                            {
                                Cursor = Cursors.WaitCursor;

                                if (strEnName == "")
                                {
                                    strEnName = "no name";
                                }
                                if (strIUPACName == "")
                                {
                                    strIUPACName = "IUPAC name not provided";
                                }

                                tanDtl_Id_out = 0;

                                if (strInchiKey != "")//Inchi will be null if result is from Enumeration
                                {
                                    if (!PepsiLiteDataAccess.DataOperations.CheckForDuplicateStructure(strInchiKey, strTanNumber, tanDtl_Id_out))
                                    {
                                        if (PepsiLiteDataAccess.DataOperations.InsertTanDetails(strTanNumber, strMolString, strMolFormula, dblMolWeight, strIUPACName, intPageNo,
                                                                                                strPageLabel, strExampleNo, strTableNo, strEnName, strInchiKey, DateTime.Now, userID, strIdentifier, out tanDtl_Id_out))
                                        {
                                            intCntr++;
                                        }
                                        else
                                        {
                                            strErrMsg = "Error in adding record to TAN";
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        strErrMsg = "Duplicate structure";
                                        break;
                                    }
                                }
                                else
                                {
                                    if (PepsiLiteDataAccess.DataOperations.InsertTanDetails(strTanNumber, strMolString, strMolFormula, dblMolWeight, strIUPACName, intPageNo,
                                                                                            strPageLabel, strExampleNo, strTableNo, strEnName, strInchiKey, DateTime.Now, userID, strIdentifier, out tanDtl_Id_out))
                                    {
                                        intCntr++;
                                    }
                                    else
                                    {
                                        strErrMsg = "Error in adding record to TAN";
                                        break;
                                    }
                                }
                            }
                        }

                        if (intCntr == EnumResultsTbl.Rows.Count)
                        {
                            _errMsg = strErrMsg;
                            return(true);
                        }
                        else
                        {
                            _errMsg = strErrMsg;
                            return(false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            _errMsg = strErrMsg;
            return(false);
        }
Ejemplo n.º 13
0
        private void chemRenditor_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                if (chemRenditor.MolfileString != null)
                {
                    if (chemRenditor.MolfileString.Trim() != "" && strInchi_Before != "")
                    {
                        chemaxon.util.MolHandler molHandler = new MolHandler(chemRenditor.MolfileString);
                        Molecule objMol = molHandler.getMolecule();

                        string strInchi_After = objMol.toFormat("inchi:key");

                        strInchi_After = Validations.GetInchiKeyFromInchiString(strInchi_After);

                        if (strInchi_After != strInchi_Before)
                        {
                            txtMolWeight.Text  = objMol.getMass().ToString();
                            txtMolFormula.Text = objMol.getFormula();

                            if (objMol.isAbsStereo())
                            {
                                lblChiral.Visible = true;
                            }
                            else
                            {
                                lblChiral.Visible = false;
                            }

                            string strMolfile   = objMol.toFormat("mol");
                            string strIUPACName = "";
                            string strErrMsg    = "";
                            if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                            {
                                //strIUPACName = Validations.RemoveSMILESFromIUPACName(strIUPACName);
                                strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                            }
                            else
                            {
                                strIUPACName = "IUPAC name not provided";
                            }
                            txtIUPACName.Text = strIUPACName;
                        }
                    }
                }

                #region Code Commented
                //if (chemRenditor.MolfileString.Trim() != "")
                //{
                //    string strChem = MolDataTbl.Rows[currRecIndex - 1]["Structure"].ToString();
                //    chemaxon.util.MolHandler molHandler_Qry = new MolHandler(chemRenditor.MolfileString.Trim());
                //    Molecule molObj_Qry = molHandler_Qry.getMolecule();

                //    chemaxon.util.MolHandler molHandler_Trgt = new MolHandler(strChem);
                //    Molecule molObj_Trgt = molHandler_Trgt.getMolecule();

                //    string strInchi_Qry = molObj_Qry.toFormat("inchi:key");
                //    string strInchi_Trgt = molObj_Trgt.toFormat("inchi:key");

                //    strInchi_Qry = Validations.GetInchiKeyFromInchiString(strInchi_Qry);
                //    strInchi_Trgt = Validations.GetInchiKeyFromInchiString(strInchi_Trgt);

                //    if (!strInchi_Qry.Equals(strInchi_Trgt))
                //    {
                //       txtMolWeight.Text = molObj_Qry.getMass().ToString();
                //       txtMolFormula.Text = molObj_Qry.getFormula();

                //       if (molObj_Qry.isAbsStereo())
                //       {
                //           lblChiral.Visible = true;
                //       }
                //       else
                //       {
                //           lblChiral.Visible = false;
                //       }

                //        string strMolfile = molObj_Qry.toFormat("mol");
                //        string strIUPACName = "";
                //        string strErrMsg = "";
                //        if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                //        {
                //            strIUPACName = Validations.RemoveSMILESFromIUPACName(strIUPACName);
                //            strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                //        }
                //        else
                //        {
                //            strIUPACName = "IUPAC name not provided";
                //        }
                //        lblIUPACName.Text = strIUPACName;
                //    }
                //}
                #endregion
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 14
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                bool blVerified = false;

                if (chkVerifyV2000.Checked)
                {
                    if (!ChemistryOperations.CheckForV3000Format(chemRenditor.MolfileString))
                    {
                        blVerified = true;
                    }
                    else
                    {
                        MessageBox.Show("Molecule is in V3000 format", "V3000 format", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    blVerified = true;
                }
                if (blVerified)
                {
                    DialogResult diaRes = MessageBox.Show("Do you want to update?", "Update Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (diaRes == DialogResult.Yes)
                    {
                        Molecule objMol_out = null;
                        Cursor = Cursors.WaitCursor;

                        if (!ChemistryOperations.CheckForDuplicateStructure(FileName, chemRenditor.MolfileString, currRecIndex, out objMol_out))
                        {
                            string strMolFile    = chemRenditor.MolfileString;
                            string strMolWeight  = txtMolWeight.Text.Trim();
                            string strMolFormula = txtMolFormula.Text.Trim();
                            string strPageNo     = txtPageNo.Text.Trim();

                            string strPageLabel = txtPageLabel.Text.Trim();
                            if (strPageLabel == "")
                            {
                                strPageLabel = "00";
                            }

                            string strExampleNo = txtExampleNo.Text.Trim();
                            if (strExampleNo == "")
                            {
                                strExampleNo = "00";
                            }

                            string strIUPACName = txtIUPACName.Text.Trim();
                            string strEn_Name   = txten_Name.Text.Trim();

                            if (UpdateRecordInTable(currRecIndex - 1, strMolFile, strMolWeight, strMolFormula, strPageNo,
                                                    strPageLabel, strExampleNo, strIUPACName, strEn_Name))
                            {
                                if (Delete_UpdateOperations.UpdateRecordInSdFile(_filename, currRecIndex, strMolFile, strPageNo, strPageLabel,
                                                                                 strExampleNo, strIUPACName, strEn_Name))
                                {
                                    Cursor = Cursors.Default;
                                    MessageBox.Show("Record updated successfully", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    Cursor = Cursors.Default;
                                    MessageBox.Show("Error in updating", "Update", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                Cursor = Cursors.Default;
                                MessageBox.Show("Error in updating", "Update", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            Cursor = Cursors.Default;
                            MessageBox.Show("Duplicate Record");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 15
0
        private DataTable ReadAllMoleculesIntoTable(MolImporter _molImporter)
        {
            DataTable dtMolData = null;

            try
            {
                dtMolData = ChemistryOperations.CreateTANDetailsTable();

                #region Code Commented
                //dtMolData.Columns.Add("Structure", typeof(object));
                //dtMolData.Columns.Add("MolWeight", typeof(string));
                //dtMolData.Columns.Add("MolFormula", typeof(string));
                //dtMolData.Columns.Add("IupacName", typeof(string));
                //dtMolData.Columns.Add("PageNumber", typeof(string));
                //dtMolData.Columns.Add("PageLabel", typeof(string));
                //dtMolData.Columns.Add("ExampleNumber", typeof(string));
                //dtMolData.Columns.Add("EnName", typeof(string));
                //dtMolData.Columns.Add("IsChiral", typeof(string));
                #endregion

                DataRow dtRow = null;
                while (_molImporter.read(mol))
                {
                    dtRow = dtMolData.NewRow();

                    //Mol Structure
                    dtRow["Structure"] = mol.toFormat("mol");

                    //Mol Weight
                    dtRow["MolWeight"] = mol.getMass().ToString();

                    //Mol Formula
                    dtRow["MolFormula"] = mol.getFormula();

                    //Page No
                    dtRow["PageNumber"] = mol.getProperty("Page Number").Trim();

                    //Page Label
                    dtRow["PageLabel"] = mol.getProperty("Page Label").Trim();

                    //Example Number
                    dtRow["ExampleNumber"] = mol.getProperty("Example Number").Trim();

                    //IUPAC Name
                    dtRow["IupacName"] = mol.getProperty("IUPAC Name").Trim();

                    //en name
                    dtRow["EnName"] = mol.getProperty("en name").Trim();

                    //Is Chiral
                    if (mol.isAbsStereo())
                    {
                        dtRow["IsChiral"] = "True";
                    }
                    else
                    {
                        dtRow["IsChiral"] = "False";
                    }


                    dtMolData.Rows.Add(dtRow);
                }
                return(dtMolData);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(dtMolData);
        }
Ejemplo n.º 16
0
        public static DataTable GetRGroupEnumerationResults(DataTable _enumDataTbl, string _qryRCore)
        {
            DataTable dtEnumResData = new DataTable();

            try
            {
                dtEnumResData.Columns.Add("id", typeof(string));
                dtEnumResData.Columns.Add("structure", typeof(object));
                dtEnumResData.Columns.Add("mol_weight", typeof(double));
                dtEnumResData.Columns.Add("mol_formula", typeof(string));
                dtEnumResData.Columns.Add("iupac_name", typeof(string));
                dtEnumResData.Columns.Add("inchi_key", typeof(string));

                int rgrpNum = 1;

                Molecule   molEnum      = null;
                MolHandler mHandler     = null;
                Molecule   rCoreMol     = null;
                RgMolecule rgMol        = null;
                MolHandler mHand_Result = null;

                DataRow dtRow = null;

                string strMolFile   = "";
                string strIUPACName = "";
                string strErrMsg    = "";

                if (_enumDataTbl != null)
                {
                    if (_enumDataTbl.Rows.Count > 0)
                    {
                        for (int rowindx = 0; rowindx < _enumDataTbl.Rows.Count; rowindx++)
                        {
                            molEnum  = new Molecule();
                            mHandler = new MolHandler(_qryRCore);
                            rCoreMol = mHandler.getMolecule();

                            try
                            {
                                for (int colindx = 1; colindx < _enumDataTbl.Columns.Count; colindx++)
                                {
                                    rgrpNum = GetRgroupNumFromRGroupName(_enumDataTbl.Columns[colindx].ColumnName);
                                    rgMol   = ReturnRGroupMolecule(_enumDataTbl.Rows[rowindx][colindx].ToString(), rgrpNum);
                                    //molEnum = AddRGrpMolToCoreMolecule(rgMol, rCoreMol, rgrpNum);
                                    AddRGrpMolToCoreMolecule(ref rCoreMol, rgMol, rgrpNum);
                                }
                                //Set Radical Empty to Result Mol
                                SetRadicalEmptyToResultMol(ref rCoreMol);

                                mHand_Result = new MolHandler(rCoreMol);
                                strMolFile   = "";
                                strMolFile   = mHand_Result.toFormat("mol");
                            }
                            catch
                            {
                            }
                            dtRow = dtEnumResData.NewRow();

                            dtRow["id"]        = _enumDataTbl.Rows[rowindx][0].ToString();
                            dtRow["structure"] = strMolFile;
                            if (strMolFile != "")
                            {
                                dtRow["mol_weight"]  = mHand_Result.calcMolWeight();
                                dtRow["mol_formula"] = mHand_Result.calcMolFormula();
                                dtRow["inchi_key"]   = ChemistryOperations.GetStructureInchiKey(strMolFile);

                                strIUPACName = "";
                                strErrMsg    = "";
                                if (ChemistryOperations.GetIUPACNameFromStructure(strMolFile, out strIUPACName, out strErrMsg))
                                {
                                    strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                                }
                                else
                                {
                                    strIUPACName = "IUPAC name not provided";
                                }

                                dtRow["iupac_name"] = strIUPACName;
                            }

                            dtEnumResData.Rows.Add(dtRow);
                        }

                        return(dtEnumResData);
                    }
                }
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
            return(dtEnumResData);
        }
Ejemplo n.º 17
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (SearchResults != null)
                {
                    if (SearchResults.Rows.Count > 0)
                    {
                        string strErrMsg = "";
                        if (ValidateUserInputs(out strErrMsg))
                        {
                            DialogResult diaRes = MessageBox.Show("Do you want to update the record?", "Update Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (diaRes == DialogResult.Yes)
                            {
                                int recIndex = currRecIndex;
                                if (recIndex > 1)
                                {
                                    recIndex = recIndex - 1;
                                }
                                else
                                {
                                    recIndex = 0;
                                }
                                int tanDtlID = Convert.ToInt32(SearchResults.Rows[recIndex]["tan_dtl_id"]);

                                string strMolString = chemRenditor_Trgt.MolfileString;
                                string strInchiKey  = ChemistryOperations.GetStructureInchiKey(strMolString);

                                if (!PepsiLiteDataAccess.DataOperations.CheckForDuplicateStructure(strInchiKey, TANNumber, tanDtlID))
                                {
                                    Cursor = Cursors.WaitCursor;

                                    double dblMolWeight  = Convert.ToDouble(txtMolWeight.Text.Trim());
                                    string strMolFormula = txtMolFormula.Text.Trim();

                                    int intPageNo = Convert.ToInt32(txtPageNo.Text.Trim());

                                    string strPageLabel = txtPageLabel.Text.Trim();
                                    if (strPageLabel == "")
                                    {
                                        strPageLabel = "00";
                                    }

                                    string strExampleNo = txtExampleNo.Text.Trim();
                                    if (strExampleNo == "")
                                    {
                                        strExampleNo = "00";
                                    }

                                    string strIUPACName = txtIUPACName.Text.Trim();
                                    string strEn_Name   = txten_Name.Text.Trim();

                                    string strTableNo = txtTableNo.Text.Trim();

                                    bool blVerified = false;

                                    if (chkVerifyV2000.Checked)
                                    {
                                        if (!ChemistryOperations.CheckForV3000Format(strMolString))
                                        {
                                            blVerified = true;
                                        }
                                        else
                                        {
                                            MessageBox.Show("Molecule is in V3000 format", "V3000", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                    else
                                    {
                                        blVerified = true;
                                    }

                                    if (blVerified)
                                    {
                                        if (PepsiLiteDataAccess.DataOperations.UpdateTanDetails(TANNumber, tanDtlID, strMolString, strMolFormula, dblMolWeight, strIUPACName, intPageNo,
                                                                                                strPageLabel, strExampleNo, strTableNo, strEn_Name, strInchiKey, DateTime.Now, UserID))
                                        {
                                            if (UpdateRecordInTable(recIndex, strMolString, dblMolWeight, strMolFormula, intPageNo,
                                                                    strPageLabel, strExampleNo, strIUPACName, strEn_Name, strInchiKey))
                                            {
                                                Cursor = Cursors.Default;
                                                MessageBox.Show("Record updated successfully", "Update Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                            else
                                            {
                                                Cursor = Cursors.Default;
                                                MessageBox.Show("Error in updating", "Update Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            }
                                        }
                                        else
                                        {
                                            Cursor = Cursors.Default;
                                            MessageBox.Show("Error in updating", "Update Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Duplicate Record");
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(strErrMsg, "Invalid user inputs", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 18
0
        private void InsertStructureDetailsInDB()
        {
            try
            {
                if (EnumResultsTbl != null)
                {
                    if (EnumResultsTbl.Rows.Count > 0)
                    {
                        for (int i = 0; i < EnumResultsTbl.Rows.Count; i++)
                        {
                            string strTanNumber = txtTANNo.Text.Trim();

                            string strMolString  = EnumResultsTbl.Rows[i]["structure"].ToString();
                            string strMolFormula = txtMolFormula.Text.Trim();
                            double dblMolWeight  = Convert.ToDouble(txtMolWeight.Text.Trim());

                            int    intPageNo    = Convert.ToInt32(txtPageNo.Text.Trim());
                            string strPageLabel = txtPageLabel.Text.Trim();
                            string strMolFileNo = txtMolFileNo.Text.Trim();
                            string strExampleNo = txtExampleNo.Text.Trim();
                            string strEnName    = txten_Name.Text.Trim();
                            string strIUPACName = txtIUPACName.Text.Trim();
                            string strTableNo   = txtTableNo.Text.Trim();

                            string strInchiKey = ChemistryOperations.GetStructureInchiKey(strMolString);

                            int userID = Generic.Generic_PepsiLite.UserID;

                            bool blVerified = false;

                            if (chkVerifyV2000.Checked)
                            {
                                if (!ChemistryOperations.CheckForV3000Format(chemRenditor.MolfileString))
                                {
                                    blVerified = true;
                                }
                                else
                                {
                                    MessageBox.Show("Molecule is in V3000 format", "V3000", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                blVerified = true;
                            }
                            if (blVerified)
                            {
                                Cursor = Cursors.WaitCursor;

                                if (strEnName == "")
                                {
                                    strEnName = "no name";
                                }
                                if (strIUPACName == "")
                                {
                                    strIUPACName = "IUPAC name not provided";
                                }

                                int tanDtl_Id_out = 0;

                                if (!PepsiLiteDataAccess.DataOperations.CheckForDuplicateStructure(strInchiKey, strTanNumber, tanDtl_Id_out))
                                {
                                    if (PepsiLiteDataAccess.DataOperations.InsertTanDetails(strTanNumber, strMolString, strMolFormula, dblMolWeight, strIUPACName, intPageNo,
                                                                                            strPageLabel, strExampleNo, strTableNo, strEnName, strInchiKey, DateTime.Now, userID, Generic.Generic_PepsiLite.UserRoleID, "", out tanDtl_Id_out))
                                    {
                                    }
                                    else
                                    {
                                        MessageBox.Show("Error in adding record to TAN", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Duplicate structure", "Duplicate Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Ejemplo n.º 19
0
        private string GetSearchQuery(int _tanID)
        {
            string strSrchQry = "";

            try
            {
                strSrchQry = "select * from pepsilite.tan_details where tan_id = " + _tanID;

                //Structure
                if (chemRenditor_Qry.MolfileString != null)
                {
                    string strInchiKey = ChemistryOperations.GetStructureInchiKey(chemRenditor_Qry.MolfileString);
                    strSrchQry = strSrchQry + " and inchi_key = '" + strInchiKey + "' ";
                }
                //Mol Formula
                if (txtMolFormula_Qry.Text.Trim() != "")
                {
                    string strMolFormulaQry = GetSearchOperator(cmbMolFormula, txtMolFormula_Qry, "mol_formula");
                    strSrchQry = strSrchQry + " and " + strMolFormulaQry;
                }
                //Mol Weight
                if (txtMolWeight_Qry.Text.Trim() != "")
                {
                    string strMolWeightQry = GetSearchOperator(cmbMolWeight, txtMolWeight_Qry, "mol_weight");
                    strSrchQry = strSrchQry + " and " + strMolWeightQry;
                }
                //Page Number
                if (txtPageNum_Qry.Text.Trim() != "")
                {
                    string strPageNumQry = GetSearchOperator(cmbPageNum, txtPageNum_Qry, "page_number");
                    strSrchQry = strSrchQry + " and " + strPageNumQry;
                }
                //Page Label
                if (txtPageLabel_Qry.Text.Trim() != "")
                {
                    string strPagelabelQry = GetSearchOperator(cmbPageLabel, txtPageLabel_Qry, "page_label");
                    strSrchQry = strSrchQry + " and " + strPagelabelQry;
                }
                //Example Number
                if (txtExampleNo_Qry.Text.Trim() != "")
                {
                    string strExampleQry = GetSearchOperator(cmbExampleNo, txtExampleNo_Qry, "example_number");
                    strSrchQry = strSrchQry + " and " + strExampleQry;
                }
                //Table Number
                if (txtTableNo_Qry.Text.Trim() != "")
                {
                    string strTableNoQry = GetSearchOperator(cmbTableNo, txtTableNo_Qry, "table_number");
                    strSrchQry = strSrchQry + " and " + strTableNoQry;
                }
                //IUPAC Name
                if (txtIUPACName_Qry.Text.Trim() != "")
                {
                    string strIUPACQry = GetSearchOperator(cmbIUPACName, txtIUPACName_Qry, "iupac_name");
                    strSrchQry = strSrchQry + " and " + strIUPACQry;
                }
                //en Name
                if (txtEnName_Qry.Text.Trim() != "")
                {
                    string strEnNameQry = GetSearchOperator(cmbEnName, txtEnName_Qry, "en_name");
                    strSrchQry = strSrchQry + " and " + strEnNameQry;
                }

                return(strSrchQry);
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
            return(strSrchQry);
        }