Esempio n. 1
0
        public int Delete(dynamic pId)
        {
            try
            {
                using (SqlConnection oCon = new SqlConnection())
                {
                    oCon.ConnectionString = _Connection;
                    using (SqlCommand oSql = new SqlCommand())
                    {
                        oSql.Connection  = oCon;
                        oSql.CommandText = "Delete from " + Call + " where " + NameTable + "ID = @id";
                        oSql.CommandType = CommandType.Text;

                        SqlParameter oParam = new SqlParameter("@id", pId);
                        oSql.Parameters.Add(oParam);

                        oSql.Connection.Open();
                        return(oSql.ExecuteNonQuery());
                    }
                }
            }
            catch (SqlException exsql)
            {
                CustomError.BusinessError be = new CustomError.BusinessError(exsql);
                throw be;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public int Execute(List <SqlParameter> lstParam, string pProcedureType)
        {
            try
            {
                using (SqlConnection oCon = new SqlConnection())
                {
                    oCon.ConnectionString = _Connection;
                    using (SqlCommand oSql = new SqlCommand())
                    {
                        oSql.Connection  = oCon;
                        oSql.CommandText = "secretariat." + Call + "_" + pProcedureType;
                        oSql.CommandType = CommandType.StoredProcedure;

                        foreach (SqlParameter oParam in lstParam)
                        {
                            oSql.Parameters.Add(oParam);
                        }

                        oSql.Connection.Open();
                        return(oSql.ExecuteNonQuery());
                    }
                }
            }
            catch (SqlException exsql)
            {
                CustomError.BusinessError be = new CustomError.BusinessError(exsql);
                throw be;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public DataSet LoadData(out string callOut)
        {
            try
            {
                using (SqlConnection oCon = new SqlConnection())
                {
                    oCon.ConnectionString = _Connection;
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    SqlCommand     oSelect = new SqlCommand();

                    oSelect.Connection  = oCon;
                    oSelect.CommandText = "Select * from " + Call;
                    oSelect.CommandType = CommandType.Text;

                    adapter.SelectCommand = oSelect;

                    DataSet data = new DataSet();

                    callOut = "My" + Call;
                    adapter.Fill(data, callOut);

                    return(data);
                }
            }
            catch (SqlException exsql)
            {
                CustomError.BusinessError be = new CustomError.BusinessError(exsql);
                throw be;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }