Example #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());
            }
        }
Example #2
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);
     }
 }
Example #3
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());
            }
        }
 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);
     }
 }
Example #5
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);
        }
Example #6
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);
        }
Example #7
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());
            }
        }
Example #8
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());
            }
        }
Example #9
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);
        }