Ejemplo n.º 1
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());
            }
        }