Пример #1
0
        private void btnDeleteCompound_Click(object sender, EventArgs e)
        {
            try
            {
                CompoundInfo objCompInfo = ucSpectral.GetCompoundInformation();
                if (objCompInfo != null)
                {
                    if (objCompInfo.CompoundID > 0)
                    {
                        DialogResult diaRes = MessageBox.Show("Do you want to delete the compound?", "ChemInform", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (diaRes == System.Windows.Forms.DialogResult.Yes)
                        {
                            //Delete compound information in the database on CompoundID
                            if (SpectralCurationDB.DeleteCompoundDataOnID(objCompInfo))
                            {
                                //Reset control values
                                ucSpectral.ResetAllControlValues();

                                //Refresh Document Compounds after Compound deleted
                                DocCompounds = Dal.SpectralCurationDB.GetCompoundsOnDocumentID(DocumentID);

                                MaxRecCnt             = DocCompounds.Rows.Count;
                                numGotoRecord.Maximum = MaxRecCnt;

                                if (currRecIndex < MaxRecCnt && currRecIndex > 1)
                                {
                                    currRecIndex = currRecIndex - 1;
                                }
                                else if (currRecIndex == MaxRecCnt && MaxRecCnt > 1)
                                {
                                    currRecIndex = currRecIndex; //currRecIndex - 1;
                                }
                                else if (currRecIndex < MaxRecCnt && currRecIndex == 1)
                                {
                                    currRecIndex = currRecIndex + 1;
                                }
                                else if (currRecIndex > MaxRecCnt)//New condition on 13th Sep 2011
                                {
                                    currRecIndex = MaxRecCnt;
                                }

                                blValidComp            = true;
                                numGotoRecord.Value    = currRecIndex;
                                btnAddCompound.Enabled = true;

                                MessageBox.Show("Compound deleted successfully", "ChemInform", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("Error in compound delete", "ChemInform", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Пример #2
0
        private bool ValidateAndSaveCompoundData()
        {
            bool blStatus = false;

            try
            {
                string strErrMsg = "";

                //Validate Spectral curation controls
                if (ValidateUserInputs(ref strErrMsg))
                {
                    //Save Compound Information
                    CompoundInfo objCompInfo = ucSpectral.GetCompoundInformation();
                    if (objCompInfo != null)
                    {
                        SpectralCurationDB.UpdateCompoundInformation(objCompInfo, GlobalVariables.LogInUserInfo);
                    }

                    //Save NMR Spectral Information
                    List <NMRSpectralInfo> lstNMRSpectrals = ucSpectral.GetNMRSpectralInformation();
                    if (lstNMRSpectrals != null)
                    {
                        for (int i = 0; i < lstNMRSpectrals.Count; i++)
                        {
                            SpectralCurationDB.UpdateNMRSpectralInformation(lstNMRSpectrals[i], GlobalVariables.LogInUserInfo);
                        }
                    }

                    //Save Other Spectral Information
                    List <OtherSpectralInfo> lstOtherSpectrals = ucSpectral.GetOtherSpectralInformation();
                    if (lstOtherSpectrals != null)
                    {
                        for (int i = 0; i < lstOtherSpectrals.Count; i++)
                        {
                            SpectralCurationDB.UpdateOtherSpectralInformation(lstOtherSpectrals[i], GlobalVariables.LogInUserInfo);
                        }
                    }

                    blStatus = true;
                }
                else
                {
                    MessageBox.Show(strErrMsg.Trim(), "ChemInform", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
            return(blStatus);
        }