コード例 #1
0
        public int personLevelIsDuplicate(E_PersonLevel oPersonLevel)
        {
            SqlConnection sqlCnn = null;
            SqlCommand    sqlCmd = null;

            int result = -1;

            Util.Tools.Clear(sql);
            sql.Append("SELECT COUNT(1) ")
            .Append("FROM person_level ")
            .Append("WHERE level_description = @Level_Description ");

            System.Diagnostics.Debug.WriteLine(sql.ToString());

            try
            {
                sqlCnn = oConn.GetConnection();
                sqlCmd = new SqlCommand(sql.ToString(), sqlCnn);
                sqlCmd.Parameters.AddWithValue("@Level_Description", oPersonLevel.getLevel_Description());
                result = (int)sqlCmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
                throw ex;
            }
            finally {
                sqlCmd.Dispose();
                sqlCnn.Close();
            }
            return(result);
        }
コード例 #2
0
        public int personLevelIns(E_PersonLevel oPersonLevel)
        {
            SqlConnection sqlCnn = null;
            SqlCommand    sqlCmd = null;
            int           result = -1;

            Util.Tools.Clear(sql);
            sql.Append("INSERT INTO Person_Level( ")
            .Append("id_Level, ")
            .Append("Level_Description, ")
            .Append("Level_status, ")
            .Append("Level_CreateBy, ")
            .Append("Level_DateBy ")
            .Append(") ")
            .Append("VALUES ( ")
            .Append("@id_Level, ")
            .Append("@Level_Description, ")
            .Append("@Level_status, ")
            .Append("@Level_CreateBy, ")
            .Append("@Level_DateBy ")
            .Append(") ");
            System.Diagnostics.Debug.WriteLine(sql.ToString());

            try {
                sqlCnn = oConn.GetConnection();
                sqlCmd = new SqlCommand(sql.ToString(), sqlCnn);
                sqlCmd.Parameters.AddWithValue("@id_Level", oPersonLevel.getId_Level());
                sqlCmd.Parameters.AddWithValue("@Level_Description", oPersonLevel.getLevel_Description());
                sqlCmd.Parameters.AddWithValue("@Level_status", oPersonLevel.getLevel_Status());
                sqlCmd.Parameters.AddWithValue("@Level_CreateBy", oPersonLevel.getLevel_CreateBy());
                sqlCmd.Parameters.AddWithValue("@Level_DateBy", oPersonLevel.getLevel_DateBy());

                result = sqlCmd.ExecuteNonQuery();
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
                throw ex;
            }
            finally {
                sqlCmd.Dispose();
                sqlCnn.Close();
            }
            return(result);
        }