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()); } }
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); }
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()); } }
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()); } }