Example #1
0
        public string PrepareMsg(Exception Ex, string mModuleName)
        {
            string FinalMsg = "";
            string str;
            string ExeMsg = Ex.Message;

            string[] SplitStr;
            string[] Msg;
            if (ExeMsg.StartsWith("The DELETE statement conflicted with the REFERENCE"))
            {
                if (Ex.ToString().IndexOf("FK_") > 0)
                {
                    str      = Ex.ToString().Substring(Ex.ToString().IndexOf("FK_"), Ex.ToString().Length - Ex.ToString().IndexOf("FK_"));
                    SplitStr = str.Split('.');

                    str = SplitStr[0];
                    str = str.Substring(0, str.Length - 1);

                    Msg = str.Split('_');

                    FinalMsg = Msg[2].Replace('-', ' ') + " is associated with " + Msg[1].Replace('-', ' ');
                    FinalMsg = FinalMsg.Substring(0, 1) + FinalMsg.Substring(1, FinalMsg.Length - 1).ToLower();
                }
            }
            else
            {
                BusinessLogic.Common ObjComm = new Account.BusinessLogic.Common();
                ObjComm.WriteExceptionLog(DateTime.Now, ExeMsg, mModuleName);
            }
            return(FinalMsg);
        }
Example #2
0
        //Created By Manoj Savalia on 04-09-2010
        public void GetBackUp(string spName, NameValueCollection paramNameValue, bool withOutPara, string mModuleName)
        {
            //Connection String for Local
            //  string SQLConnectionString = @"Data Source=Manoj;Initial Catalog=Account_Master;Integrated Security = true";
            Account.Common.Encryption Encry = new Account.Common.Encryption();
            Encry.DecryptBackUP();
            //Connection String for Development
            string SQLConnectionString = Account.Common.Encryption.ConstrBackUP;



            // SQL Connection Object
            SqlConnection cnnConnection = new SqlConnection(SQLConnectionString);
            SqlCommand    cmdSQLCommand = new SqlCommand();
            IEnumerator   iEnum         = default(IEnumerator);

            if (paramNameValue != null)
            {
                iEnum = paramNameValue.GetEnumerator();
            }
            // Initialize the Exception ...
            this.Exception    = null;
            this.ErrorMessage = "";
            try
            {
                // Prepare DataAdapter ...
                cmdSQLCommand.Connection  = cnnConnection;
                cmdSQLCommand.CommandText = spName;
                cmdSQLCommand.CommandType = CommandType.StoredProcedure;
                // Pass Parameters ...
                if (paramNameValue != null)
                {
                    while (iEnum.MoveNext())
                    {
                        cmdSQLCommand.Parameters.AddWithValue(iEnum.Current.ToString(), paramNameValue.GetValues(iEnum.Current.ToString()).GetValue(0).ToString().Trim());
                    }
                }
                if (withOutPara == true)
                {
                    // Add output parameters ...
                    cmdSQLCommand.Parameters.Add("@o_ErrorMesg", SqlDbType.VarChar, 250).Direction = ParameterDirection.Output;
                }
                // Open Database Connection ...
                cnnConnection.Open();
                cmdSQLCommand.ExecuteNonQuery();
                // Read values of Output Parameters
                if (withOutPara == true)
                {
                    // Read Values of Output Paramters and Stored into Property
                    this.ErrorMessage = (string)(cmdSQLCommand.Parameters["@o_ErrorMesg"].Value);
                }
                else
                {
                    this.ErrorMessage = "";
                }
            }
            catch (Exception exception)
            {
                // Set the Exception ...
                this.Exception = exception;
                if (cnnConnection.State == ConnectionState.Open)
                {
                    cnnConnection.Close();
                }
                // Insert Exception
                BusinessLogic.Common ObjComm = new Account.BusinessLogic.Common();
                ObjComm.WriteExceptionLog(DateTime.Now, exception.Message, mModuleName);
            }
            finally
            {
                if (cnnConnection.State == ConnectionState.Open)
                {
                    cnnConnection.Close();
                }
            }
        }
Example #3
0
        public DataSet ExecuteDataSetSP(string spName, NameValueCollection paramNameValue, Boolean withOutPara, ref Exception mException, ref string mErrorMsg, string mModuleName)
        {
            SqlDataAdapter daDataAdapter = new SqlDataAdapter();
            DataSet        dsDataSet     = new DataSet();

            IEnumerator iEnum = default(IEnumerator);

            if (paramNameValue != null)
            {
                iEnum = paramNameValue.GetEnumerator();
            }
            // Initialize the Exception ...
            this.Exception = null;
            try
            {
                // Prepare DataAdapter ...
                daDataAdapter.SelectCommand             = new SqlCommand();
                daDataAdapter.SelectCommand.Connection  = cnnConnection;
                daDataAdapter.SelectCommand.CommandText = spName;
                daDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                // Pass Parameters ...
                if (paramNameValue != null)
                {
                    while (iEnum.MoveNext())
                    {
                        daDataAdapter.SelectCommand.Parameters.AddWithValue(iEnum.Current.ToString(), paramNameValue.GetValues(iEnum.Current.ToString()).GetValue(0).ToString().Trim());
                    }
                }

                if (withOutPara == true)
                {
                    // Add output parameters ...
                    daDataAdapter.SelectCommand.Parameters.Add("@o_ErrorMesg", SqlDbType.VarChar, 250).Direction = ParameterDirection.Output;
                }

                // Open Database Connection ...
                cnnConnection.Open();

                // Fill the DataSet ...
                daDataAdapter.Fill(dsDataSet);

                // Read values of Output Parameters
                if (withOutPara == true)
                {
                    // Read Values of Output Paramters and Stored into Property
                    mErrorMsg = (string)(daDataAdapter.SelectCommand.Parameters["@o_ErrorMesg"].Value);
                }
                else
                {
                    mErrorMsg = "";
                }
            }
            catch (Exception exception)
            {
                // Set the Exception ...
                mException = exception;
                // Insert Exception
                if (cnnConnection.State == ConnectionState.Open)
                {
                    cnnConnection.Close();
                }
                BusinessLogic.Common ObjComm = new Account.BusinessLogic.Common();
                ObjComm.WriteExceptionLog(DateTime.Now, exception.Message, mModuleName);
                dsDataSet = null;
            }
            finally
            {
                if (cnnConnection.State == ConnectionState.Open)
                {
                    cnnConnection.Close();
                }
            }
            return(dsDataSet);
        }